]> git.saurik.com Git - bison.git/blame - m4/c-working.m4
xml: match DOT output and xml2dot.xsl processing
[bison.git] / m4 / c-working.m4
CommitLineData
498e897c
PE
1# Sanity test a C compiler.
2
c932d613 3# Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
498e897c 4#
f16b0819 5# This program is free software: you can redistribute it and/or modify
498e897c 6# it under the terms of the GNU General Public License as published by
f16b0819 7# the Free Software Foundation, either version 3 of the License, or
498e897c
PE
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
f16b0819 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
498e897c
PE
17
18# Written by Paul Eggert.
19
20AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
21 AC_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [[#include <limits.h>
24 int test_array[CHAR_BIT];]])],
25 [],
26 [AC_MSG_FAILURE([cannot compile a simple C program])])
27])
0a36880a
AD
28
29# BISON_CHECK_WITH_POSIXLY_CORRECT(CODE)
30# --------------------------------------
31# Run the Autoconf CODE with POSIXLY_CORRECT set to 1, and restored to
32# its initial value afterwards.
33AC_DEFUN([BISON_CHECK_WITH_POSIXLY_CORRECT],
34[gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
35case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
36 xx) gl_had_POSIXLY_CORRECT=exported ;;
37 x) gl_had_POSIXLY_CORRECT=yes ;;
38 *) gl_had_POSIXLY_CORRECT= ;;
39esac
40POSIXLY_CORRECT=1
41export POSIXLY_CORRECT
42$1
43case $gl_had_POSIXLY_CORRECT in
44 exported) ;;
45 yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
46 *) AS_UNSET([POSIXLY_CORRECT]) ;;
47esac
48])
49
50# BISON_C_COMPILER_POSIXLY_CORRECT
51# --------------------------------
52# Whether the compiler supports -g in POSIXLY_CORRECT mode. clang-2.9
53# on OS X does not, because "clang-mp-2.9 -o test -g test.c" launches
54# "/usr/bin/dsymutil test -o test.dSYM" which fails with "error:
55# unable to open executable '-o'".
56#
57# Sets C_COMPILER_POSIXLY_CORRECT to true/false.
58AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT],
59[AC_CACHE_CHECK([whether $CC supports POSIXLY_CORRECT=1],
60 [bison_cv_cc_supports_posixly_correct],
61[BISON_CHECK_WITH_POSIXLY_CORRECT(
62[AC_LANG_PUSH([C])
63AC_LINK_IFELSE([AC_LANG_PROGRAM],
64 [bison_cv_cc_supports_posixly_correct=yes],
65 [bison_cv_cc_supports_posixly_correct=no])
66AC_LANG_POP([C])])])
67case $bison_cv_cc_supports_posixly_correct in
68 yes) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [true]) ;;
69 no) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [false]);;
70esac
71])