Debian Codegraph @

m4/ax_c_check_flag.m4

raw
1 ##### http://autoconf-archive.cryp.to/ax_c_check_flag.html
2 #
3 # SYNOPSIS
4 #
5 # AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
6 #
7 # DESCRIPTION
8 #
9 # This macro tests if the C compiler supports the flag FLAG-TO-CHECK.
10 # If successfull execute ACTION-IF-SUCCESS otherwise
11 # ACTION-IF-FAILURE. PROLOGUE and BODY are optional and should be
12 # used as in AC_LANG_PROGRAM macro.
13 #
14 # This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
15 # Bogdan Drozdowski <[email protected]> for testing and bug fixes.
16 #
17 # LAST MODIFICATION
18 #
19 # 2007-11-26
20 #
21 # COPYLEFT
22 #
23 # Copyright (c) 2007 Francesco Salvestrini <[email protected]>
24 #
25 # This program is free software; you can redistribute it and/or
26 # modify it under the terms of the GNU General Public License as
27 # published by the Free Software Foundation; either version 2 of the
28 # License, or (at your option) any later version.
29 #
30 # This program is distributed in the hope that it will be useful, but
31 # WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 # General Public License for more details.
34 #
35 # You should have received a copy of the GNU General Public License
36 # along with this program; if not, write to the Free Software
37 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
38 # 02111-1307, USA.
39 #
40 # As a special exception, the respective Autoconf Macro's copyright
41 # owner gives unlimited permission to copy, distribute and modify the
42 # configure scripts that are the output of Autoconf when processing
43 # the Macro. You need not follow the terms of the GNU General Public
44 # License when using or distributing such scripts, even though
45 # portions of the text of the Macro appear in them. The GNU General
46 # Public License (GPL) does govern all other use of the material that
47 # constitutes the Autoconf Macro.
48 #
49 # This special exception to the GPL applies to versions of the
50 # Autoconf Macro released by the Autoconf Macro Archive. When you
51 # make and distribute a modified version of the Autoconf Macro, you
52 # may extend this special exception to the GPL to apply to your
53 # modified version as well.
54
55 AC_DEFUN([AX_C_CHECK_FLAG],[
56 AC_PREREQ([2.61])
57 AC_REQUIRE([AC_PROG_CC])
58 AC_REQUIRE([AC_PROG_SED])
59
60 flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
61
62 AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
63 [ax_cv_c_check_flag_$flag],[
64
65 AC_LANG_PUSH([C])
66
67 save_CFLAGS="$CFLAGS"
68 CFLAGS="$CFLAGS $1"
69 AC_COMPILE_IFELSE([
70 AC_LANG_PROGRAM([$2],[$3])
71 ],[
72 eval "ax_cv_c_check_flag_$flag=yes"
73 ],[
74 eval "ax_cv_c_check_flag_$flag=no"
75 ])
76
77 CFLAGS="$save_CFLAGS"
78
79 AC_LANG_POP
80
81 ])
82
83 AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
84 :
85 $4
86 ],[
87 :
88 $5
89 ])
90 ])