GL3: build ref_gles3 in addition to ref_gl3

instead of making it a compile-time option, just build both
This commit is contained in:
Daniel Gibson 2022-04-26 19:18:45 +02:00
parent a195305592
commit 2a8bd9e7a6
1 changed files with 85 additions and 41 deletions

126
Makefile
View File

@ -53,9 +53,6 @@ WITH_OPENAL:=yes
# or libopenal.so. Not supported on Windows. # or libopenal.so. Not supported on Windows.
WITH_RPATH:=yes WITH_RPATH:=yes
# if set to yes, use OpenGL ES 3.0 instead of desktop OpenGL 3
GL3_GLES3:=no
# Enable systemwide installation of game assets. # Enable systemwide installation of game assets.
WITH_SYSTEMWIDE:=no WITH_SYSTEMWIDE:=no
@ -303,15 +300,6 @@ endif
# ---------- # ----------
# Local includes for GLAD.
ifeq ($(GL3_GLES3),yes)
GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad-gles3/include
else
GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad/include
endif
# ----------
# Base LDFLAGS. This is just the library path. # Base LDFLAGS. This is just the library path.
ifeq ($(YQ2_OSTYPE),Linux) ifeq ($(YQ2_OSTYPE),Linux)
LDFLAGS ?= -L/usr/lib LDFLAGS ?= -L/usr/lib
@ -394,12 +382,12 @@ endif
# ---------- # ----------
# Phony targets # Phony targets
.PHONY : all client game icon server ref_gl1 ref_gl3 ref_soft .PHONY : all client game icon server ref_gl1 ref_gl3 ref_gles3 ref_soft
# ---------- # ----------
# Builds everything # Builds everything
all: config client server game ref_gl1 ref_gl3 ref_soft all: config client server game ref_gl1 ref_gl3 ref_gles3 ref_soft
# ---------- # ----------
@ -413,7 +401,6 @@ config:
@echo "WITH_RPATH = $(WITH_RPATH)" @echo "WITH_RPATH = $(WITH_RPATH)"
@echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)" @echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)"
@echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)" @echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)"
@echo "GL3_GLES3 = $(GL3_GLES3)"
@echo "============================" @echo "============================"
@echo "" @echo ""
@ -626,45 +613,28 @@ ref_gl3:
@echo "===> Building ref_gl3.dll" @echo "===> Building ref_gl3.dll"
$(MAKE) release/ref_gl3.dll $(MAKE) release/ref_gl3.dll
release/ref_gl3.dll : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad/include
release/ref_gl3.dll : LDFLAGS += -shared release/ref_gl3.dll : LDFLAGS += -shared
ifeq ($(GL3_GLES3),yes)
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gl3.dll : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES
endif
else ifeq ($(YQ2_OSTYPE), Darwin) else ifeq ($(YQ2_OSTYPE), Darwin)
ref_gl3: ref_gl3:
@echo "===> Building ref_gl3.dylib" @echo "===> Building ref_gl3.dylib"
$(MAKE) release/ref_gl3.dylib $(MAKE) release/ref_gl3.dylib
release/ref_gl3.dylib : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad/include
release/ref_gl3.dylib : LDFLAGS += -shared release/ref_gl3.dylib : LDFLAGS += -shared
ifeq ($(GL3_GLES3),yes)
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gl3.dylib : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES
endif
else # not Windows or Darwin else # not Windows or Darwin
ref_gl3: ref_gl3:
@echo "===> Building ref_gl3.so" @echo "===> Building ref_gl3.so"
$(MAKE) release/ref_gl3.so $(MAKE) release/ref_gl3.so
release/ref_gl3.so : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad/include
release/ref_gl3.so : CFLAGS += -fPIC release/ref_gl3.so : CFLAGS += -fPIC
release/ref_gl3.so : LDFLAGS += -shared release/ref_gl3.so : LDFLAGS += -shared
ifeq ($(GL3_GLES3),yes)
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gl3.so : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES
endif
endif # OS specific ref_gl3 stuff endif # OS specific ref_gl3 stuff
build/ref_gl3/%.o: %.c build/ref_gl3/%.o: %.c
@ -674,6 +644,61 @@ build/ref_gl3/%.o: %.c
# ---------- # ----------
# The OpenGL ES 3.0 renderer lib
ifeq ($(YQ2_OSTYPE), Windows)
ref_gles3:
@echo "===> Building ref_gles3.dll"
$(MAKE) release/ref_gles3.dll
release/ref_gles3.dll : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad-gles3/include
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gles3.dll : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES
release/ref_gles3.dll : LDFLAGS += -shared
else ifeq ($(YQ2_OSTYPE), Darwin)
ref_gles3:
@echo "===> Building ref_gles3.dylib"
$(MAKE) release/ref_gles3.dylib
release/ref_gles3.dylib : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad-gles3/include
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gles3.dylib : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES
release/ref_gles3.dylib : LDFLAGS += -shared
else # not Windows or Darwin
ref_gles3:
@echo "===> Building ref_gles3.so"
$(MAKE) release/ref_gles3.so
release/ref_gles3.so : GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad-gles3/include
# YQ2_GL3_GLES3 is for GLES3, DYQ2_GL3_GLES is for things that are identical
# in both GLES3 and GLES2 (in case we ever support that)
release/ref_gles3.so : CFLAGS += -DYQ2_GL3_GLES3 -DYQ2_GL3_GLES -fPIC
release/ref_gles3.so : LDFLAGS += -shared
GLAD_INCLUDE = -Isrc/client/refresh/gl3/glad-gles3/include
endif # OS specific ref_gl3 stuff
build/ref_gles3/%.o: %.c
@echo "===> CC $<"
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) $(GLAD_INCLUDE) -o $@ $<
# ----------
# The soft renderer lib # The soft renderer lib
ifeq ($(YQ2_OSTYPE), Windows) ifeq ($(YQ2_OSTYPE), Windows)
@ -948,13 +973,11 @@ REFGL3_OBJS_ := \
src/common/shared/shared.o \ src/common/shared/shared.o \
src/common/md4.o src/common/md4.o
ifeq ($(GL3_GLES3),yes) REFGL3_OBJS_GLADE_ := \
REFGL3_OBJS_ += \
src/client/refresh/gl3/glad-gles3/src/glad.o
else # desktop GL3 (not ES)
REFGL3_OBJS_ += \
src/client/refresh/gl3/glad/src/glad.o src/client/refresh/gl3/glad/src/glad.o
endif
REFGL3_OBJS_GLADEES_ := \
src/client/refresh/gl3/glad-gles3/src/glad.o
ifeq ($(YQ2_OSTYPE), Windows) ifeq ($(YQ2_OSTYPE), Windows)
REFGL3_OBJS_ += \ REFGL3_OBJS_ += \
@ -1056,6 +1079,9 @@ endif
CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_)) CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_))
REFGL1_OBJS = $(patsubst %,build/ref_gl1/%,$(REFGL1_OBJS_)) REFGL1_OBJS = $(patsubst %,build/ref_gl1/%,$(REFGL1_OBJS_))
REFGL3_OBJS = $(patsubst %,build/ref_gl3/%,$(REFGL3_OBJS_)) REFGL3_OBJS = $(patsubst %,build/ref_gl3/%,$(REFGL3_OBJS_))
REFGL3_OBJS += $(patsubst %,build/ref_gl3/%,$(REFGL3_OBJS_GLADE_))
REFGLES3_OBJS = $(patsubst %,build/ref_gles3/%,$(REFGL3_OBJS_))
REFGLES3_OBJS += $(patsubst %,build/ref_gles3/%,$(REFGL3_OBJS_GLADEES_))
REFSOFT_OBJS = $(patsubst %,build/ref_soft/%,$(REFSOFT_OBJS_)) REFSOFT_OBJS = $(patsubst %,build/ref_soft/%,$(REFSOFT_OBJS_))
SERVER_OBJS = $(patsubst %,build/server/%,$(SERVER_OBJS_)) SERVER_OBJS = $(patsubst %,build/server/%,$(SERVER_OBJS_))
GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_)) GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_))
@ -1067,6 +1093,7 @@ CLIENT_DEPS= $(CLIENT_OBJS:.o=.d)
GAME_DEPS= $(GAME_OBJS:.o=.d) GAME_DEPS= $(GAME_OBJS:.o=.d)
REFGL1_DEPS= $(REFGL1_OBJS:.o=.d) REFGL1_DEPS= $(REFGL1_OBJS:.o=.d)
REFGL3_DEPS= $(REFGL3_OBJS:.o=.d) REFGL3_DEPS= $(REFGL3_OBJS:.o=.d)
REFGLES3_DEPS= $(REFGLES3_OBJS:.o=.d)
REFSOFT_DEPS= $(REFSOFT_OBJS:.o=.d) REFSOFT_DEPS= $(REFSOFT_OBJS:.o=.d)
SERVER_DEPS= $(SERVER_OBJS:.o=.d) SERVER_DEPS= $(SERVER_OBJS:.o=.d)
@ -1075,6 +1102,7 @@ SERVER_DEPS= $(SERVER_OBJS:.o=.d)
-include $(GAME_DEPS) -include $(GAME_DEPS)
-include $(REFGL1_DEPS) -include $(REFGL1_DEPS)
-include $(REFGL3_DEPS) -include $(REFGL3_DEPS)
-include $(REFGLES3_DEPS)
-include $(SERVER_DEPS) -include $(SERVER_DEPS)
# ---------- # ----------
@ -1138,6 +1166,22 @@ release/ref_gl3.so : $(REFGL3_OBJS)
${Q}$(CC) $(LDFLAGS) $(REFGL3_OBJS) $(LDLIBS) $(SDLLDFLAGS) -o $@ ${Q}$(CC) $(LDFLAGS) $(REFGL3_OBJS) $(LDLIBS) $(SDLLDFLAGS) -o $@
endif endif
# release/ref_gles3.so
ifeq ($(YQ2_OSTYPE), Windows)
release/ref_gles3.dll : $(REFGLES3_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) $(REFGLES3_OBJS) $(LDLIBS) $(DLL_SDLLDFLAGS) -o $@
$(Q)strip $@
else ifeq ($(YQ2_OSTYPE), Darwin)
release/ref_gles3.dylib : $(REFGLES3_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) $(REFGLES3_OBJS) $(LDLIBS) $(SDLLDFLAGS) -o $@
else
release/ref_gles3.so : $(REFGLES3_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) $(REFGLES3_OBJS) $(LDLIBS) $(SDLLDFLAGS) -o $@
endif
# release/ref_soft.so # release/ref_soft.so
ifeq ($(YQ2_OSTYPE), Windows) ifeq ($(YQ2_OSTYPE), Windows)
release/ref_soft.dll : $(REFSOFT_OBJS) release/ref_soft.dll : $(REFSOFT_OBJS)