|
Packit |
eba2e2 |
# If possible, ignore libraries that are not depended on.
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
dnl Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc.
|
|
Packit |
eba2e2 |
dnl This file is free software; the Free Software Foundation
|
|
Packit |
eba2e2 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit |
eba2e2 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
dnl Written by Paul Eggert.
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# gl_IGNORE_UNUSED_LIBRARIES
|
|
Packit |
eba2e2 |
# --------------------------
|
|
Packit |
eba2e2 |
# Determines the option to be passed to the C/C++/Fortran compiler, so that it
|
|
Packit |
eba2e2 |
# omits unused libraries.
|
|
Packit |
eba2e2 |
# Example (on Solaris):
|
|
Packit |
eba2e2 |
# $ cc foo.c -lnsl; ldd ./a.out
|
|
Packit |
eba2e2 |
# libnsl.so.1 => /lib/libnsl.so.1
|
|
Packit |
eba2e2 |
# libc.so.1 => /lib/libc.so.1
|
|
Packit |
eba2e2 |
# libmp.so.2 => /lib/libmp.so.2
|
|
Packit |
eba2e2 |
# libmd.so.1 => /lib/libmd.so.1
|
|
Packit |
eba2e2 |
# libscf.so.1 => /lib/libscf.so.1
|
|
Packit |
eba2e2 |
# libdoor.so.1 => /lib/libdoor.so.1
|
|
Packit |
eba2e2 |
# libuutil.so.1 => /lib/libuutil.so.1
|
|
Packit |
eba2e2 |
# libgen.so.1 => /lib/libgen.so.1
|
|
Packit |
eba2e2 |
# libm.so.2 => /lib/libm.so.2
|
|
Packit |
eba2e2 |
# $ cc foo.c -lnsl -Wl,-z,ignore; ldd ./a.out
|
|
Packit |
eba2e2 |
# libc.so.1 => /lib/libc.so.1
|
|
Packit |
eba2e2 |
# libm.so.2 => /lib/libm.so.2
|
|
Packit |
eba2e2 |
#
|
|
Packit |
eba2e2 |
# Note that the option works only for the C compiler, not for the C++
|
|
Packit |
eba2e2 |
# compiler:
|
|
Packit |
eba2e2 |
# - Sun C likes '-Wl,-z,ignore'.
|
|
Packit |
eba2e2 |
# '-Qoption ld -z,ignore' is not accepted.
|
|
Packit |
eba2e2 |
# '-z ignore' is accepted but has no effect.
|
|
Packit |
eba2e2 |
# - Sun C++ and Sun Fortran like '-Qoption ld -z,ignore'.
|
|
Packit |
eba2e2 |
# '-Wl,-z,ignore' is not accepted.
|
|
Packit |
eba2e2 |
# '-z ignore' is accepted but has no effect.
|
|
Packit |
eba2e2 |
#
|
|
Packit |
eba2e2 |
# Sets and substitutes a variable that depends on the current language:
|
|
Packit |
eba2e2 |
# - IGNORE_UNUSED_LIBRARIES_CFLAGS for C
|
|
Packit |
eba2e2 |
# - IGNORE_UNUSED_LIBRARIES_CXXFLAGS for C++
|
|
Packit |
eba2e2 |
# - IGNORE_UNUSED_LIBRARIES_FFLAGS for Fortran
|
|
Packit |
eba2e2 |
#
|
|
Packit |
eba2e2 |
# Note that the option works only for direct invocation of the compiler, not
|
|
Packit |
eba2e2 |
# through libtool: When libtool is used to create a shared library, it will
|
|
Packit |
eba2e2 |
# honor and translate '-Wl,-z,ignore' to '-Qoption ld -z -Qoption ld ignore'
|
|
Packit |
eba2e2 |
# if needed, but it will drop a '-Qoption ld -z,ignore' on the command line.
|
|
Packit |
eba2e2 |
#
|
|
Packit |
eba2e2 |
AC_DEFUN([gl_IGNORE_UNUSED_LIBRARIES],
|
|
Packit |
eba2e2 |
[
|
|
Packit |
eba2e2 |
AC_CACHE_CHECK([for []_AC_LANG[] compiler flag to ignore unused libraries],
|
|
Packit |
eba2e2 |
[gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries],
|
|
Packit |
eba2e2 |
[gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries=none
|
|
Packit |
eba2e2 |
gl_saved_ldflags=$LDFLAGS
|
|
Packit |
eba2e2 |
gl_saved_libs=$LIBS
|
|
Packit |
eba2e2 |
# Link with -lm to detect binutils 2.16 bug with --as-needed; see
|
|
Packit |
eba2e2 |
# <http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00131.html>.
|
|
Packit |
eba2e2 |
LIBS="$LIBS -lm"
|
|
Packit |
eba2e2 |
# Use long option sequences like '-z ignore' to test for the feature,
|
|
Packit |
eba2e2 |
# to forestall problems with linkers that have -z, -i, -g, -n, etc. flags.
|
|
Packit |
eba2e2 |
# GCC + binutils likes '-Wl,--as-needed'.
|
|
Packit |
eba2e2 |
# GCC + Solaris ld likes '-Wl,-z,ignore'.
|
|
Packit |
eba2e2 |
# Sun C likes '-Wl,-z,ignore'. '-z ignore' is accepted but has no effect.
|
|
Packit |
eba2e2 |
# Don't try bare '--as-needed'; nothing likes it and the HP-UX 11.11
|
|
Packit |
eba2e2 |
# native cc issues annoying warnings and then ignores it,
|
|
Packit |
eba2e2 |
# which would cause us to incorrectly conclude that it worked.
|
|
Packit |
eba2e2 |
for gl_flags in _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS
|
|
Packit |
eba2e2 |
do
|
|
Packit |
eba2e2 |
LDFLAGS="$gl_flags $LDFLAGS"
|
|
Packit |
eba2e2 |
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
|
|
Packit |
eba2e2 |
[gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries=$gl_flags])
|
|
Packit |
eba2e2 |
LDFLAGS=$gl_saved_ldflags
|
|
Packit |
eba2e2 |
test "$gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries" != none &&
|
|
Packit |
eba2e2 |
break
|
|
Packit |
eba2e2 |
done
|
|
Packit |
eba2e2 |
LIBS=$gl_saved_libs
|
|
Packit |
eba2e2 |
])
|
|
Packit |
eba2e2 |
IGNORE_UNUSED_LIBRARIES_[]_AC_LANG_PREFIX[]FLAGS=
|
|
Packit |
eba2e2 |
if test "$gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries" != none; then
|
|
Packit |
eba2e2 |
IGNORE_UNUSED_LIBRARIES_[]_AC_LANG_PREFIX[]FLAGS="$gl_cv_prog_[]_AC_LANG_ABBREV[]_ignore_unused_libraries"
|
|
Packit |
eba2e2 |
fi
|
|
Packit |
eba2e2 |
AC_SUBST([IGNORE_UNUSED_LIBRARIES_]_AC_LANG_PREFIX[FLAGS])
|
|
Packit |
eba2e2 |
])
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS
|
|
Packit |
eba2e2 |
# -----------------------------------
|
|
Packit |
eba2e2 |
# Expands to the language dependent options to be tried.
|
|
Packit |
eba2e2 |
AC_DEFUN([_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS],
|
|
Packit |
eba2e2 |
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(C)
|
|
Packit |
eba2e2 |
# --------------------------------------
|
|
Packit |
eba2e2 |
m4_define([_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(C)],
|
|
Packit |
eba2e2 |
[ '-Wl,--as-needed' \
|
|
Packit |
eba2e2 |
'-Wl,-z,ignore' \
|
|
Packit |
eba2e2 |
'-z ignore'
|
|
Packit |
eba2e2 |
])
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(C++)
|
|
Packit |
eba2e2 |
# ----------------------------------------
|
|
Packit |
eba2e2 |
m4_define([_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(C++)],
|
|
Packit |
eba2e2 |
[ '-Wl,--as-needed' \
|
|
Packit |
eba2e2 |
'-Qoption ld -z,ignore' \
|
|
Packit |
eba2e2 |
'-Wl,-z,ignore' \
|
|
Packit |
eba2e2 |
'-z ignore'
|
|
Packit |
eba2e2 |
])
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(Fortran 77)
|
|
Packit |
eba2e2 |
# -----------------------------------------------
|
|
Packit |
eba2e2 |
m4_copy([_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(C++)],
|
|
Packit |
eba2e2 |
[_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(Fortran 77)])
|
|
Packit |
eba2e2 |
|
|
Packit |
eba2e2 |
# _gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(Fortran)
|
|
Packit |
eba2e2 |
# --------------------------------------------
|
|
Packit |
eba2e2 |
m4_copy([_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(Fortran 77)],
|
|
Packit |
eba2e2 |
[_gl_IGNORE_UNUSED_LIBRARIES_OPTIONS(Fortran)])
|