1 # If possible, ignore libraries that are not depended on.
3 dnl Copyright (C) 2006 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.
8 dnl Written by Paul Eggert.
10 AC_DEFUN([gl_IGNORE_UNUSED_LIBRARIES],
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
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>.
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.
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
41 test "$gl_cv_ignore_unused_libraries" != none &&
42 LDFLAGS="$LDFLAGS $gl_cv_ignore_unused_libraries"