1# This program is free software; you can redistribute it and/or modify 2# it under the terms of the GNU General Public License as published by 3# the Free Software Foundation; either version 2 of the License, or 4# (at your option) any later version. 5# 6# This program is distributed in the hope that it will be useful, 7# but WITHOUT ANY WARRANTY; without even the implied warranty of 8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9# GNU General Public License for more details. 10# 11# You should have received a copy of the GNU General Public License 12# along with this program; if not, write to the Free Software 13# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 15# Originally from: 16# https://github.com/WinterMute/prboom/blob/master/autotools/ac_c_compile_flags.m4 17# RWMJ: I adapted it to add the extra parameters and fixed a few bugs. 18 19# AC_C_COMPILE_FLAGS(VAR, FLAGS TO TEST, [CFLAGS_FOR_TEST = $CFLAGS]) 20# ---------------------------------------------------------- 21# Check if compiler flag $2 is supported, if so add it to $1. 22# Extra CFLAGS for the test can be passed in $3. 23AC_DEFUN([AC_C_COMPILE_FLAGS],[ 24 CFLAGS_FOR_TEST="m4_default([$3], [$CFLAGS])" 25 for flag in $2 26 do 27 AC_MSG_CHECKING(whether the compiler supports $flag) 28 SAVED_CFLAGS="$CFLAGS" 29 CFLAGS="$CFLAGS_FOR_TEST $flag" 30 AC_COMPILE_IFELSE([AC_LANG_PROGRAM() 31 ],[ 32 AC_MSG_RESULT(yes) 33 $1="${$1} $flag" 34 ],[AC_MSG_RESULT(no)]) 35 CFLAGS="$SAVED_CFLAGS" 36 done 37]) 38