]>
Commit | Line | Data |
---|---|---|
498e897c PE |
1 | # Sanity test a C compiler. |
2 | ||
7d6bad19 | 3 | # Copyright (C) 2006, 2009-2013 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])]) | |
d4728d92 | 27 | AC_SUBST([BISON_C_WORKS], [:]) |
498e897c | 28 | ]) |
0a36880a AD |
29 | |
30 | # BISON_CHECK_WITH_POSIXLY_CORRECT(CODE) | |
31 | # -------------------------------------- | |
32 | # Run the Autoconf CODE with POSIXLY_CORRECT set to 1, and restored to | |
33 | # its initial value afterwards. | |
34 | AC_DEFUN([BISON_CHECK_WITH_POSIXLY_CORRECT], | |
35 | [gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' | |
36 | case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in | |
37 | xx) gl_had_POSIXLY_CORRECT=exported ;; | |
38 | x) gl_had_POSIXLY_CORRECT=yes ;; | |
39 | *) gl_had_POSIXLY_CORRECT= ;; | |
40 | esac | |
41 | POSIXLY_CORRECT=1 | |
42 | export POSIXLY_CORRECT | |
43 | $1 | |
44 | case $gl_had_POSIXLY_CORRECT in | |
45 | exported) ;; | |
46 | yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;; | |
47 | *) AS_UNSET([POSIXLY_CORRECT]) ;; | |
48 | esac | |
49 | ]) | |
50 | ||
d4728d92 AD |
51 | # BISON_LANG_COMPILER_POSIXLY_CORRECT |
52 | # ----------------------------------- | |
53 | # Whether the compiler for the current language supports -g in | |
54 | # POSIXLY_CORRECT mode. clang-2.9 on OS X does not, because | |
55 | # "clang-mp-2.9 -o test -g test.c" launches "/usr/bin/dsymutil test -o | |
56 | # test.dSYM" which fails with "error: unable to open executable '-o'". | |
57 | # | |
58 | # Sets <LANG>_COMPILER_POSIXLY_CORRECT to true/false. | |
59 | AC_DEFUN([BISON_LANG_COMPILER_POSIXLY_CORRECT], | |
60 | [AC_CACHE_CHECK([whether $_AC_CC supports POSIXLY_CORRECT=1], | |
61 | [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct], | |
62 | [BISON_CHECK_WITH_POSIXLY_CORRECT( | |
63 | [AC_LINK_IFELSE([AC_LANG_PROGRAM], | |
64 | [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=yes], | |
65 | [bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=no])])]) | |
66 | case $bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct in | |
67 | yes) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [true]) ;; | |
68 | no) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [false]);; | |
69 | esac | |
70 | ]) | |
71 | ||
0a36880a AD |
72 | # BISON_C_COMPILER_POSIXLY_CORRECT |
73 | # -------------------------------- | |
d4728d92 | 74 | # Whether the C compiler supports -g in POSIXLY_CORRECT mode. |
0a36880a | 75 | AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT], |
0a36880a | 76 | [AC_LANG_PUSH([C]) |
d4728d92 AD |
77 | BISON_LANG_COMPILER_POSIXLY_CORRECT |
78 | AC_LANG_POP([C]) | |
0a36880a | 79 | ]) |