aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorRandy Witt <rewitt@declaratino.com>2012-03-16 01:01:17 -0400
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-03-17 03:34:08 -0300
commit00ff57663d45e6c16a85a18a73cbabd316a571c9 (patch)
treed2ee13d46ef8514454746bd52a2209652450d295 /m4
parent436da1e96efff42e2adaa632bff20efdc91f570d (diff)
downloadkmod-00ff57663d45e6c16a85a18a73cbabd316a571c9.tar.gz
Add CC_CHECK_LDFLAGS_APPEND m4 macro.
This is mostly just preparation for the next patch. But this macro is used for flags that are only needed during linking but that don't make sense for normal compilation. I saw this exact type of patch online for systemd, but it never seems to have actually been incorporated into their attributes.m4.
Diffstat (limited to 'm4')
-rw-r--r--m4/attributes.m443
1 files changed, 37 insertions, 6 deletions
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index 9d561c2..20d05e4 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -81,15 +81,14 @@ AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
done
])
-dnl Check if the flag is supported by linker (cacheable)
-dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+dnl Check if the flag is supported by linker
+dnl CC_CHECK_LDFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
-AC_DEFUN([CC_CHECK_LDFLAGS], [
- AC_CACHE_CHECK([if $CC supports $1 flag],
- AS_TR_SH([cc_cv_ldflags_$1]),
+AC_DEFUN([CC_CHECK_LDFLAGS_SILENT], [
+ AC_CACHE_VAL(AS_TR_SH([cc_cv_ldflags_$1]),
[ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $1"
- AC_LINK_IFELSE([int main() { return 1; }],
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])],
[eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
[eval "AS_TR_SH([cc_cv_ldflags_$1])="])
LDFLAGS="$ac_save_LDFLAGS"
@@ -99,6 +98,38 @@ AC_DEFUN([CC_CHECK_LDFLAGS], [
[$2], [$3])
])
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_ldflags_$1]),
+ CC_CHECK_LDFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl CC_CHECK_LDFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for LDFLAG and appends them to LDFLAGS if supported
+AC_DEFUN([CC_CHECK_LDFLAG_APPEND], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_ldflags_$1]),
+ CC_CHECK_LDFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+ [LDFLAGS="$LDFLAGS $1"; DEBUG_LDFLAGS="$DEBUG_LDFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_LDFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_LDFLAGS_APPEND], [
+ for flag in $1; do
+ CC_CHECK_LDFLAG_APPEND($flag, [$2], [$3])
+ done
+])
+
dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
dnl the current linker to avoid undefined references in a shared object.
AC_DEFUN([CC_NOUNDEFINED], [