Blame m4/ax_c_check_flag.m4

Packit Service 2e9770
# ===========================================================================
Packit Service 2e9770
#      http://www.gnu.org/software/autoconf-archive/ax_c_check_flag.html
Packit Service 2e9770
# ===========================================================================
Packit Service 2e9770
#
Packit Service 2e9770
# SYNOPSIS
Packit Service 2e9770
#
Packit Service 2e9770
#   AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
Packit Service 2e9770
#
Packit Service 2e9770
# DESCRIPTION
Packit Service 2e9770
#
Packit Service 2e9770
#   This macro tests if the C compiler supports the flag FLAG-TO-CHECK. If
Packit Service 2e9770
#   successfull execute ACTION-IF-SUCCESS otherwise ACTION-IF-FAILURE.
Packit Service 2e9770
#   PROLOGUE and BODY are optional and should be used as in AC_LANG_PROGRAM
Packit Service 2e9770
#   macro.
Packit Service 2e9770
#
Packit Service 2e9770
#   This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
Packit Service 2e9770
#   Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
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
#
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 6
Packit Service 2e9770
Packit Service 2e9770
AC_DEFUN([AX_C_CHECK_FLAG],[
Packit Service 2e9770
  AC_PREREQ([2.61])
Packit Service 2e9770
  AC_REQUIRE([AC_PROG_CC])
Packit Service 2e9770
  AC_REQUIRE([AC_PROG_SED])
Packit Service 2e9770
Packit Service 2e9770
  flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
Packit Service 2e9770
Packit Service 2e9770
  AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
Packit Service 2e9770
    [ax_cv_c_check_flag_$flag],[
Packit Service 2e9770
Packit Service 2e9770
    AC_LANG_PUSH([C])
Packit Service 2e9770
Packit Service 2e9770
    save_CFLAGS="$CFLAGS"
Packit Service 2e9770
    CFLAGS="$CFLAGS $1"
Packit Service 2e9770
    AC_COMPILE_IFELSE([
Packit Service 2e9770
      AC_LANG_PROGRAM([$2],[$3])
Packit Service 2e9770
    ],[
Packit Service 2e9770
      eval "ax_cv_c_check_flag_$flag=yes"
Packit Service 2e9770
    ],[
Packit Service 2e9770
      eval "ax_cv_c_check_flag_$flag=no"
Packit Service 2e9770
    ])
Packit Service 2e9770
Packit Service 2e9770
    CFLAGS="$save_CFLAGS"
Packit Service 2e9770
Packit Service 2e9770
    AC_LANG_POP
Packit Service 2e9770
Packit Service 2e9770
  ])
Packit Service 2e9770
Packit Service 2e9770
  AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
Packit Service 2e9770
    :
Packit Service 2e9770
    $4
Packit Service 2e9770
  ],[
Packit Service 2e9770
    :
Packit Service 2e9770
    $5
Packit Service 2e9770
  ])
Packit Service 2e9770
])