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 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
16 [gl_ldd_output0=`(ldd conftest$ac_exeext) 2>/dev/null` ||
18 if test "$gl_ldd_output0"; then
19 gl_saved_ldflags=$LDFLAGS
22 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
23 [gl_ldd_output1=`(ldd conftest$ac_exeext) 2>/dev/null` ||
25 if test "$gl_ldd_output1" && test "$gl_ldd_output0" != "$gl_ldd_output1"
27 for gl_flags in '-Xlinker -zignore' '-zignore'; do
28 LDFLAGS="$gl_flags $LDFLAGS"
29 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
30 [if gl_ldd_output2=`(ldd conftest$ac_exeext) 2>/dev/null` &&
31 test "$gl_ldd_output0" = "$gl_ldd_output2"; then
32 gl_cv_ignore_unused_libraries=$gl_flags
34 LDFLAGS=$gl_saved_ldflags
35 test "gl_cv_ignore_unused_libraries" != none && break
41 test "$gl_cv_ignore_unused_libraries" != none &&
42 LDFLAGS="$LDFLAGS $gl_cv_ignore_unused_libraries"