commit 99629b28d293c2dd755308ebf2f714c48c652f5e
parent f28272a8e0ddcb065acebf4985932d36b4ca9677
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 30 Mar 2025 12:11:47 +0200
Clean up the use of the PIE and PIC compilation options
Static libraries are linked as executables with the pie option. Their
objects must therefore be compiled as PIE and not as PIC.
Diffstat:
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Makefile.atmosphere b/Makefile.atmosphere
@@ -45,7 +45,8 @@ SRC =\
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
-CFLAGS_LIB = $(CFLAGS_SO) $(ATMOSPHERE_INCS) -Isrc -DHTRDR_SHARED_BUILD
+# Use CFLAGS_EXE because the object files will be linked as executables
+CFLAGS_LIB = $(CFLAGS_EXE) $(ATMOSPHERE_INCS) -DHTRDR_SHARED_BUILD
library: core .config_atmosphere htrdr-atmosphere.pc $(DEP)
@$(MAKE) -fMakefile.atmosphere \
diff --git a/Makefile.combustion b/Makefile.combustion
@@ -45,7 +45,8 @@ SRC =\
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
-CFLAGS_LIB = $(CFLAGS_SO) $(COMBUSTION_INCS) -Isrc -DHTRDR_SHARED_BUILD
+# Use CFLAGS_EXE because the object files will be linked as executables
+CFLAGS_LIB = $(CFLAGS_EXE) $(COMBUSTION_INCS) -DHTRDR_SHARED_BUILD
library: core .config_combustion htrdr-combustion.pc $(DEP)
@$(MAKE) -fMakefile.combustion \
diff --git a/Makefile.core b/Makefile.core
@@ -54,7 +54,12 @@ SRC =\
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
-CFLAGS_CORE = $(CFLAGS_SO) -Isrc -DHTRDR_SHARED_BUILD $(CORE_INCS)
+# Use CFLAGS_EXE when the library is built as a static library because
+# the object files will be linked as executables.
+CFLAGS_STATIC = $(CFLAGS_EXE)
+CFLAGS_SHARED = $(CFLAGS_SO)
+
+CFLAGS_CORE = $(CFLAGS_$(LIB_TYPE)) -Isrc -DHTRDR_SHARED_BUILD $(CORE_INCS)
LDFLAGS_CORE = $(LDFLAGS_SO) $(CORE_LIBS)
core: .config_core htrdr-core.pc $(DEP)
diff --git a/Makefile.planets b/Makefile.planets
@@ -44,7 +44,8 @@ SRC =\
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
-CFLAGS_LIB = $(CFLAGS_SO) $(PLANETS_INCS) -Isrc -DHTRDR_SHARED_BUILD
+# Use CFLAGS_EXE because the object files will be linked as executables
+CFLAGS_LIB = $(CFLAGS_EXE) $(PLANETS_INCS) -DHTRDR_SHARED_BUILD
library: core .config_planets htrdr-planets.pc $(DEP)
@$(MAKE) -fMakefile.planets \