update nearly all FSF copyright year lists to include 2010
[gnulib.git] / m4 / lib-ignore.m4
1 # If possible, ignore libraries that are not depended on.
2
3 dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl Written by Paul Eggert.
9
10 AC_DEFUN([gl_IGNORE_UNUSED_LIBRARIES],
11 [
12   AC_CACHE_CHECK([for flag to ignore unused libraries],
13     [gl_cv_ignore_unused_libraries],
14     [gl_cv_ignore_unused_libraries=none
15      gl_saved_ldflags=$LDFLAGS
16      gl_saved_libs=$LIBS
17      # Link with -lm to detect binutils 2.16 bug with --as-needed; see
18      # <http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00131.html>.
19      LIBS="$LIBS -lm"
20      # Use long option sequences like '-z ignore' to test for the feature,
21      # to forestall problems with linkers that have -z, -i, -g, -n, etc. flags.
22      # GCC + binutils likes '-Wl,--as-needed'.
23      # GCC + Solaris ld likes '-Wl,-z,ignore'.
24      # Sun C likes '-z ignore'.
25      # Don't try bare '--as-needed'; nothing likes it and the HP-UX 11.11
26      # native cc issues annoying warnings and then ignores it,
27      # which would cause us to incorrectly conclude that it worked.
28      for gl_flags in \
29         '-Wl,--as-needed' \
30         '-Wl,-z,ignore' \
31         '-z ignore'
32      do
33        LDFLAGS="$gl_flags $LDFLAGS"
34        AC_LINK_IFELSE([AC_LANG_PROGRAM()],
35          [gl_cv_ignore_unused_libraries=$gl_flags])
36        LDFLAGS=$gl_saved_ldflags
37        test "$gl_cv_ignore_unused_libraries" != none && break
38      done
39      LIBS=$gl_saved_libs])
40
41   test "$gl_cv_ignore_unused_libraries" != none &&
42     LDFLAGS="$LDFLAGS $gl_cv_ignore_unused_libraries"
43 ])