flags.m4 1.08 KB
Newer Older
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# <rdenis (at) simphalempin (dot) com>.
# This file (flags.m4) is free software; unlimited permission to
# copy and/or distribute it , with or without modifications, as long
# as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

AC_DEFUN([RDC_PROG_CC_FLAGS_IFELSE],
[AC_LANG_ASSERT(C)
  CFLAGS_save="${CFLAGS}"
  as_ac_var=`echo "ac_cv_prog_cc_flags_$1" | $as_tr_sh`
  AC_CACHE_CHECK([if $CC accepts $1], [$as_ac_var], [
Rémi Denis-Courmont's avatar
Fixes    
Rémi Denis-Courmont committed
16
    CFLAGS="${CFLAGS_save} $1"
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
17
18
19
20
21
22
23
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
      eval "$as_ac_var=yes"
    ],[
      eval "$as_ac_var=no"
    ])
  ])

Rémi Denis-Courmont's avatar
Fixes    
Rémi Denis-Courmont committed
24
  ac_res=`eval echo '${'$as_ac_var'}'`
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
25
  AS_IF([test "${ac_res}" != "no"], [
Rémi Denis-Courmont's avatar
Fixes    
Rémi Denis-Courmont committed
26
27
28
    CFLAGS="${CFLAGS_save} $1"
    CXXFLAGS="${CFLAGS_save} $1"
    OBJCFLAGS="${OBJCFLAGS_save} $1"
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
29
30
31
32
33
34
35
36
37
38
39
40
    $2
  ], [
    CFLAGS="${CFLAGS_save}"
    $3
  ])
])

AC_DEFUN([RDC_PROG_CC_WFLAGS],
[ for a in $1; do
    RDC_PROG_CC_FLAGS_IFELSE([-W$a])
  done
])