summaryrefslogtreecommitdiffstats
path: root/m4/CC_CHECK_LDFLAGS.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/CC_CHECK_LDFLAGS.m4')
-rw-r--r--m4/CC_CHECK_LDFLAGS.m421
1 files changed, 21 insertions, 0 deletions
diff --git a/m4/CC_CHECK_LDFLAGS.m4 b/m4/CC_CHECK_LDFLAGS.m4
new file mode 100644
index 0000000..be20df3
--- /dev/null
+++ b/m4/CC_CHECK_LDFLAGS.m4
@@ -0,0 +1,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])
+])