Blame m4/ax_c_check_flag.m4

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