Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3de04e4

Browse files
committed
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
1 parent 264eb03 commit 3de04e4

File tree

2 files changed

+243
-171
lines changed

2 files changed

+243
-171
lines changed

config/c-compiler.m4

+24-24
Original file line numberDiff line numberDiff line change
@@ -428,26 +428,40 @@ fi])# PGAC_C_VA_ARGS
428428

429429

430430

431-
# PGAC_PROG_CC_CFLAGS_OPT
431+
# PGAC_PROG_VARCC_VARFLAGS_OPT
432432
# -----------------------
433-
# Given a string, check if the compiler supports the string as a
434-
# command-line option. If it does, add the string to CFLAGS.
435-
AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
436-
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$1])])dnl
437-
AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
433+
# Given a compiler, variable name and a string, check if the compiler
434+
# supports the string as a command-line option. If it does, add the
435+
# string to the given variable.
436+
AC_DEFUN([PGAC_PROG_VARCC_VARFLAGS_OPT],
437+
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_$1_cflags_$3])])dnl
438+
AC_CACHE_CHECK([whether ${$1} supports $3, for $2], [Ac_cachevar],
438439
[pgac_save_CFLAGS=$CFLAGS
439-
CFLAGS="$pgac_save_CFLAGS $1"
440+
pgac_save_CC=$CC
441+
CC=${$1}
442+
CFLAGS="${$2} $3"
440443
ac_save_c_werror_flag=$ac_c_werror_flag
441444
ac_c_werror_flag=yes
442445
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
443446
[Ac_cachevar=yes],
444447
[Ac_cachevar=no])
445448
ac_c_werror_flag=$ac_save_c_werror_flag
446-
CFLAGS="$pgac_save_CFLAGS"])
449+
CFLAGS="$pgac_save_CFLAGS"
450+
CC="$pgac_save_CC"])
447451
if test x"$Ac_cachevar" = x"yes"; then
448-
CFLAGS="$CFLAGS $1"
452+
$2="${$2} $3"
449453
fi
450454
undefine([Ac_cachevar])dnl
455+
])# PGAC_PROG_VARCC_VARFLAGS_OPT
456+
457+
458+
459+
# PGAC_PROG_CC_CFLAGS_OPT
460+
# -----------------------
461+
# Given a string, check if the compiler supports the string as a
462+
# command-line option. If it does, add the string to CFLAGS.
463+
AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT], [
464+
PGAC_PROG_VARCC_VARFLAGS_OPT(CC, CFLAGS, $1)
451465
])# PGAC_PROG_CC_CFLAGS_OPT
452466

453467

@@ -458,21 +472,7 @@ undefine([Ac_cachevar])dnl
458472
# the string as a command-line option. If it does, add the string to
459473
# the given variable.
460474
AC_DEFUN([PGAC_PROG_CC_VAR_OPT],
461-
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$2])])dnl
462-
AC_CACHE_CHECK([whether $CC supports $2], [Ac_cachevar],
463-
[pgac_save_CFLAGS=$CFLAGS
464-
CFLAGS="$pgac_save_CFLAGS $2"
465-
ac_save_c_werror_flag=$ac_c_werror_flag
466-
ac_c_werror_flag=yes
467-
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
468-
[Ac_cachevar=yes],
469-
[Ac_cachevar=no])
470-
ac_c_werror_flag=$ac_save_c_werror_flag
471-
CFLAGS="$pgac_save_CFLAGS"])
472-
if test x"$Ac_cachevar" = x"yes"; then
473-
$1="${$1} $2"
474-
fi
475-
undefine([Ac_cachevar])dnl
475+
[PGAC_PROG_VARCC_VARFLAGS_OPT(CC, $1, $2)
476476
])# PGAC_PROG_CC_VAR_OPT
477477

478478

0 commit comments

Comments
 (0)