# Sanity test a C compiler.
-# Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc.
#
# 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
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <limits.h>
- 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)
esac
])
+# BISON_LANG_COMPILER_POSIXLY_CORRECT
+# -----------------------------------
+# Whether the compiler for the current language supports -g in
+# POSIXLY_CORRECT mode. clang-2.9 on OS X does not, because
+# "clang-mp-2.9 -o test -g test.c" launches "/usr/bin/dsymutil test -o
+# test.dSYM" which fails with "error: unable to open executable '-o'".
+#
+# Sets <LANG>_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 compiler supports -g in POSIXLY_CORRECT mode. clang-2.9
-# on OS X does not, because "clang-mp-2.9 -o test -g test.c" launches
-# "/usr/bin/dsymutil test -o test.dSYM" which fails with "error:
-# unable to open executable '-o'".
-#
-# Sets C_COMPILER_POSIXLY_CORRECT to true/false.
+# Whether the C compiler supports -g in POSIXLY_CORRECT mode.
AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT],
-[AC_CACHE_CHECK([whether $CC supports POSIXLY_CORRECT=1],
- [bison_cv_cc_supports_posixly_correct],
-[BISON_CHECK_WITH_POSIXLY_CORRECT(
[AC_LANG_PUSH([C])
-AC_LINK_IFELSE([AC_LANG_PROGRAM],
- [bison_cv_cc_supports_posixly_correct=yes],
- [bison_cv_cc_supports_posixly_correct=no])
-AC_LANG_POP([C])])])
-case $bison_cv_cc_supports_posixly_correct in
- yes) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [true]) ;;
- no) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [false]);;
-esac
+BISON_LANG_COMPILER_POSIXLY_CORRECT
+AC_LANG_POP([C])
])