]>
Commit | Line | Data |
---|---|---|
498e897c PE |
1 | # Sanity test a C compiler. |
2 | ||
34136e65 | 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 | ||
20 | AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [ | |
21 | AC_COMPILE_IFELSE( | |
22 | [AC_LANG_PROGRAM( | |
23 | [[#include <limits.h> | |
e9690142 | 24 | int test_array[CHAR_BIT];]])], |
498e897c PE |
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. | |
33 | AC_DEFUN([BISON_CHECK_WITH_POSIXLY_CORRECT], | |
34 | [gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' | |
35 | case ${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= ;; | |
39 | esac | |
40 | POSIXLY_CORRECT=1 | |
41 | export POSIXLY_CORRECT | |
42 | $1 | |
43 | case $gl_had_POSIXLY_CORRECT in | |
44 | exported) ;; | |
45 | yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;; | |
46 | *) AS_UNSET([POSIXLY_CORRECT]) ;; | |
47 | esac | |
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. | |
58 | AC_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]) | |
63 | AC_LINK_IFELSE([AC_LANG_PROGRAM], | |
64 | [bison_cv_cc_supports_posixly_correct=yes], | |
65 | [bison_cv_cc_supports_posixly_correct=no]) | |
66 | AC_LANG_POP([C])])]) | |
67 | case $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]);; | |
70 | esac | |
71 | ]) |