1 # Copyright © 2006 Rémi Denis-Courmont
2 # This file (flags.m4) is free software; unlimited permission to
3 # copy and/or distribute it , with or without modifications, as long
4 # as this notice is preserved.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 AC_DEFUN([RDC_PROG_CC_FLAGS_IFELSE],
13 CFLAGS_save="${CFLAGS}"
14 as_ac_var=`echo "ac_cv_prog_cc_flags_$1" | $as_tr_sh`
15 AC_CACHE_CHECK([if $CC accepts $1], [$as_ac_var], [
16 CFLAGS="${CFLAGS} -Werror $1"
17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
24 ac_res=`eval echo '${'$as_ac_var'}'`
25 CFLAGS="${CFLAGS_save}"
26 AS_IF([test "${ac_res}" != "no"], [$2], [$3])
29 AC_DEFUN([RDC_PROG_CC_FLAGS],
31 RDC_PROG_CC_FLAGS_IFELSE([$1], [CFLAGS="${CFLAGS} $1"])
34 AC_DEFUN([RDC_PROG_CC_WFLAGS],
36 RDC_PROG_CC_FLAGS([-W$a])
40 AC_DEFUN([RDC_PROG_CC_FFLAGS],
42 RDC_PROG_CC_FLAGS([-f$a])
46 AC_DEFUN([RDC_PROG_CXX_FLAGS_IFELSE],
48 CXXFLAGS_save="${CXXFLAGS}"
49 as_ac_var=`echo "ac_cv_prog_cxx_flags_$1" | $as_tr_sh`
50 AC_CACHE_CHECK([if $CXX accepts $1], [$as_ac_var], [
51 CXXFLAGS="${CXXFLAGS} -Werror $1"
52 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
59 ac_res=`eval echo '${'$as_ac_var'}'`
60 CXXFLAGS="${CXXFLAGS_save}"
61 AS_IF([test "${ac_res}" != "no"], [$2], [$3])
64 AC_DEFUN([RDC_PROG_CXX_FLAGS],
66 RDC_PROG_CXX_FLAGS_IFELSE([$1], [CXXFLAGS="${CXXFLAGS} $1"])
69 AC_DEFUN([RDC_PROG_CXX_WFLAGS],
71 RDC_PROG_CXX_FLAGS([-W$a])
75 AC_DEFUN([RDC_PROG_CXX_FFLAGS],
77 RDC_PROG_CXX_FLAGS([-f$a])
81 AC_DEFUN([RDC_PROG_LINK_FLAGS_IFELSE],
83 LDFLAGS_save="${LDFLAGS}"
84 as_ac_var=`echo "ac_cv_prog_link_flags_$1" | $as_tr_sh`
85 AC_CACHE_CHECK([if $LINK accepts $1], [$as_ac_var], [
86 LDFLAGS="${LDFLAGS} $1"
87 AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
94 ac_res=`eval echo '${'$as_ac_var'}'`
95 AS_IF([test "${ac_res}" != "no"], [
96 LDFLAGS="${LDFLAGS} $1"
99 LDFLAGS="${LDFLAGS_save}"