source: m4/ax_c_check_flag.m4 @ d564c3d

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since d564c3d was 8073852, checked in by Anders Kaseorg <andersk@mit.edu>, 15 years ago
Use an aclocal macro directory m4/, and add the macros we use. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Property mode set to 100644
File size: 2.9 KB
Line 
1# ===========================================================================
2#            http://autoconf-archive.cryp.to/ax_c_check_flag.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
8#
9# DESCRIPTION
10#
11#   This macro tests if the C compiler supports the flag FLAG-TO-CHECK. If
12#   successfull execute ACTION-IF-SUCCESS otherwise ACTION-IF-FAILURE.
13#   PROLOGUE and BODY are optional and should be used as in AC_LANG_PROGRAM
14#   macro.
15#
16#   This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
17#   Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
18#
19# LICENSE
20#
21#   Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
22#
23#   This program is free software; you can redistribute it and/or modify it
24#   under the terms of the GNU General Public License as published by the
25#   Free Software Foundation; either version 2 of the License, or (at your
26#   option) any later version.
27#
28#   This program is distributed in the hope that it will be useful, but
29#   WITHOUT ANY WARRANTY; without even the implied warranty of
30#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
31#   Public License for more details.
32#
33#   You should have received a copy of the GNU General Public License along
34#   with this program. If not, see <http://www.gnu.org/licenses/>.
35#
36#   As a special exception, the respective Autoconf Macro's copyright owner
37#   gives unlimited permission to copy, distribute and modify the configure
38#   scripts that are the output of Autoconf when processing the Macro. You
39#   need not follow the terms of the GNU General Public License when using
40#   or distributing such scripts, even though portions of the text of the
41#   Macro appear in them. The GNU General Public License (GPL) does govern
42#   all other use of the material that constitutes the Autoconf Macro.
43#
44#   This special exception to the GPL applies to versions of the Autoconf
45#   Macro released by the Autoconf Archive. When you make and distribute a
46#   modified version of the Autoconf Macro, you may extend this special
47#   exception to the GPL to apply to your modified version as well.
48
49AC_DEFUN([AX_C_CHECK_FLAG],[
50  AC_PREREQ([2.61])
51  AC_REQUIRE([AC_PROG_CC])
52  AC_REQUIRE([AC_PROG_SED])
53
54  flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
55
56  AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
57    [ax_cv_c_check_flag_$flag],[
58
59    AC_LANG_PUSH([C])
60
61    save_CFLAGS="$CFLAGS"
62    CFLAGS="$CFLAGS $1"
63    AC_COMPILE_IFELSE([
64      AC_LANG_PROGRAM([$2],[$3])
65    ],[
66      eval "ax_cv_c_check_flag_$flag=yes"
67    ],[
68      eval "ax_cv_c_check_flag_$flag=no"
69    ])
70
71    CFLAGS="$save_CFLAGS"
72
73    AC_LANG_POP
74
75  ])
76
77  AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
78    :
79    $4
80  ],[
81    :
82    $5
83  ])
84])
Note: See TracBrowser for help on using the repository browser.