htmie

Optical properties of water droplets
git clone git://git.meso-star.fr/htmie.git
Log | Files | Refs | README | LICENSE

commit fad8c2ea2741edb3762d03c2b3c4eae7f47c7d13
parent 2f4e026a546e00ea1c4243314407b0f21ad6879c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 30 Oct 2023 15:50:54 +0100

Partially link static library object files

Make hidden symbols local to the relocatable object to avoid conflicts
with internal symbols in another static library. In release mode, delete
all symbols not required for relocation processing, but keep them in
debug mode for... debugging purposes.

Diffstat:
MMakefile | 9+++++++--
Mconfig.mk | 6++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -44,10 +44,14 @@ $(DEP) $(OBJ): config.mk $(LIBNAME_SHARED): $(OBJ) $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) -$(LIBNAME_STATIC): $(OBJ) +$(LIBNAME_STATIC): libhtmie.o $(AR) -rc $@ $? $(RANLIB) $@ +libhtmie.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + .config: config.mk @if ! $(PKG_CONFIG) --atleast-version $(NETCDF_VERSION) netcdf; then \ echo "netcdf $(NETCDF_VERSION) not found" >&2; exit 1; fi @@ -102,7 +106,8 @@ uninstall: all: build_library build_tests clean: clean_test - rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) .config .test htmie.pc htmie-local.pc + rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) + rm -f .config .test libhtmie.o htmie.pc htmie-local.pc distclean: clean rm -f $(DEP) $(TEST_DEP) diff --git a/config.mk b/config.mk @@ -12,6 +12,8 @@ BUILD_TYPE = RELEASE ################################################################################ AR = ar CC = cc +LD = ld +OBJCOPY = objcopy PKG_CONFIG = pkg-config RANLIB = ranlib @@ -73,3 +75,7 @@ LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) LDFLAGS_SO = $(LDFLAGS_$(BUILD_TYPE)) -shared -Wl,--no-undefined LDFLAGS_EXE = $(LDFLAGS_$(BUILD_TYPE)) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE))