Blame m4/ax_ld_check_flag.m4

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