i18n work in progress... desperately needs some housecleaning.
[barry.git] / m4 / ax_cxx_check_flag.m4
blobef592d7e916b4eb27200e8958e2486e5e9e86b0d
1 ##### http://autoconf-archive.cryp.to/ax_cxx_check_flag.html
3 # SYNOPSIS
5 #   AX_CXX_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
10 #   FLAG-TO-CHECK. 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., 59 Temple Place - Suite 330, Boston, MA
38 #   02111-1307, USA.
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.
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.
55 AC_DEFUN([AX_CXX_CHECK_FLAG],[
56   AC_PREREQ([2.61])
57   AC_REQUIRE([AC_PROG_CXX])
58   AC_REQUIRE([AC_PROG_SED])
60   flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
62   AC_CACHE_CHECK([whether the C++ compiler accepts the $1 flag],
63     [ax_cv_cxx_check_flag_$flag],[
65     AC_LANG_PUSH([C++])
67     save_CXXFLAGS="$CXXFLAGS"
68     CXXFLAGS="$CXXFLAGS $1"
69     AC_COMPILE_IFELSE([
70       AC_LANG_PROGRAM([$2],[$3])
71     ],[
72       eval "ax_cv_cxx_check_flag_$flag=yes"
73     ],[
74       eval "ax_cv_cxx_check_flag_$flag=no"
75     ])
77     CXXFLAGS="$save_CXXFLAGS"
79     AC_LANG_POP
81   ])
83   AS_IF([eval "test \"`echo '$ax_cv_cxx_check_flag_'$flag`\" = yes"],[
84     :
85     $4
86   ],[
87     :
88     $5
89   ])