build: Detect support for --version-script in ld

This commit is contained in:
Guillem Jover 2019-11-16 00:04:18 +01:00
parent eb445425ff
commit 3d6b6ead64
2 changed files with 23 additions and 1 deletions

View File

@ -27,6 +27,25 @@ AC_SYS_LARGEFILE
LT_INIT
AC_CACHE_CHECK([if ld supports --version-script flag],
[libbsd_cv_version_script], [
echo "{ global: symbol; local: *; };" >conftest.map
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([], [])
], [
libbsd_cv_version_script=yes
], [
libbsd_cv_version_script=no
])
LDFLAGS="$save_LDFLAGS"
rm -f conftest.map
]
)
AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
[test "x$libbsd_cv_version_script" = "xyes"])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

View File

@ -65,8 +65,11 @@ libbsd_la_LIBADD = \
$(ARC4RANDOM_ATFORK_LIBS) \
$(nil)
libbsd_la_LDFLAGS = \
-Wl,--version-script=$(srcdir)/libbsd.map \
-version-number $(LIBBSD_ABI)
if HAVE_LINKER_VERSION_SCRIPT
libbsd_la_LDFLAGS += \
-Wl,--version-script=$(srcdir)/libbsd.map
endif
libbsd_la_SOURCES = \
arc4random.c \
arc4random.h \