From b18104bdaa75d6b9908bbcc3444e7733c8082875 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 26 Dec 2023 17:45:26 +1000 Subject: [PATCH] Makefile: support explicit static linking of all configurable libraries Fixes a bug in df973c344562c8cadc2413d36dcaa03f8e9040c2 where libd0_rijndael static linking only worked if DP_LINK_CRYPTO_RIJNDAEL=static was read from the environment rather than being passed as an override. Signed-off-by: bones_was_here --- makefile | 57 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/makefile b/makefile index eb978a86..a3cdd69d 100644 --- a/makefile +++ b/makefile @@ -255,20 +255,25 @@ ifeq ($(DP_MAKE_TARGET), mingw) DP_LINK_XMP?=dlopen endif -# set these to "" if you want to use dynamic loading instead -# zlib + +##### Library linking ##### +# SDL2 ifeq ($(DP_LINK_SDL), shared) SDL_LIBS=$(SDLCONFIG_LIBS) -endif -ifeq ($(DP_LINK_SDL), static) +else ifeq ($(DP_LINK_SDL), static) SDL_LIBS=$(SDLCONFIG_STATICLIBS) +else ifeq ($(DP_LINK_SDL), dlopen) + $(error libSDL2 can only be used with shared or static linking) endif +# zlib ifeq ($(DP_LINK_ZLIB), shared) CFLAGS_LIBZ=-DLINK_TO_ZLIB LIB_Z=-lz -endif -ifeq ($(DP_LINK_ZLIB), dlopen) +else ifeq ($(DP_LINK_ZLIB), static) + CFLAGS_LIBZ=-DLINK_TO_ZLIB + LIB_Z=-l:libz.a +else ifeq ($(DP_LINK_ZLIB), dlopen) CFLAGS_LIBZ= LIB_Z= endif @@ -277,8 +282,10 @@ endif ifeq ($(DP_LINK_JPEG), shared) CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG LIB_JPEG=-ljpeg -endif -ifeq ($(DP_LINK_JPEG), dlopen) +else ifeq ($(DP_LINK_JPEG), static) + CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG + LIB_JPEG=-l:libjpeg.a +else ifeq ($(DP_LINK_JPEG), dlopen) CFLAGS_LIBJPEG= LIB_JPEG= endif @@ -288,29 +295,38 @@ ifeq ($(DP_LINK_ODE), shared) ODE_CONFIG?=ode-config LIB_ODE=`$(ODE_CONFIG) --libs` CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE -endif -ifeq ($(DP_LINK_ODE), dlopen) +else ifeq ($(DP_LINK_ODE), static) + # This is the configuration from Xonotic + ODE_CONFIG?=ode-config + LIB_ODE=-l:libode.a -lstdc++ -pthread + CFLAGS_ODE=-DUSEODE -DLINK_TO_LIBODE -DdDOUBLE +else ifeq ($(DP_LINK_ODE), dlopen) LIB_ODE= CFLAGS_ODE=-DUSEODE endif # d0_blind_id -ifeq ($(DP_LINK_CRYPTO), static) - LIB_CRYPTO=-ld0_blind_id -lgmp - CFLAGS_CRYPTO=-DLINK_TO_CRYPTO -else ifeq ($(DP_LINK_CRYPTO), shared) +ifeq ($(DP_LINK_CRYPTO), shared) LIB_CRYPTO=-ld0_blind_id CFLAGS_CRYPTO=-DLINK_TO_CRYPTO +else ifeq ($(DP_LINK_CRYPTO), static) + LIB_CRYPTO=-l:libd0_blind_id.a -lgmp + CFLAGS_CRYPTO=-DLINK_TO_CRYPTO +else ifeq ($(DP_LINK_CRYPTO), static_inc_gmp) + LIB_CRYPTO=-l:libd0_blind_id.a -l:libgmp.a + CFLAGS_CRYPTO=-DLINK_TO_CRYPTO else ifeq ($(DP_LINK_CRYPTO), dlopen) LIB_CRYPTO= CFLAGS_CRYPTO= endif -ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), static) - DP_LINK_CRYPTO_RIJNDAEL=shared -endif + +# d0_rijndael ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared) LIB_CRYPTO_RIJNDAEL=-ld0_rijndael CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL +else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), static) + LIB_CRYPTO_RIJNDAEL=-l:libd0_rijndael.a + CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen) LIB_CRYPTO_RIJNDAEL= CFLAGS_CRYPTO_RIJNDAEL= @@ -321,8 +337,11 @@ ifeq ($(DP_LINK_XMP), shared) OBJ_SND_XMP=snd_xmp.o LIB_SND_XMP=-lxmp CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP -endif -ifeq ($(DP_LINK_XMP), dlopen) +else ifeq ($(DP_LINK_XMP), static) + OBJ_SND_XMP=snd_xmp.o + LIB_SND_XMP=-l:libxmp.a + CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP +else ifeq ($(DP_LINK_XMP), dlopen) OBJ_SND_XMP=snd_xmp.o LIB_SND_XMP= CFLAGS_SND_XMP=-DUSEXMP -- 2.39.2