summaryrefslogtreecommitdiffstats
path: root/m4/ld-as-needed.m4
blob: d6590192207639636ed62f72541dcb3a5a56fab1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/m4
dnl Check whether ld supports --as-needed

AC_DEFUN([PAM_LD_AS_NEEDED], [dnl
  AC_CACHE_CHECK([whether ld supports --as-needed],
                 [pam_cv_ld_as_needed],
                 [saved_LDFLAGS="$LDFLAGS"
                  LDFLAGS="$LDFLAGS -Wl,--as-needed"
                  AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
                                 [pam_cv_ld_as_needed=yes],
                                 [pam_cv_ld_as_needed=no])
                  LDFLAGS="$saved_LDFLAGS"])
  AS_IF([test $pam_cv_ld_as_needed = yes],
        [LDFLAGS="$LDFLAGS -Wl,--as-needed"])
])