Blame m4/ax_c_check_flag.m4

Packit 80c72f
# ===========================================================================
Packit 80c72f
#      http://www.gnu.org/software/autoconf-archive/ax_c_check_flag.html
Packit 80c72f
# ===========================================================================
Packit 80c72f
#
Packit 80c72f
# SYNOPSIS
Packit 80c72f
#
Packit 80c72f
#   AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
Packit 80c72f
#
Packit 80c72f
# DESCRIPTION
Packit 80c72f
#
Packit 80c72f
#   This macro tests if the C compiler supports the flag FLAG-TO-CHECK. If
Packit 80c72f
#   successfull execute ACTION-IF-SUCCESS otherwise ACTION-IF-FAILURE.
Packit 80c72f
#   PROLOGUE and BODY are optional and should be used as in AC_LANG_PROGRAM
Packit 80c72f
#   macro.
Packit 80c72f
#
Packit 80c72f
#   This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
Packit 80c72f
#   Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
Packit 80c72f
#
Packit 80c72f
# LICENSE
Packit 80c72f
#
Packit 80c72f
#   Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
Packit 80c72f
#
Packit 80c72f
#   This program is free software; you can redistribute it and/or modify it
Packit 80c72f
#   under the terms of the GNU General Public License as published by the
Packit 80c72f
#   Free Software Foundation; either version 2 of the License, or (at your
Packit 80c72f
#   option) any later version.
Packit 80c72f
#
Packit 80c72f
#   This program is distributed in the hope that it will be useful, but
Packit 80c72f
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 80c72f
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 80c72f
#   Public License for more details.
Packit 80c72f
#
Packit 80c72f
#   You should have received a copy of the GNU General Public License along
Packit 80c72f
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 80c72f
#
Packit 80c72f
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit 80c72f
#   gives unlimited permission to copy, distribute and modify the configure
Packit 80c72f
#   scripts that are the output of Autoconf when processing the Macro. You
Packit 80c72f
#   need not follow the terms of the GNU General Public License when using
Packit 80c72f
#   or distributing such scripts, even though portions of the text of the
Packit 80c72f
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 80c72f
#   all other use of the material that constitutes the Autoconf Macro.
Packit 80c72f
#
Packit 80c72f
#   This special exception to the GPL applies to versions of the Autoconf
Packit 80c72f
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit 80c72f
#   modified version of the Autoconf Macro, you may extend this special
Packit 80c72f
#   exception to the GPL to apply to your modified version as well.
Packit 80c72f
Packit 80c72f
#serial 6
Packit 80c72f
Packit 80c72f
AC_DEFUN([AX_C_CHECK_FLAG],[
Packit 80c72f
  AC_PREREQ([2.61])
Packit 80c72f
  AC_REQUIRE([AC_PROG_CC])
Packit 80c72f
  AC_REQUIRE([AC_PROG_SED])
Packit 80c72f
Packit 80c72f
  flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
Packit 80c72f
Packit 80c72f
  AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
Packit 80c72f
    [ax_cv_c_check_flag_$flag],[
Packit 80c72f
Packit 80c72f
    AC_LANG_PUSH([C])
Packit 80c72f
Packit 80c72f
    save_CFLAGS="$CFLAGS"
Packit 80c72f
    CFLAGS="$CFLAGS $1"
Packit 80c72f
    AC_COMPILE_IFELSE([
Packit 80c72f
      AC_LANG_PROGRAM([$2],[$3])
Packit 80c72f
    ],[
Packit 80c72f
      eval "ax_cv_c_check_flag_$flag=yes"
Packit 80c72f
    ],[
Packit 80c72f
      eval "ax_cv_c_check_flag_$flag=no"
Packit 80c72f
    ])
Packit 80c72f
Packit 80c72f
    CFLAGS="$save_CFLAGS"
Packit 80c72f
Packit 80c72f
    AC_LANG_POP
Packit 80c72f
Packit 80c72f
  ])
Packit 80c72f
Packit 80c72f
  AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
Packit 80c72f
    :
Packit 80c72f
    $4
Packit 80c72f
  ],[
Packit 80c72f
    :
Packit 80c72f
    $5
Packit 80c72f
  ])
Packit 80c72f
])