vformat.c: fixed incomplete base64_init()
[barry.git] / m4 / ax_c_check_flag.m4
blob479bd165c3c0b1431b354729c2a1a5b4cae5a3fc
1 ##### http://autoconf-archive.cryp.to/ax_c_check_flag.html
3 # SYNOPSIS
5 #   AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
7 # DESCRIPTION
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.
14 #   This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
15 #   Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
17 # LAST MODIFICATION
19 #   2007-11-26
21 # COPYLEFT
23 #   Copyright (c) 2007 Francesco Salvestrini <salvestrini@users.sourceforge.net>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39 #   As a special exception, the respective Autoconf Macro's copyright
40 #   owner gives unlimited permission to copy, distribute and modify the
41 #   configure scripts that are the output of Autoconf when processing
42 #   the Macro. You need not follow the terms of the GNU General Public
43 #   License when using or distributing such scripts, even though
44 #   portions of the text of the Macro appear in them. The GNU General
45 #   Public License (GPL) does govern all other use of the material that
46 #   constitutes the Autoconf Macro.
48 #   This special exception to the GPL applies to versions of the
49 #   Autoconf Macro released by the Autoconf Macro Archive. When you
50 #   make and distribute a modified version of the Autoconf Macro, you
51 #   may extend this special exception to the GPL to apply to your
52 #   modified version as well.
54 AC_DEFUN([AX_C_CHECK_FLAG],[
55   AC_PREREQ([2.61])
56   AC_REQUIRE([AC_PROG_CC])
57   AC_REQUIRE([AC_PROG_SED])
59   flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
61   AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
62     [ax_cv_c_check_flag_$flag],[
64     AC_LANG_PUSH([C])
66     save_CFLAGS="$CFLAGS"
67     CFLAGS="$CFLAGS $1"
68     AC_COMPILE_IFELSE([
69       AC_LANG_PROGRAM([$2],[$3])
70     ],[
71       eval "ax_cv_c_check_flag_$flag=yes"
72     ],[
73       eval "ax_cv_c_check_flag_$flag=no"
74     ])
76     CFLAGS="$save_CFLAGS"
78     AC_LANG_POP
80   ])
82   AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
83     :
84     $4
85   ],[
86     :
87     $5
88   ])