diff options
author | David R. Bild <david.bild@xaptum.com> | 2017-11-28 18:09:42 -0600 |
---|---|---|
committer | Tadeusz Struk <tadeusz.struk@intel.com> | 2017-12-01 10:53:56 -0800 |
commit | 1e49b4cef08605dbea33d5fbf0e1cd419a4e5ab4 (patch) | |
tree | fdf9d4b8447439d4f89a13859e2d9a468d7f1c86 /m4 | |
parent | f6876526a34346d764033ac397fdb60ada02f97c (diff) | |
download | tpm2-tss-1e49b4cef08605dbea33d5fbf0e1cd419a4e5ab4.tar.gz |
build: detect ld version-script flag support
Some linkers do not support the --version-script flag. Only include
it if the linker supports it.
Signed-off-by: David R. Bild <david.bild@xaptum.com>
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ld-version-script.m4 | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/m4/ld-version-script.m4 b/m4/ld-version-script.m4 new file mode 100644 index 00000000..f8b4a5c5 --- /dev/null +++ b/m4/ld-version-script.m4 @@ -0,0 +1,53 @@ +# ld-version-script.m4 serial 3 +dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# FIXME: The test below returns a false positive for mingw +# cross-compiles, 'local:' statements does not reduce number of +# exported symbols in a DLL. Use --disable-ld-version-script to work +# around the problem. + +# gl_LD_VERSION_SCRIPT +# -------------------- +# Check if LD supports linker scripts, and define automake conditional +# HAVE_LD_VERSION_SCRIPT if so. +AC_DEFUN([gl_LD_VERSION_SCRIPT], +[ + AC_ARG_ENABLE([ld-version-script], + AS_HELP_STRING([--enable-ld-version-script], + [enable linker version script (default is enabled when possible)]), + [have_ld_version_script=$enableval], []) + if test -z "$have_ld_version_script"; then + AC_MSG_CHECKING([if LD -Wl,--version-script works]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map <<EOF +foo +EOF + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], + [accepts_syntax_errors=yes], [accepts_syntax_errors=no]) + if test "$accepts_syntax_errors" = no; then + cat > conftest.map <<EOF +VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +EOF + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], + [have_ld_version_script=yes], [have_ld_version_script=no]) + else + have_ld_version_script=no + fi + rm -f conftest.map + LDFLAGS="$save_LDFLAGS" + AC_MSG_RESULT($have_ld_version_script) + fi + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") +]) |