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