Blame m4/ax_gcc_option.m4

Packit Service 2e9770
# ===========================================================================
Packit Service 2e9770
#       http://www.gnu.org/software/autoconf-archive/ax_gcc_option.html
Packit Service 2e9770
# ===========================================================================
Packit Service 2e9770
#
Packit Service 2e9770
# OBSOLETE MACRO
Packit Service 2e9770
#
Packit Service 2e9770
#   Deprecated in favor of AX_C_CHECK_FLAG, AX_CXX_CHECK_FLAG,
Packit Service 2e9770
#   AX_CPP_CHECK_FLAG, AX_CXXCPP_CHECK_FLAG and AX_LD_CHECK_FLAG.
Packit Service 2e9770
#
Packit Service 2e9770
# SYNOPSIS
Packit Service 2e9770
#
Packit Service 2e9770
#   AX_GCC_OPTION(OPTION,EXTRA-OPTIONS,TEST-PROGRAM,ACTION-IF-SUCCESSFUL,ACTION-IF-NOT-SUCCESFUL)
Packit Service 2e9770
#
Packit Service 2e9770
# DESCRIPTION
Packit Service 2e9770
#
Packit Service 2e9770
#   AX_GCC_OPTION checks wheter gcc accepts the passed OPTION. If it accepts
Packit Service 2e9770
#   the OPTION then ACTION-IF-SUCCESSFUL will be executed, otherwise
Packit Service 2e9770
#   ACTION-IF-UNSUCCESSFUL.
Packit Service 2e9770
#
Packit Service 2e9770
#   A typical usage should be the following one:
Packit Service 2e9770
#
Packit Service 2e9770
#     AX_GCC_OPTION([-fomit-frame-pointer],[],[],[
Packit Service 2e9770
#       AC_MSG_NOTICE([The option is supported])],[
Packit Service 2e9770
#       AC_MSG_NOTICE([No luck this time])
Packit Service 2e9770
#     ])
Packit Service 2e9770
#
Packit Service 2e9770
#   The macro doesn't discriminate between languages so, if you are testing
Packit Service 2e9770
#   for an option that works for C++ but not for C you should use '-x c++'
Packit Service 2e9770
#   as EXTRA-OPTIONS:
Packit Service 2e9770
#
Packit Service 2e9770
#     AX_GCC_OPTION([-fno-rtti],[-x c++],[],[ ... ],[ ... ])
Packit Service 2e9770
#
Packit Service 2e9770
#   OPTION is tested against the following code:
Packit Service 2e9770
#
Packit Service 2e9770
#     int main()
Packit Service 2e9770
#     {
Packit Service 2e9770
#             return 0;
Packit Service 2e9770
#     }
Packit Service 2e9770
#
Packit Service 2e9770
#   The optional TEST-PROGRAM comes handy when the default main() is not
Packit Service 2e9770
#   suited for the option being checked
Packit Service 2e9770
#
Packit Service 2e9770
#   So, if you need to test for -fstrict-prototypes option you should
Packit Service 2e9770
#   probably use the macro as follows:
Packit Service 2e9770
#
Packit Service 2e9770
#     AX_GCC_OPTION([-fstrict-prototypes],[-x c++],[
Packit Service 2e9770
#       int main(int argc, char ** argv)
Packit Service 2e9770
#       {
Packit Service 2e9770
#               (void) argc;
Packit Service 2e9770
#               (void) argv;
Packit Service 2e9770
#
Packit Service 2e9770
#               return 0;
Packit Service 2e9770
#       }
Packit Service 2e9770
#     ],[ ... ],[ ... ])
Packit Service 2e9770
#
Packit Service 2e9770
#   Note that the macro compiles but doesn't link the test program so it is
Packit Service 2e9770
#   not suited for checking options that are passed to the linker, like:
Packit Service 2e9770
#
Packit Service 2e9770
#     -Wl,-L<a-library-path>
Packit Service 2e9770
#
Packit Service 2e9770
#   In order to avoid such kind of problems you should think about usinguse
Packit Service 2e9770
#   the AX_*_CHECK_FLAG family macros
Packit Service 2e9770
#
Packit Service 2e9770
# LICENSE
Packit Service 2e9770
#
Packit Service 2e9770
#   Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
Packit Service 2e9770
#   Copyright (c) 2008 Bogdan Drozdowski <bogdandr@op.pl>
Packit Service 2e9770
#
Packit Service 2e9770
#   This program is free software; you can redistribute it and/or modify it
Packit Service 2e9770
#   under the terms of the GNU General Public License as published by the
Packit Service 2e9770
#   Free Software Foundation; either version 2 of the License, or (at your
Packit Service 2e9770
#   option) any later version.
Packit Service 2e9770
#
Packit Service 2e9770
#   This program is distributed in the hope that it will be useful, but
Packit Service 2e9770
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2e9770
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit Service 2e9770
#   Public License for more details.
Packit Service 2e9770
#
Packit Service 2e9770
#   You should have received a copy of the GNU General Public License along
Packit Service 2e9770
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit Service 2e9770
#
Packit Service 2e9770
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit Service 2e9770
#   gives unlimited permission to copy, distribute and modify the configure
Packit Service 2e9770
#   scripts that are the output of Autoconf when processing the Macro. You
Packit Service 2e9770
#   need not follow the terms of the GNU General Public License when using
Packit Service 2e9770
#   or distributing such scripts, even though portions of the text of the
Packit Service 2e9770
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit Service 2e9770
#   all other use of the material that constitutes the Autoconf Macro.
Packit Service 2e9770
#
Packit Service 2e9770
#   This special exception to the GPL applies to versions of the Autoconf
Packit Service 2e9770
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit Service 2e9770
#   modified version of the Autoconf Macro, you may extend this special
Packit Service 2e9770
#   exception to the GPL to apply to your modified version as well.
Packit Service 2e9770
Packit Service 2e9770
#serial 13
Packit Service 2e9770
Packit Service 2e9770
AC_DEFUN([AX_GCC_OPTION], [
Packit Service 2e9770
  AC_REQUIRE([AC_PROG_CC])
Packit Service 2e9770
Packit Service 2e9770
  AC_MSG_CHECKING([if gcc accepts $1 option])
Packit Service 2e9770
Packit Service 2e9770
  AS_IF([ test "x$GCC" = "xyes" ],[
Packit Service 2e9770
    AS_IF([ test -z "$3" ],[
Packit Service 2e9770
      ax_gcc_option_test="int main()
Packit Service 2e9770
{
Packit Service 2e9770
	return 0;
Packit Service 2e9770
}"
Packit Service 2e9770
    ],[
Packit Service 2e9770
      ax_gcc_option_test="$3"
Packit Service 2e9770
    ])
Packit Service 2e9770
Packit Service 2e9770
    # Dump the test program to file
Packit Service 2e9770
    cat <<EOF > conftest.c
Packit Service 2e9770
$ax_gcc_option_test
Packit Service 2e9770
EOF
Packit Service 2e9770
Packit Service 2e9770
    # Dump back the file to the log, useful for debugging purposes
Packit Service 2e9770
    AC_TRY_COMMAND(cat conftest.c 1>&AS_MESSAGE_LOG_FD)
Packit Service 2e9770
Packit Service 2e9770
    AS_IF([ AC_TRY_COMMAND($CC $2 $1 -c conftest.c 1>&AS_MESSAGE_LOG_FD) ],[
Packit Service 2e9770
		AC_MSG_RESULT([yes])
Packit Service 2e9770
	$4
Packit Service 2e9770
    ],[
Packit Service 2e9770
		AC_MSG_RESULT([no])
Packit Service 2e9770
	$5
Packit Service 2e9770
    ])
Packit Service 2e9770
  ],[
Packit Service 2e9770
    AC_MSG_RESULT([no gcc available])
Packit Service 2e9770
  ])
Packit Service 2e9770
])