Add new module ld-version-script. Fix doc for visibility.
[gnulib.git] / m4 / ld-version-script.m4
1 # ld-version-script.m4 serial 1
2 dnl Copyright (C) 2008, 2009 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 # gl_LD_VERSION_SCRIPT
10 # --------------------
11 # Check if LD supports linker scripts, and define automake conditional
12 # HAVE_LD_VERSION_SCRIPT if so.
13 AC_DEFUN([gl_LD_VERSION_SCRIPT],
14 [
15   AC_ARG_ENABLE([ld-version-script],
16     AS_HELP_STRING([--enable-ld-version-script],
17       [enable linker version script (default is enabled when possible)]),
18       [have_ld_version_script=$enableval], [])
19   if test -z "$have_ld_version_script"; then
20     AC_MSG_CHECKING([if LD -Wl,--version-script works])
21     save_LDFLAGS="$LDFLAGS"
22     LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
23     cat > conftest.map <<EOF
24 VERS_1 {
25         global: sym;
26 };
27
28 VERS_2 {
29         global: sym;
30 } VERS_1;
31 EOF
32     AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
33                    [have_ld_version_script=yes], [have_ld_version_script=no])
34     rm -f conftest.map
35     LDFLAGS="$save_LDFLAGS"
36     AC_MSG_RESULT($have_ld_version_script)
37   fi
38   AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
39 ])