cristy | 9b86f20 | 2012-11-28 21:55:35 +0000 | [diff] [blame] | 1 | # ld-version-script.m4 serial 3 |
| 2 | dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | |
| 7 | dnl From Simon Josefsson |
| 8 | |
| 9 | # FIXME: The test below returns a false positive for mingw |
| 10 | # cross-compiles, 'local:' statements does not reduce number of |
| 11 | # exported symbols in a DLL. Use --disable-ld-version-script to work |
| 12 | # around the problem. |
| 13 | |
| 14 | # gl_LD_VERSION_SCRIPT |
| 15 | # -------------------- |
| 16 | # Check if LD supports linker scripts, and define automake conditional |
| 17 | # HAVE_LD_VERSION_SCRIPT if so. |
| 18 | AC_DEFUN([gl_LD_VERSION_SCRIPT], |
| 19 | [ |
| 20 | AC_ARG_ENABLE([ld-version-script], |
| 21 | AS_HELP_STRING([--enable-ld-version-script], |
| 22 | [enable linker version script (default is enabled when possible)]), |
| 23 | [have_ld_version_script=$enableval], []) |
| 24 | if test -z "$have_ld_version_script"; then |
| 25 | AC_MSG_CHECKING([if LD -Wl,--version-script works]) |
| 26 | save_LDFLAGS="$LDFLAGS" |
| 27 | LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" |
| 28 | cat > conftest.map <<EOF |
| 29 | foo |
| 30 | EOF |
| 31 | AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], |
| 32 | [accepts_syntax_errors=yes], [accepts_syntax_errors=no]) |
| 33 | if test "$accepts_syntax_errors" = no; then |
| 34 | cat > conftest.map <<EOF |
| 35 | VERS_1 { |
| 36 | global: sym; |
| 37 | }; |
| 38 | |
| 39 | VERS_2 { |
| 40 | global: sym; |
| 41 | } VERS_1; |
| 42 | EOF |
| 43 | AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], |
| 44 | [have_ld_version_script=yes], [have_ld_version_script=no]) |
| 45 | else |
| 46 | have_ld_version_script=no |
| 47 | fi |
| 48 | rm -f conftest.map |
| 49 | LDFLAGS="$save_LDFLAGS" |
| 50 | AC_MSG_RESULT($have_ld_version_script) |
| 51 | fi |
| 52 | AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") |
| 53 | ]) |