]> git.sesse.net Git - vlc/blob - m4/flags.m4
Avoid flags duplication when configure cache not present
[vlc] / m4 / flags.m4
1 # <rdenis (at) simphalempin (dot) com>.
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.
5
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
9 # PARTICULAR PURPOSE.
10
11 AC_DEFUN([RDC_PROG_CC_FLAGS_IFELSE],
12 [AC_LANG_ASSERT(C)
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} $1"
17     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
18       eval "$as_ac_var=yes"
19     ],[
20       eval "$as_ac_var=no"
21     ])
22   ])
23
24   ac_res=`eval echo '${'$as_ac_var'}'`
25   AS_IF([test "${ac_res}" != "no"], [
26     CFLAGS="${CFLAGS_save} $1"
27     CXXFLAGS="${CXXFLAGS} $1"
28     OBJCFLAGS="${OBJCFLAGS} $1"
29     $2
30   ], [
31     CFLAGS="${CFLAGS_save}"
32     $3
33   ])
34 ])
35
36 AC_DEFUN([RDC_PROG_CC_WFLAGS],
37 [ for a in $1; do
38     RDC_PROG_CC_FLAGS_IFELSE([-W$a])
39   done
40 ])
41
42 AC_DEFUN([RDC_PROG_LINK_FLAGS_IFELSE],
43 [AC_LANG_ASSERT(C)
44   LDFLAGS_save="${LDFLAGS}"
45   as_ac_var=`echo "ac_cv_prog_link_flags_$1" | $as_tr_sh`
46   AC_CACHE_CHECK([if $LINK accepts $1], [$as_ac_var], [
47     LDFLAGS="${LDFLAGS} $1"
48     AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
49       eval "$as_ac_var=yes"
50     ],[
51       eval "$as_ac_var=no"
52     ])
53   ])
54
55   ac_res=`eval echo '${'$as_ac_var'}'`
56   AS_IF([test "${ac_res}" != "no"], [
57     LDFLAGS="${LDFLAGS} $1"
58     $2
59   ], [
60     LDFLAGS="${LDFLAGS_save}"
61     $3
62   ])
63 ])