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