]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/ax_gcc_option.m4
Add more checks for Intel compiler.
[wxWidgets.git] / build / aclocal / ax_gcc_option.m4
1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_gcc_option.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_GCC_OPTION(OPTION,EXTRA-OPTIONS,TEST-PROGRAM,ACTION-IF-SUCCESSFUL,ACTION-IF-NOT-SUCCESFUL)
8 #
9 # DESCRIPTION
10 #
11 # AX_GCC_OPTION checks wheter gcc accepts the passed OPTION. If it accepts
12 # the OPTION then ACTION-IF-SUCCESSFUL will be executed, otherwise
13 # ACTION-IF-UNSUCCESSFUL.
14 #
15 # NOTE: This macro will be obsoleted by AX_C_CHECK_FLAG AX_CXX_CHECK_FLAG,
16 # AX_CPP_CHECK_FLAG, AX_CXXCPP_CHECK_FLAG and AX_LD_CHECK_FLAG.
17 #
18 # A typical usage should be the following one:
19 #
20 # AX_GCC_OPTION([-fomit-frame-pointer],[],[],[
21 # AC_MSG_NOTICE([The option is supported])],[
22 # AC_MSG_NOTICE([No luck this time])
23 # ])
24 #
25 # The macro doesn't discriminate between languages so, if you are testing
26 # for an option that works for C++ but not for C you should use '-x c++'
27 # as EXTRA-OPTIONS:
28 #
29 # AX_GCC_OPTION([-fno-rtti],[-x c++],[],[ ... ],[ ... ])
30 #
31 # OPTION is tested against the following code:
32 #
33 # int main()
34 # {
35 # return 0;
36 # }
37 #
38 # The optional TEST-PROGRAM comes handy when the default main() is not
39 # suited for the option being checked
40 #
41 # So, if you need to test for -fstrict-prototypes option you should
42 # probably use the macro as follows:
43 #
44 # AX_GCC_OPTION([-fstrict-prototypes],[-x c++],[
45 # int main(int argc, char ** argv)
46 # {
47 # (void) argc;
48 # (void) argv;
49 #
50 # return 0;
51 # }
52 # ],[ ... ],[ ... ])
53 #
54 # Note that the macro compiles but doesn't link the test program so it is
55 # not suited for checking options that are passed to the linker, like:
56 #
57 # -Wl,-L<a-library-path>
58 #
59 # In order to avoid such kind of problems you should think about usinguse
60 # the AX_*_CHECK_FLAG family macros
61 #
62 # LAST MODIFICATION
63 #
64 # 2008-04-12
65 #
66 # COPYLEFT
67 #
68 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
69 # Copyright (c) 2008 Bogdan Drozdowski <bogdandr@op.pl>
70 #
71 # This program is free software; you can redistribute it and/or modify it
72 # under the terms of the GNU General Public License as published by the
73 # Free Software Foundation; either version 2 of the License, or (at your
74 # option) any later version.
75 #
76 # This program is distributed in the hope that it will be useful, but
77 # WITHOUT ANY WARRANTY; without even the implied warranty of
78 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
79 # Public License for more details.
80 #
81 # You should have received a copy of the GNU General Public License along
82 # with this program. If not, see <http://www.gnu.org/licenses/>.
83 #
84 # As a special exception, the respective Autoconf Macro's copyright owner
85 # gives unlimited permission to copy, distribute and modify the configure
86 # scripts that are the output of Autoconf when processing the Macro. You
87 # need not follow the terms of the GNU General Public License when using
88 # or distributing such scripts, even though portions of the text of the
89 # Macro appear in them. The GNU General Public License (GPL) does govern
90 # all other use of the material that constitutes the Autoconf Macro.
91 #
92 # This special exception to the GPL applies to versions of the Autoconf
93 # Macro released by the Autoconf Macro Archive. When you make and
94 # distribute a modified version of the Autoconf Macro, you may extend this
95 # special exception to the GPL to apply to your modified version as well.
96
97 AC_DEFUN([AX_GCC_OPTION], [
98 AC_REQUIRE([AC_PROG_CC])
99
100 AC_MSG_CHECKING([if gcc accepts $1 option])
101
102 AS_IF([ test "x$GCC" = "xyes" ],[
103 AS_IF([ test -z "$3" ],[
104 ax_gcc_option_test="int main()
105 {
106 return 0;
107 }"
108 ],[
109 ax_gcc_option_test="$3"
110 ])
111
112 # Dump the test program to file
113 cat <<EOF > conftest.c
114 $ax_gcc_option_test
115 EOF
116
117 # Dump back the file to the log, useful for debugging purposes
118 AC_TRY_COMMAND(cat conftest.c 1>&AS_MESSAGE_LOG_FD)
119
120 AS_IF([ AC_TRY_COMMAND($CC $2 $1 -c conftest.c 1>&AS_MESSAGE_LOG_FD) ],[
121 AC_MSG_RESULT([yes])
122 $4
123 ],[
124 AC_MSG_RESULT([no])
125 $5
126 ])
127 ],[
128 AC_MSG_RESULT([no gcc available])
129 ])
130 ])