[PATCH 7/9] introduce gnulib, using lib-symbol-versions module

Michael Haubenwallner michael.haubenwallner at ssi-schaefer.com
Mon Apr 10 11:10:44 UTC 2017


The -Wl,--version-script linker flag is not portable, but gnulib already
provides an autoconf check for whether that flag works.  As the portable
alternative we use the -export-symbols-regex libtool flag.
---
 .gitignore         |  3 ++-
 Makefile.am        |  4 +++-
 autogen            |  1 +
 configure.ac       |  8 +++++---
 m4/.gitignore      |  7 +++++++
 m4/gnulib-cache.m4 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am    |  9 ++++++++-
 7 files changed, 74 insertions(+), 6 deletions(-)
 create mode 100644 m4/.gitignore
 create mode 100644 m4/gnulib-cache.m4

diff --git a/.gitignore b/.gitignore
index 3dd8333..9633e44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 ChangeLog
+*~
 *.a
 *.o
 *.la
@@ -20,5 +21,5 @@ Makefile.in
 /config.*
 /configure
 /libtool
-/m4/
+/lib/
 /stamp-h1
diff --git a/Makefile.am b/Makefile.am
index b839ae1..d1f385f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,12 +1,14 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = include man src test
+SUBDIRS = lib include man src test
 
 ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = \
 	autogen \
 	get-version \
+	m4/gnulib-cache.m4 \
+	m4/gnulib-tool.m4 \
 	$(nil)
 
 dist-hook:
diff --git a/autogen b/autogen
index 7cf1815..294fbfa 100755
--- a/autogen
+++ b/autogen
@@ -1,5 +1,6 @@
 #!/bin/sh
 
 mkdir -p m4
+gnulib-tool --update
 autoreconf -f -i
 rm -rf autom4te.cache
diff --git a/configure.ac b/configure.ac
index 6cc811e..f238c4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,11 +22,11 @@ AC_SUBST([LIBMD_ABI])
 AC_USE_SYSTEM_EXTENSIONS
 AC_SYS_LARGEFILE
 
-AM_PROG_AR
-LT_INIT
-
 # Checks for programs.
 AC_PROG_CC
+gl_EARLY
+AM_PROG_AR
+LT_INIT
 
 # Checks for libraries.
 
@@ -39,9 +39,11 @@ AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
 
 # Checks for library functions.
+gl_INIT
 
 AC_CONFIG_FILES([
 	Makefile
+	lib/Makefile
 	include/Makefile
 	man/Makefile
 	src/Makefile
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..b152427
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,7 @@
+/00gnulib.m4
+/gnulib-common.m4
+/gnulib-comp.m4
+/gnulib-tool.m4
+/ld-version-script.m4
+/libtool.m4
+/lt*.m4
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
new file mode 100644
index 0000000..0a867f4
--- /dev/null
+++ b/m4/gnulib-cache.m4
@@ -0,0 +1,48 @@
+# Copyright (C) 2002-2017 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+#
+# This file represents the specification of how gnulib-tool is used.
+# It acts as a cache: It is written and read by gnulib-tool.
+# In projects that use version control, this file is meant to be put under
+# version control, like the configure.ac and various Makefile.am files.
+
+
+# Specification in the form of a command-line invocation:
+#   gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl lib-symbol-versions
+
+# Specification in the form of a few gnulib-tool.m4 macro invocations:
+gl_LOCAL_DIR([])
+gl_MODULES([
+  lib-symbol-versions
+])
+gl_AVOID([])
+gl_SOURCE_BASE([lib])
+gl_M4_BASE([m4])
+gl_PO_BASE([])
+gl_DOC_BASE([doc])
+gl_TESTS_BASE([tests])
+gl_LIB([libgnu])
+gl_MAKEFILE_NAME([])
+gl_LIBTOOL
+gl_MACRO_PREFIX([gl])
+gl_PO_DOMAIN([])
+gl_WITNESS_C_MACRO([])
diff --git a/src/Makefile.am b/src/Makefile.am
index 041b6d8..4ec53ba 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,9 +23,16 @@ libmd_la_helper_sources = \
 	sha512hl.c \
 	$(nil)
 
+libmd_la_LIBADD = ../lib/libgnu.la
+
 libmd_la_LDFLAGS = \
-	-Wl,--version-script=$(srcdir)/libmd.map \
 	-no-undefined -version-number $(LIBMD_ABI)
+if HAVE_LD_VERSION_SCRIPT
+libmd_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libmd.map
+else
+libmd_la_LDFLAGS += -export-symbols-regex '^(MD[245]|RMD160|SHA(1|256|384|512))(Data|End|Fil(e|eChunk)|Final|Init|Pad|Transform|Update)'
+endif
+
 libmd_la_DEPENDENCIES = \
 	libmd.map \
 	helper.c \
-- 
2.10.2



More information about the libbsd mailing list