2 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
3 # Copyright © 2010, 2014, 2016 Guillem Jover <guillem@debian.org>
5 # DPKG_LINKER_OPTIMIZATIONS
6 # -------------------------
7 # Add configure option to disable linker optimizations.
8 AC_DEFUN([DPKG_LINKER_OPTIMIZATIONS], [
9 AC_ARG_ENABLE([linker-optimizations],
10 [AS_HELP_STRING([--disable-linker-optimizations],
11 [Disable (detected) linker optimizations])],
12 [], [enable_linker_optimizations=yes])
14 AS_IF([test "x$enable_linker_optimizations" = "xno"], [
15 LDFLAGS=$(echo "$LDFLAGS" | $SED -e "s/ -Wl,-O[[0-9]]*\b//g")
18 LDFLAGS="$LDFLAGS -Wl,-O1"
20 AC_LANG_PROGRAM([[]], [[]])
22 LDFLAGS="$save_LDFLAGS"
27 # DPKG_LINKER_AS_NEEDED
28 # ---------------------
29 AC_DEFUN([DPKG_LINKER_AS_NEEDED], [
30 AC_CACHE_CHECK([for --as-needed linker flag], [dpkg_cv_linker_as_needed], [
32 LDFLAGS="$LDFLAGS -Wl,--as-needed"
34 AC_LANG_PROGRAM([], [])
36 dpkg_cv_linker_as_needed=yes
38 dpkg_cv_linker_as_needed=no
40 LDFLAGS="$save_LDFLAGS"
42 AM_CONDITIONAL([HAVE_LINKER_AS_NEEDED],
43 [test "x$dpkg_cv_linker_as_needed" = "xyes"])
46 # DPKG_LINKER_VERSION_SCRIPT
47 # --------------------------
48 AC_DEFUN([DPKG_LINKER_VERSION_SCRIPT], [
49 AC_CACHE_CHECK([for --version-script linker flag], [dpkg_cv_version_script], [
50 echo "{ global: symbol; local: *; };" >conftest.map
52 LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
54 AC_LANG_PROGRAM([], [])
56 dpkg_cv_version_script=yes
58 dpkg_cv_version_script=no
60 LDFLAGS="$save_LDFLAGS"
63 AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
64 [test "x$dpkg_cv_version_script" = "xyes"])