]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
build: Generate the map file from the configured ABI
authorGuillem Jover <guillem@hadrons.org>
Sun, 11 Feb 2024 18:35:05 +0000 (19:35 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sun, 18 Feb 2024 12:54:13 +0000 (13:54 +0100)
Some linkers require the map file definitions to contain only symbols
that are present on the linked object, either in the map file or in the
sym file we generate from the map file.

This is preparatory work to be able to conditionally include symbols
in the man and sym files depending on the ABI definitions.

.gitignore
src/Makefile.am
src/libbsd.map.in [moved from src/libbsd.map with 99% similarity]

index 5c3a5ed22878114a3f52a5ce21ad9a016e409694..a6f640352a54b478461993059278da89ddd488e5 100644 (file)
@@ -11,6 +11,7 @@ ChangeLog
 *.gcda
 *.gcno
 *.sym
+*.map
 .dirstamp
 .deps/
 .libs/
index 6f2325c2b20b50478037b878715d518cb9520bab..1c350b82aff145be85d685d50a557938cb0aa335 100644 (file)
@@ -28,7 +28,7 @@ libbsd_la_included_sources = \
 
 CLEANFILES =
 EXTRA_DIST = \
-       libbsd.map \
+       libbsd.map.in \
        libbsd.pc.in \
        libbsd-ctor.pc.in \
        libbsd-overlay.pc.in \
@@ -53,6 +53,7 @@ endif
 EXTRA_libbsd_la_DEPENDENCIES = \
        $(libbsd_la_included_sources) \
        libbsd.map \
+       libbsd.map.in \
        # EOL
 libbsd_la_LIBADD = \
        $(MD5_LIBS) \
@@ -64,7 +65,7 @@ libbsd_la_LDFLAGS = \
        # EOL
 if HAVE_LINKER_VERSION_SCRIPT
 libbsd_la_LDFLAGS += \
-       -Wl,--version-script=$(srcdir)/libbsd.map \
+       -Wl,--version-script=libbsd.map \
        # EOL
 else
 libbsd_la_LDFLAGS += \
@@ -194,12 +195,18 @@ endif
 
 DISTCLEANFILES = \
        libbsd.sym \
+       libbsd.map \
        # EOL
 
 libbsd_ctor_a_SOURCES = \
        setproctitle_ctor.c \
        # EOL
 
+# Generate the library map file with the pre-processor to selectively include
+# symbols depending on the host system, otherwise some linkers might fail.
+libbsd.map: libbsd.map.in
+       $(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -P - <$(srcdir)/libbsd.map.in >$@
+
 # Generate a simple libtool symbol export list to be used as a fallback if
 # there is no version script support.
 libbsd.sym: libbsd.map
similarity index 99%
rename from src/libbsd.map
rename to src/libbsd.map.in
index 6c6123538a370c6d56535b2b5082f66c25ccb94a..06550ea7f8ee1e1efe6ccba3f637bc416ee5229d 100644 (file)
@@ -1,3 +1,5 @@
+#include "config.h"
+
 LIBBSD_0.0 {
   global:
     arc4random;