summaryrefslogtreecommitdiffstats
path: root/m4/CC_CHECK_LDFLAGS.m4
blob: be20df3a94927837bd5a91abb77ceb4d40fecd97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
dnl Check if the flag is supported by linker (cacheable)
dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
dnl
dnl Origin (declared license: GPLv2+ with less restrictive exception):
dnl https://git.gnome.org/browse/glib/tree/m4macros/attributes.m4?h=2.49.1
dnl (AC_LANG_PROGRAM substituted by Jan Pokorny <jpokorny@redhat.com>)

AC_DEFUN([CC_CHECK_LDFLAGS], [
  AC_CACHE_CHECK([if $CC supports $1 flag],
    AS_TR_SH([cc_cv_ldflags_$1]),
    [ac_save_LDFLAGS="$LDFLAGS"
     LDFLAGS="$LDFLAGS $1"
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
       [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
       [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
     LDFLAGS="$ac_save_LDFLAGS"
    ])

  AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
    [$2], [$3])
])