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"
55 extern int symbol(void);
56 int symbol(void) { return 0; }
60 dpkg_cv_version_script=yes
62 dpkg_cv_version_script=no
64 LDFLAGS="$save_LDFLAGS"
67 AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
68 [test "x$dpkg_cv_version_script" = "xyes"])