summaryrefslogtreecommitdiff
path: root/config/c-compiler.m4
diff options
context:
space:
mode:
authorAndres Freund2018-03-20 19:58:08 +0000
committerAndres Freund2018-03-20 19:58:08 +0000
commit3de04e4ed12d0794e87e1db2e729d126cf183a58 (patch)
tree99dfe81a09960b493709793f2da256e241be6ae4 /config/c-compiler.m4
parent264eb03aab067da6db2a0de907a8421ce6865d60 (diff)
Add PGAC_PROG_VARCC_VARFLAGS_OPT autoconf macro.
The new macro allows to test flags for different compilers and to store them in different CFLAG like variables. The existing PGAC_PROG_CC_CFLAGS_OPT and PGAC_PROG_CC_VAR_OPT are changed to be just wrappers around the new function. This'll be used by the upcoming LLVM support, to separately detect capabilities used by clang, when generating bitcode. Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Diffstat (limited to 'config/c-compiler.m4')
-rw-r--r--config/c-compiler.m448
1 files changed, 24 insertions, 24 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 689bb7f181b..30b270185b1 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -428,26 +428,40 @@ fi])# PGAC_C_VA_ARGS
-# PGAC_PROG_CC_CFLAGS_OPT
+# PGAC_PROG_VARCC_VARFLAGS_OPT
# -----------------------
-# Given a string, check if the compiler supports the string as a
-# command-line option. If it does, add the string to CFLAGS.
-AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
-[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$1])])dnl
-AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
+# Given a compiler, variable name and a string, check if the compiler
+# supports the string as a command-line option. If it does, add the
+# string to the given variable.
+AC_DEFUN([PGAC_PROG_VARCC_VARFLAGS_OPT],
+[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_$1_cflags_$3])])dnl
+AC_CACHE_CHECK([whether ${$1} supports $3, for $2], [Ac_cachevar],
[pgac_save_CFLAGS=$CFLAGS
-CFLAGS="$pgac_save_CFLAGS $1"
+pgac_save_CC=$CC
+CC=${$1}
+CFLAGS="${$2} $3"
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[Ac_cachevar=yes],
[Ac_cachevar=no])
ac_c_werror_flag=$ac_save_c_werror_flag
-CFLAGS="$pgac_save_CFLAGS"])
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"])
if test x"$Ac_cachevar" = x"yes"; then
- CFLAGS="$CFLAGS $1"
+ $2="${$2} $3"
fi
undefine([Ac_cachevar])dnl
+])# PGAC_PROG_VARCC_VARFLAGS_OPT
+
+
+
+# PGAC_PROG_CC_CFLAGS_OPT
+# -----------------------
+# Given a string, check if the compiler supports the string as a
+# command-line option. If it does, add the string to CFLAGS.
+AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT], [
+PGAC_PROG_VARCC_VARFLAGS_OPT(CC, CFLAGS, $1)
])# PGAC_PROG_CC_CFLAGS_OPT
@@ -458,21 +472,7 @@ undefine([Ac_cachevar])dnl
# the string as a command-line option. If it does, add the string to
# the given variable.
AC_DEFUN([PGAC_PROG_CC_VAR_OPT],
-[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$2])])dnl
-AC_CACHE_CHECK([whether $CC supports $2], [Ac_cachevar],
-[pgac_save_CFLAGS=$CFLAGS
-CFLAGS="$pgac_save_CFLAGS $2"
-ac_save_c_werror_flag=$ac_c_werror_flag
-ac_c_werror_flag=yes
-_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
- [Ac_cachevar=yes],
- [Ac_cachevar=no])
-ac_c_werror_flag=$ac_save_c_werror_flag
-CFLAGS="$pgac_save_CFLAGS"])
-if test x"$Ac_cachevar" = x"yes"; then
- $1="${$1} $2"
-fi
-undefine([Ac_cachevar])dnl
+[PGAC_PROG_VARCC_VARFLAGS_OPT(CC, $1, $2)
])# PGAC_PROG_CC_VAR_OPT