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_CXX_FLAGS_IFELSE],
42 CXXFLAGS_save="${CXXFLAGS}"
43 as_ac_var=`echo "ac_cv_prog_cxx_flags_$1" | $as_tr_sh`
44 AC_CACHE_CHECK([if $CXX accepts $1], [$as_ac_var], [
45 CXXFLAGS="${CXXFLAGS} $1"
46 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
53 ac_res=`eval echo '${'$as_ac_var'}'`
54 CXXFLAGS="${CXXFLAGS_save}"
55 AS_IF([test "${ac_res}" != "no"], [$2], [$3])
58 AC_DEFUN([RDC_PROG_CXX_FLAGS],
60 RDC_PROG_CXX_FLAGS_IFELSE([$1], [CXXFLAGS="${CXXFLAGS} $1"])
63 AC_DEFUN([RDC_PROG_CXX_WFLAGS],
65 RDC_PROG_CXX_FLAGS([-W$a])
69 AC_DEFUN([RDC_PROG_LINK_FLAGS_IFELSE],
71 LDFLAGS_save="${LDFLAGS}"
72 as_ac_var=`echo "ac_cv_prog_link_flags_$1" | $as_tr_sh`
73 AC_CACHE_CHECK([if $LINK accepts $1], [$as_ac_var], [
74 LDFLAGS="${LDFLAGS} $1"
75 AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
82 ac_res=`eval echo '${'$as_ac_var'}'`
83 AS_IF([test "${ac_res}" != "no"], [
84 LDFLAGS="${LDFLAGS} $1"
87 LDFLAGS="${LDFLAGS_save}"