X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/498e897c67d09b6ea955a3678ce9d0b0c6e0a4c2..3fd1d6b2f36722c64f8db77400c6f6a2639ebae0:/m4/c-working.m4?ds=sidebyside diff --git a/m4/c-working.m4 b/m4/c-working.m4 index ec74035b..999c52de 100644 --- a/m4/c-working.m4 +++ b/m4/c-working.m4 @@ -1,10 +1,10 @@ # Sanity test a C compiler. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify +# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -13,9 +13,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301 USA +# along with this program. If not, see . # Written by Paul Eggert. @@ -23,7 +21,59 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include - int test_array[CHAR_BIT];]])], + int test_array[CHAR_BIT];]])], [], [AC_MSG_FAILURE([cannot compile a simple C program])]) + AC_SUBST([BISON_C_WORKS], [:]) +]) + +# BISON_CHECK_WITH_POSIXLY_CORRECT(CODE) +# -------------------------------------- +# Run the Autoconf CODE with POSIXLY_CORRECT set to 1, and restored to +# its initial value afterwards. +AC_DEFUN([BISON_CHECK_WITH_POSIXLY_CORRECT], +[gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' +case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" _COMPILER_POSIXLY_CORRECT to true/false. +AC_DEFUN([BISON_LANG_COMPILER_POSIXLY_CORRECT], +[AC_CACHE_CHECK([whether $_AC_CC supports POSIXLY_CORRECT=1], + [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct], +[BISON_CHECK_WITH_POSIXLY_CORRECT( +[AC_LINK_IFELSE([AC_LANG_PROGRAM], + [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=yes], + [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=no])])]) +case $bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct in + yes) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [true]) ;; + no) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [false]);; +esac +]) + +# BISON_C_COMPILER_POSIXLY_CORRECT +# -------------------------------- +# Whether the C compiler supports -g in POSIXLY_CORRECT mode. +AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT], +[AC_LANG_PUSH([C]) +BISON_LANG_COMPILER_POSIXLY_CORRECT +AC_LANG_POP([C]) ])