1 # bison-check-compile-flag.m4
5 # Copyright (C) 2018-2022 Free Software Foundation, Inc.
7 # This file is free software; the Free Software Foundation
8 # gives unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
13 # BISON_CHECK_COMPILER_FLAG(FLAG,
14 # [ACTION-SUCCESS], [ACTION-FAILURE],
16 # -------------------------------------------------------------
18 # Based on Autoconf Macro Archive's AX_CHECK_COMPILE_FLAG, but using
19 # AC_LINK_IFELSE, not just AC_COMPILE_IFELSE to capture failures such
22 # ./c++.at:401: $PREPARSER ./list
24 # ./list: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
26 # because we thought '-stdlib=c++' works, as it passes with AC_COMPILE_IFELSE.
28 # Not using AX_CHECK_LINK_FLAG, because its message is inappropriate:
30 # checking whether the linker accepts -std=c++11... yes
31 # checking whether the linker accepts -std=c++14... yes
32 # checking whether the linker accepts -std=c++17... no
33 AC_DEFUN([BISON_CHECK_COMPILER_FLAG],
34 [AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
35 AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
36 AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
37 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
38 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
39 AC_LINK_IFELSE([m4_default([$5], [AC_LANG_PROGRAM()])],
40 [AS_VAR_SET(CACHEVAR,[yes])],
41 [AS_VAR_SET(CACHEVAR,[no])])
42 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
43 AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [$2], [$3])
44 AS_VAR_POPDEF([CACHEVAR])dnl
45 ])dnl BISON_CHECK_COMPILER_FLAGS