@@ -240,6 +240,10 @@ ifndef DEBUG_CFLAGS
240240DEBUG_CFLAGS =-g -O0
241241endif
242242
243+ ifndef SDL_VERSION
244+ SDL_VERSION =2
245+ endif
246+
243247# ############################################################################
244248
245249BD =$(BUILD_DIR ) /debug-$(PLATFORM ) -$(ARCH )
@@ -274,7 +278,11 @@ Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc
274278Q3LCCSRCDIR =$(MOUNT_DIR ) /tools/lcc/src
275279LOKISETUPDIR =misc/setup
276280NSISDIR =misc/nsis
277- SDLHDIR =$(MOUNT_DIR ) /SDL12
281+ ifeq ($(SDL_VERSION ) ,2)
282+ SDLHDIR =$(MOUNT_DIR ) /SDL2
283+ else
284+ SDLHDIR =$(MOUNT_DIR ) /SDL12
285+ endif
278286LIBSDIR =$(MOUNT_DIR ) /libs
279287
280288bin_path =$(shell which $(1 ) 2> /dev/null)
@@ -288,15 +296,27 @@ ifneq ($(BUILD_CLIENT),0)
288296 CURL_LIBS =$(shell pkg-config --silence-errors --libs libcurl)
289297 OPENAL_CFLAGS =$(shell pkg-config --silence-errors --cflags openal)
290298 OPENAL_LIBS =$(shell pkg-config --silence-errors --libs openal)
291- SDL_CFLAGS =$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
292- SDL_LIBS =$(shell pkg-config --silence-errors --libs sdl)
299+ ifeq ($(SDL_VERSION),2)
300+ SDL_CFLAGS =$(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
301+ SDL_LIBS =$(shell pkg-config --silence-errors --libs sdl2)
302+ else
303+ SDL_CFLAGS =$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
304+ SDL_LIBS =$(shell pkg-config --silence-errors --libs sdl)
305+ endif
293306 FREETYPE_CFLAGS =$(shell pkg-config --silence-errors --cflags freetype2)
294307 endif
295308 # Use sdl-config if all else fails
296309 ifeq ($(SDL_CFLAGS),)
297- ifneq ($(call bin_path, sdl-config),)
298- SDL_CFLAGS =$(shell sdl-config --cflags)
299- SDL_LIBS =$(shell sdl-config --libs)
310+ ifeq ($(SDL_VERSION),2)
311+ ifneq ($(call bin_path, sdl2-config),)
312+ SDL_CFLAGS =$(shell sdl2-config --cflags)
313+ SDL_LIBS =$(shell sdl2-config --libs)
314+ endif
315+ else
316+ ifneq ($(call bin_path, sdl-config),)
317+ SDL_CFLAGS =$(shell sdl-config --cflags)
318+ SDL_LIBS =$(shell sdl-config --libs)
319+ endif
300320 endif
301321 endif
302322endif
@@ -495,11 +515,17 @@ ifeq ($(PLATFORM),darwin)
495515
496516 # We copy sdlmain before ranlib'ing it so that subversion doesn't think
497517 # the file has been modified by each build.
498- LIBSDLMAIN =$(B ) /libSDLmain.a
499- LIBSDLMAINSRC =$(LIBSDIR ) /macosx/libSDLmain.a
500- CLIENT_LIBS += -framework IOKit \
501- $(LIBSDIR ) /macosx/libSDL-1.2.0.dylib
502- RENDERER_LIBS += -framework OpenGL $(LIBSDIR ) /macosx/libSDL-1.2.0.dylib
518+ ifeq ($(SDL_VERSION),2)
519+ LIBSDLMAIN =$(B ) /libSDL2main.a
520+ LIBSDLMAINSRC =$(LIBSDIR ) /macosx/libSDL2main.a
521+ CLIENT_LIBS += -framework IOKit $(LIBSDIR ) /macosx/libSDL2-2.0.0.dylib
522+ RENDERER_LIBS += -framework OpenGL $(LIBSDIR ) /macosx/libSDL2-2.0.0.dylib
523+ else
524+ LIBSDLMAIN =$(B ) /libSDLmain.a
525+ LIBSDLMAINSRC =$(LIBSDIR ) /macosx/libSDLmain.a
526+ CLIENT_LIBS += -framework IOKit $(LIBSDIR ) /macosx/libSDL-1.2.0.dylib
527+ RENDERER_LIBS += -framework OpenGL $(LIBSDIR ) /macosx/libSDL-1.2.0.dylib
528+ endif
503529
504530 OPTIMIZEVM += -falign-loops=16
505531 OPTIMIZE = $(OPTIMIZEVM ) -ffast-math
@@ -643,24 +669,44 @@ ifeq ($(PLATFORM),mingw32)
643669
644670 ifeq ($(USE_LOCAL_HEADERS),1)
645671 CLIENT_CFLAGS += -I$(SDLHDIR ) /include
646- ifeq ($(ARCH),x86)
647- CLIENT_LIBS += $(LIBSDIR ) /win32/libSDLmain.a \
648- $(LIBSDIR ) /win32/libSDL.dll.a
649- RENDERER_LIBS += $(LIBSDIR ) /win32/libSDLmain.a \
650- $(LIBSDIR ) /win32/libSDL.dll.a
651- SDLDLL =SDL.dll
672+ ifeq ($(SDL_VERSION),2)
673+ ifeq ($(ARCH),x86)
674+ CLIENT_LIBS += $(LIBSDIR ) /win32/libSDL2main.a \
675+ $(LIBSDIR ) /win32/libSDL2.dll.a
676+ RENDERER_LIBS += $(LIBSDIR ) /win32/libSDL2main.a \
677+ $(LIBSDIR ) /win32/libSDL2.dll.a
678+ SDLDLL =SDL2.dll
679+ else
680+ CLIENT_LIBS += $(LIBSDIR ) /win64/libSDL264main.a \
681+ $(LIBSDIR ) /win64/libSDL264.dll.a
682+ RENDERER_LIBS += $(LIBSDIR ) /win64/libSDL264main.a \
683+ $(LIBSDIR ) /win64/libSDL264.dll.a
684+ SDLDLL =SDL264.dll
685+ endif
652686 else
653- CLIENT_LIBS += $(LIBSDIR ) /win64/libSDLmain.a \
654- $(LIBSDIR ) /win64/libSDL64.dll.a
655- RENDERER_LIBS += $(LIBSDIR ) /win64/libSDLmain.a \
656- $(LIBSDIR ) /win64/libSDL64.dll.a
657- SDLDLL =SDL64.dll
687+ ifeq ($(ARCH),x86)
688+ CLIENT_LIBS += $(LIBSDIR ) /win32/libSDLmain.a \
689+ $(LIBSDIR ) /win32/libSDL.dll.a
690+ RENDERER_LIBS += $(LIBSDIR ) /win32/libSDLmain.a \
691+ $(LIBSDIR ) /win32/libSDL.dll.a
692+ SDLDLL =SDL.dll
693+ else
694+ CLIENT_LIBS += $(LIBSDIR ) /win64/libSDLmain.a \
695+ $(LIBSDIR ) /win64/libSDL64.dll.a
696+ RENDERER_LIBS += $(LIBSDIR ) /win64/libSDLmain.a \
697+ $(LIBSDIR ) /win64/libSDL64.dll.a
698+ SDLDLL =SDL64.dll
699+ endif
658700 endif
659701 else
660702 CLIENT_CFLAGS += $(SDL_CFLAGS )
661703 CLIENT_LIBS += $(SDL_LIBS )
662704 RENDERER_LIBS += $(SDL_LIBS )
663- SDLDLL =SDL.dll
705+ ifeq ($(SDL_VERSION),2)
706+ SDLDLL =SDL2.dll
707+ else
708+ SDLDLL =SDL.dll
709+ endif
664710 endif
665711
666712else # ifeq mingw32
0 commit comments