Commit 4c94d7fd8ccc96036ef847ddac96d24ffee12235

Guillem Jover 2017-05-31T06:55:35

build: Use an export symbols file if there is no version script support We generate the symbol list from the version script to avoid repeating ourselves and potentially getting the lists out-of-sync. Proposed-by: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>

diff --git a/.gitignore b/.gitignore
index affc47b..f3f1b27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 ChangeLog
+*.sym
 *.a
 *.o
 *.la
diff --git a/src/Makefile.am b/src/Makefile.am
index 62cba25..505843e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,9 +29,13 @@ libmd_la_LDFLAGS = \
 if HAVE_LINKER_VERSION_SCRIPT
 libmd_la_LDFLAGS += \
 	-Wl,--version-script=$(srcdir)/libmd.map
+else
+libmd_la_LDFLAGS += \
+	-export-symbols $(srcdir)/libmd.sym
 endif
 libmd_la_DEPENDENCIES = \
 	libmd.map \
+	libmd.sym \
 	helper.c \
 	$(nil)
 libmd_la_SOURCES = \
@@ -58,6 +62,15 @@ CLEANFILES = \
 	$(libmd_la_helper_sources) \
 	$(nil)
 
+DISTCLEANFILES = \
+	libmd.sym \
+	$(nil)
+
+# Generate a simple libtool symbol export list to be used as a fallback if
+# there is no version script support.
+libmd.sym: libmd.map
+	$(AM_V_GEN) sed -ne 's/^[[:space:]]\+\([A-Za-z0-9]\+\);/\1/p' $< > $@
+
 md2hl.c: helper.c
 	$(AM_V_GEN) sed -e 's/hashinc/md2.h/g' -e 's/HASH/MD2/g' $< > $@