ld-version-script.m4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. dnl From Simon Josefsson
  7. # FIXME: The test below returns a false positive for mingw
  8. # cross-compiles, 'local:' statements does not reduce number of
  9. # exported symbols in a DLL. Use --disable-ld-version-script to work
  10. # around the problem.
  11. # gl_LD_VERSION_SCRIPT
  12. # --------------------
  13. # Check if LD supports linker scripts, and define automake conditional
  14. # HAVE_LD_VERSION_SCRIPT if so.
  15. AC_DEFUN([gl_LD_VERSION_SCRIPT],
  16. [
  17. AC_ARG_ENABLE([ld-version-script],
  18. AS_HELP_STRING([--enable-ld-version-script],
  19. [enable linker version script (default is enabled when possible)]),
  20. [have_ld_version_script=$enableval], [])
  21. if test -z "$have_ld_version_script"; then
  22. AC_MSG_CHECKING([if LD -Wl,--version-script works])
  23. save_LDFLAGS="$LDFLAGS"
  24. LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
  25. cat > conftest.map <<EOF
  26. foo
  27. EOF
  28. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  29. [accepts_syntax_errors=yes], [accepts_syntax_errors=no])
  30. if test "$accepts_syntax_errors" = no; then
  31. cat > conftest.map <<EOF
  32. VERS_1 {
  33. global: sym;
  34. };
  35. VERS_2 {
  36. global: sym;
  37. } VERS_1;
  38. EOF
  39. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  40. [have_ld_version_script=yes], [have_ld_version_script=no])
  41. else
  42. have_ld_version_script=no
  43. fi
  44. rm -f conftest.map
  45. LDFLAGS="$save_LDFLAGS"
  46. AC_MSG_RESULT($have_ld_version_script)
  47. fi
  48. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  49. ])