Add SDL 3 support to the Makefile.

This is hidden behind WITH_SDL3, which is disabled by default.

Additionally rename the SDL sources files in the client to represent the
SDL major version they are supporting. They will be forked for SDL 3.
That isn't optimal, because it forces us to support two variants of the
same code. However the changes between SDL 2 and 3 are too big to work
with #ifdef and something like function pointer magic is even more
confusing.
This commit is contained in:
Yamagi 2024-03-28 08:46:53 +01:00
parent 34d2ddc2a9
commit 126c2ea10b
4 changed files with 31 additions and 5 deletions

View file

@ -53,6 +53,9 @@ WITH_OPENAL:=yes
# or libopenal.so. Not supported on Windows.
WITH_RPATH:=yes
# Builds with SDL 3 instead of SDL 2.
WITH_SDL3:=no
# Enable systemwide installation of game assets.
WITH_SYSTEMWIDE:=no
@ -276,7 +279,12 @@ endif
# ----------
# Extra CFLAGS for SDL.
ifeq ($(WITH_SDL3),yes)
SDLCFLAGS := $(shell pkgconf --cflags sdl3)
SDLCFLAGS += -DUSE_SDL3
else
SDLCFLAGS := $(shell sdl2-config --cflags)
endif
# ----------
@ -353,11 +361,19 @@ endif
# ----------
# Extra LDFLAGS for SDL
ifeq ($(WITH_SDL3),yes)
ifeq ($(YQ2_OSTYPE), Darwin)
SDLLDFLAGS := -lSDL3
else
SDLLDFLAGS := $(shell pkgconf --libs sdl3)
endif
else
ifeq ($(YQ2_OSTYPE), Darwin)
SDLLDFLAGS := -lSDL2
else # not Darwin
else
SDLLDFLAGS := $(shell sdl2-config --libs)
endif # Darwin
endif
endif
# The renderer libs don't need libSDL2main, libmingw32 or -mwindows.
ifeq ($(YQ2_OSTYPE), Windows)
@ -394,6 +410,7 @@ config:
@echo "WITH_CURL = $(WITH_CURL)"
@echo "WITH_OPENAL = $(WITH_OPENAL)"
@echo "WITH_RPATH = $(WITH_RPATH)"
@echo "WITH_SDL3 = $(WITH_SDL3)"
@echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)"
@echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)"
@echo "============================"
@ -852,17 +869,14 @@ CLIENT_OBJS_ := \
src/client/cl_view.o \
src/client/curl/download.o \
src/client/curl/qcurl.o \
src/client/input/sdl.o \
src/client/menu/menu.o \
src/client/menu/qmenu.o \
src/client/menu/videomenu.o \
src/client/sound/sdl.o \
src/client/sound/ogg.o \
src/client/sound/openal.o \
src/client/sound/qal.o \
src/client/sound/sound.o \
src/client/sound/wave.o \
src/client/vid/glimp_sdl.o \
src/client/vid/vid.o \
src/common/argproc.o \
src/common/clientserver.o \
@ -898,6 +912,18 @@ CLIENT_OBJS_ := \
src/server/sv_user.o \
src/server/sv_world.o
ifeq ($(WITH_SDL3),yes)
CLIENT_OBJS_ += \
src/client/input/sdl3.o \
src/client/sound/sdl3.o \
src/client/vid/glimp_sdl3.o
else
CLIENT_OBJS_ += \
src/client/input/sdl2.o \
src/client/sound/sdl2.o \
src/client/vid/glimp_sdl2.o
endif
ifeq ($(YQ2_OSTYPE), Windows)
CLIENT_OBJS_ += \
src/backends/windows/main.o \

View file