From: Reid Spencer Date: Tue, 7 Sep 2004 06:56:14 +0000 (+0000) Subject: Individual autoconf function broken out of acincludes.m4. This change X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=491f6812ef173989612d987fa8706fd38e2e673f;p=oota-llvm.git Individual autoconf function broken out of acincludes.m4. This change per the recommended style guide for autoconf and so that individual autoconf functions can more easily be shared across projects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16223 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/autoconf/m4/bison.m4 b/autoconf/m4/bison.m4 new file mode 100644 index 00000000000..60fcb6d78af --- /dev/null +++ b/autoconf/m4/bison.m4 @@ -0,0 +1,18 @@ +# +# Check for Bison. +# +# This macro verifies that Bison is installed. If successful, then +# 1) YACC is set to bison -y (to emulate YACC calls) +# 2) BISON is set to bison +# +AC_DEFUN([AC_PROG_BISON], +[AC_CACHE_CHECK(, +ac_cv_has_bison, +[AC_PROG_YACC() +]) +if test "$YACC" != "bison -y"; then + AC_MSG_ERROR([bison not found but required]) +else + AC_SUBST(BISON,[bison],[location of bison]) +fi +]) diff --git a/autoconf/m4/c_printf_a.m4 b/autoconf/m4/c_printf_a.m4 new file mode 100644 index 00000000000..62ed2ac8d75 --- /dev/null +++ b/autoconf/m4/c_printf_a.m4 @@ -0,0 +1,31 @@ +# +# Determine if the printf() functions have the %a format character. +# This is modified from: +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html +AC_DEFUN([AC_C_PRINTF_A], +[ + AC_MSG_CHECKING([for printf %a format specifier]) + AC_LANG_SAVE + AC_LANG_C + AC_RUN_IFELSE( + AC_LANG_PROGRAM([#include + #include ], + [[[ + volatile double A, B; + char Buffer[100]; + A = 1; + A /= 10.0; + sprintf(Buffer, "%a", A); + B = atof(Buffer); + if (A != B) + return (1); + if (A != 0x1.999999999999ap-4) + return (1); + return (0);]]]), + ac_c_printf_a=yes,ac_c_printf_a=no) + AC_LANG_RESTORE + AC_MSG_RESULT($ac_c_printf_a) + if test "$ac_c_printf_a" = "yes"; then + AC_DEFINE([HAVE_PRINTF_A],[1],[Define to have the %a format string]) + fi +]) diff --git a/autoconf/m4/check_gnu_make.m4 b/autoconf/m4/check_gnu_make.m4 new file mode 100644 index 00000000000..cb107d223a0 --- /dev/null +++ b/autoconf/m4/check_gnu_make.m4 @@ -0,0 +1,25 @@ +# +# Check for GNU Make. This is from +# http://www.gnu.org/software/ac-archive/htmldoc/check_gnu_make.html +# +AC_DEFUN([AC_CHECK_GNU_MAKE], +[ AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command, + _cv_gnu_make_command='' ; +dnl Search all the common names for GNU make + for a in "$MAKE" make gmake gnumake ; do + if test -z "$a" ; then continue ; fi ; + if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then + _cv_gnu_make_command=$a ; + break; + fi + done ; + ) ; +dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise + if test "x$_cv_gnu_make_command" != "x" ; then + ifGNUmake='' ; + else + ifGNUmake='#' ; + AC_MSG_RESULT("Not found"); + fi + AC_SUBST(ifGNUmake) +]) diff --git a/autoconf/m4/config_makefile.m4 b/autoconf/m4/config_makefile.m4 new file mode 100644 index 00000000000..e30f1876201 --- /dev/null +++ b/autoconf/m4/config_makefile.m4 @@ -0,0 +1,7 @@ +# +# Configure a Makefile without clobbering it if it exists and is not out of +# date. This macro is unique to LLVM. +# +AC_DEFUN([AC_CONFIG_MAKEFILE], +[AC_CONFIG_COMMANDS($1,${SHELL} ${srcdir}/autoconf/install-sh -c ${srcdir}/$1 $1,${srcdir}/autoconf/mkinstalldirs `dirname $1`) +]) diff --git a/autoconf/m4/cxx_bidi_iterator.m4 b/autoconf/m4/cxx_bidi_iterator.m4 new file mode 100644 index 00000000000..e16976d389e --- /dev/null +++ b/autoconf/m4/cxx_bidi_iterator.m4 @@ -0,0 +1,23 @@ +# +# Check for bidirectional iterator extension. This is modified from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html +# +AC_DEFUN([AC_CXX_HAVE_BI_ITERATOR], +[AC_CACHE_CHECK(whether the compiler has the bidirectional iterator, +ac_cv_cxx_have_bi_iterator, +[AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[bidirectional_iterator t; return 0;], + ac_cv_cxx_have_bi_iterator=yes, ac_cv_cxx_have_bi_iterator=no) + AC_LANG_RESTORE +]) +HAVE_BI_ITERATOR=0 +if test "$ac_cv_cxx_have_bi_iterator" = yes +then + HAVE_BI_ITERATOR=1 +fi +AC_SUBST(HAVE_BI_ITERATOR)]) diff --git a/autoconf/m4/cxx_fwd_iterator.m4 b/autoconf/m4/cxx_fwd_iterator.m4 new file mode 100644 index 00000000000..8da2944b91c --- /dev/null +++ b/autoconf/m4/cxx_fwd_iterator.m4 @@ -0,0 +1,23 @@ +# Check for forward iterator extension. This is modified from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html +AC_DEFUN([AC_CXX_HAVE_FWD_ITERATOR], +[AC_CACHE_CHECK(whether the compiler has forward iterators, +ac_cv_cxx_have_fwd_iterator, +[AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[forward_iterator t; return 0;], + ac_cv_cxx_have_fwd_iterator=yes, ac_cv_cxx_have_fwd_iterator=no) + AC_LANG_RESTORE +]) +HAVE_FWD_ITERATOR=0 +if test "$ac_cv_cxx_have_fwd_iterator" = yes +then + HAVE_FWD_ITERATOR=1 +fi +AC_SUBST(HAVE_FWD_ITERATOR)]) + + diff --git a/autoconf/m4/cxx_hash_map.m4 b/autoconf/m4/cxx_hash_map.m4 new file mode 100644 index 00000000000..4cc45f9f0aa --- /dev/null +++ b/autoconf/m4/cxx_hash_map.m4 @@ -0,0 +1,62 @@ +# Check for hash_map extension. This is from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_map.html +AC_DEFUN([AC_CXX_HAVE_STD_EXT_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has defining template class std::hash_map], + ac_cv_cxx_have_std_ext_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[hash_map t;], + [ac_cv_cxx_have_std_ext_hash_map=yes], [ac_cv_cxx_have_std_ext_hash_map=no]) + AC_LANG_RESTORE]) + HAVE_STD_EXT_HASH_MAP=0 + if test "$ac_cv_cxx_have_std_ext_hash_map" = yes + then + HAVE_STD_EXT_HASH_MAP=1 + fi + AC_SUBST(HAVE_STD_EXT_HASH_MAP)]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has defining template class __gnu_cxx::hash_map], + ac_cv_cxx_have_gnu_ext_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace __gnu_cxx; +#endif],[hash_map t; ], + [ac_cv_cxx_have_gnu_ext_hash_map=yes],[ac_cv_cxx_have_gnu_ext_hash_map=no]) + AC_LANG_RESTORE]) + HAVE_GNU_EXT_HASH_MAP=0 + if test "$ac_cv_cxx_have_gnu_ext_hash_map" = yes + then + HAVE_GNU_EXT_HASH_MAP=1 + fi + AC_SUBST(HAVE_GNU_EXT_HASH_MAP)]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has defining template class ::hash_map], + ac_cv_cxx_have_global_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include ],[hash_map t; ], + [ac_cv_cxx_have_global_hash_map=yes], [ac_cv_cxx_have_global_hash_map=no]) + AC_LANG_RESTORE]) + HAVE_GLOBAL_HASH_MAP=0 + if test "$ac_cv_cxx_have_global_hash_map" = yes + then + HAVE_GLOBAL_HASH_MAP=1 + fi + AC_SUBST(HAVE_GLOBAL_HASH_MAP)]) + +AC_DEFUN([AC_CXX_HAVE_HASH_MAP], +[AC_CXX_HAVE_STD_EXT_HASH_MAP + AC_CXX_HAVE_GNU_EXT_HASH_MAP + AC_CXX_HAVE_GLOBAL_HASH_MAP]) + + diff --git a/autoconf/m4/cxx_hash_set.m4 b/autoconf/m4/cxx_hash_set.m4 new file mode 100644 index 00000000000..0e736d9a7d5 --- /dev/null +++ b/autoconf/m4/cxx_hash_set.m4 @@ -0,0 +1,63 @@ +# Check for hash_set extension. This is modified from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html +AC_DEFUN([AC_CXX_HAVE_STD_EXT_HASH_SET], +[AC_CACHE_CHECK([whether the compiler has defining template class std::hash_set], + ac_cv_cxx_have_std_ext_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[hash_set t; ], + [ac_cv_cxx_have_std_ext_hash_set=yes], [ac_cv_cxx_have_std_ext_hash_set=no]) + AC_LANG_RESTORE]) + HAVE_STD_EXT_HASH_SET=0 + if test "$ac_cv_cxx_have_std_ext_hash_set" = yes + then + HAVE_STD_EXT_HASH_SET=1 + fi + AC_SUBST(HAVE_STD_EXT_HASH_SET)]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_SET], +[AC_CACHE_CHECK( + [whether the compiler has defining template class __gnu_cxx::hash_set], + ac_cv_cxx_have_gnu_ext_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace __gnu_cxx; +#endif],[hash_set t; ], + [ac_cv_cxx_have_gnu_ext_hash_set=yes], [ac_cv_cxx_have_gnu_ext_hash_set=no]) + AC_LANG_RESTORE]) + HAVE_GNU_EXT_HASH_SET=0 + if test "$ac_cv_cxx_have_gnu_ext_hash_set" = yes + then + HAVE_GNU_EXT_HASH_SET=1 + fi + AC_SUBST(HAVE_GNU_EXT_HASH_SET)]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_SET], +[AC_CACHE_CHECK([whether the compiler has defining template class ::hash_set], + ac_cv_cxx_have_global_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include ],[hash_set t; return 0;], + [ac_cv_cxx_have_global_hash_set=yes], [ac_cv_cxx_have_global_hash_set=no]) + AC_LANG_RESTORE]) + HAVE_GLOBAL_HASH_SET=0 + if test "$ac_cv_cxx_have_global_hash_set" = yes + then + HAVE_GLOBAL_HASH_SET=1 + fi + AC_SUBST(HAVE_GLOBAL_HASH_SET)]) + +AC_DEFUN([AC_CXX_HAVE_HASH_SET], +[AC_CXX_HAVE_STD_EXT_HASH_SET + AC_CXX_HAVE_GNU_EXT_HASH_SET + AC_CXX_HAVE_GLOBAL_HASH_SET]) + + diff --git a/autoconf/m4/cxx_namespaces.m4 b/autoconf/m4/cxx_namespaces.m4 new file mode 100644 index 00000000000..756e378f7f7 --- /dev/null +++ b/autoconf/m4/cxx_namespaces.m4 @@ -0,0 +1,18 @@ +# Check for C++ namespace support. This is from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_namespaces.html +# +AC_DEFUN([AC_CXX_NAMESPACES], +[AC_CACHE_CHECK(whether the compiler implements namespaces, +ac_cv_cxx_namespaces, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], + [using namespace Outer::Inner; return i;], + ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_namespaces" = yes; then + AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces]) +fi +]) + diff --git a/autoconf/m4/cxx_std_iterator.m4 b/autoconf/m4/cxx_std_iterator.m4 new file mode 100644 index 00000000000..46665f2867e --- /dev/null +++ b/autoconf/m4/cxx_std_iterator.m4 @@ -0,0 +1,23 @@ +# Check for standard iterator extension. This is modified from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html +AC_DEFUN([AC_CXX_HAVE_STD_ITERATOR], +[AC_CACHE_CHECK(whether the compiler has the standard iterator, +ac_cv_cxx_have_std_iterator, +[AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[iterator t; return 0;], + ac_cv_cxx_have_std_iterator=yes, ac_cv_cxx_have_std_iterator=no) + AC_LANG_RESTORE +]) +HAVE_STD_ITERATOR=0 +if test "$ac_cv_cxx_have_std_iterator" = yes +then + HAVE_STD_ITERATOR=1 +fi +AC_SUBST(HAVE_STD_ITERATOR)]) + + diff --git a/autoconf/m4/flex.m4 b/autoconf/m4/flex.m4 new file mode 100644 index 00000000000..5cb3dc4f8fd --- /dev/null +++ b/autoconf/m4/flex.m4 @@ -0,0 +1,17 @@ +# +# Check for FLEX. +# +# This macro verifies that flex is installed. If successful, then +# 1) $LEX is set to "flex" (to emulate lex calls) +# 2) BISON is set to bison +AC_DEFUN([AC_PROG_FLEX], +[AC_CACHE_CHECK(, +ac_cv_has_flex, +[AC_PROG_LEX() +]) +if test "$LEX" != "flex"; then + AC_MSG_ERROR([flex not found but required]) +else + AC_SUBST(FLEX,[flex],[location of flex]) +fi +]) diff --git a/autoconf/m4/func_mmap_file.m4 b/autoconf/m4/func_mmap_file.m4 new file mode 100644 index 00000000000..707a1d1b5f9 --- /dev/null +++ b/autoconf/m4/func_mmap_file.m4 @@ -0,0 +1,32 @@ +# +# Check for the ability to mmap a file. +# +AC_DEFUN([AC_FUNC_MMAP_FILE], +[AC_CACHE_CHECK(for mmap of files, +ac_cv_func_mmap_file, +[AC_LANG_SAVE + AC_LANG_C + AC_TRY_RUN([ +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif + + int fd; + int main () { + fd = creat ("foo",0777); fd = (int) mmap (0, 1, PROT_READ, MAP_SHARED, fd, 0); unlink ("foo"); return (fd != (int) MAP_FAILED);}], + ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_func_mmap_file" = yes; then + AC_DEFINE([HAVE_MMAP_FILE],[],[Define if mmap() can map files into memory]) + AC_SUBST(MMAP_FILE,[yes]) +fi +]) diff --git a/autoconf/m4/header_mmap_anonymous.m4 b/autoconf/m4/header_mmap_anonymous.m4 new file mode 100644 index 00000000000..409189b0ee0 --- /dev/null +++ b/autoconf/m4/header_mmap_anonymous.m4 @@ -0,0 +1,22 @@ +# +# Check for anonymous mmap macros. This is modified from +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html +# +AC_DEFUN([AC_HEADER_MMAP_ANONYMOUS], +[AC_CACHE_CHECK(for MAP_ANONYMOUS vs. MAP_ANON, +ac_cv_header_mmap_anon, +[AC_LANG_SAVE + AC_LANG_C + AC_TRY_COMPILE([#include + #include + #include ], + [mmap (0, 1, PROT_READ, MAP_ANONYMOUS, -1, 0); return (0);], + ac_cv_header_mmap_anon=yes, ac_cv_header_mmap_anon=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_header_mmap_anon" = yes; then + AC_DEFINE([HAVE_MMAP_ANONYMOUS],[],[Define if mmap() uses MAP_ANONYMOUS to map anonymous pages, or undefine if it uses MAP_ANON]) +fi +]) + + diff --git a/autoconf/m4/link_use_r.m4 b/autoconf/m4/link_use_r.m4 new file mode 100644 index 00000000000..e553e7e5889 --- /dev/null +++ b/autoconf/m4/link_use_r.m4 @@ -0,0 +1,23 @@ +# +# Determine if the system can handle the -R option being passed to the linker. +# +# This macro is specific to LLVM. +# +AC_DEFUN([AC_LINK_USE_R], +[ + AC_MSG_CHECKING([for compiler -Wl,-R option]) + AC_LANG_SAVE + AC_LANG_C + oldcflags="$CFLAGS" + CFLAGS="$CFLAGS -Wl,-R." + AC_LINK_IFELSE([int main() { return 0; }],[ac_cv_link_use_r=yes],[ac_cv_link_use_r=no]) + CFLAGS="$oldcflags" + AC_LANG_RESTORE + AC_MSG_RESULT($ac_cv_link_use_r) + if test "$ac_cv_link_use_r" = yes + then + AC_DEFINE([HAVE_LINK_R],[1],[Define if you can use -Wl,-R. to pass -R. to the linker, in order to add the current directory to the dynamic linker search path.]) + fi +]) + + diff --git a/autoconf/m4/single_cxx_check.m4 b/autoconf/m4/single_cxx_check.m4 new file mode 100644 index 00000000000..c5e4b199c67 --- /dev/null +++ b/autoconf/m4/single_cxx_check.m4 @@ -0,0 +1,48 @@ +dnl AC_SINGLE_CXX_CHECK(DEFINEVAR, CACHEVAR, FUNCTION, HEADER, PROGRAM) +dnl $1, $2, $3, $4, $5 +dnl +AC_DEFUN([AC_SINGLE_CXX_CHECK], +[AC_CACHE_CHECK([for $3 in $4], [$2], + [AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE(AC_LANG_SOURCE([$5]),[$2=yes],[$2=no]) + AC_LANG_POP(C++)]) + if test "$$2" = "yes" + then + AC_DEFINE($1, 1, [Define to 1 if your compiler defines $3 in the $4 + header file.]) + fi]) + +AC_DEFUN([AC_FUNC_ISNAN],[ +AC_SINGLE_CXX_CHECK([HAVE_ISNAN_IN_MATH_H], [ac_cv_func_isnan_in_math_h], + [isnan], [], + [#include + int foo(float f) {return isnan(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_ISNAN_IN_CMATH], [ac_cv_func_isnan_in_cmath], + [isnan], [], + [#include + int foo(float f) {return isnan(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_STD_ISNAN_IN_CMATH], [ac_cv_func_std_isnan_in_cmath], + [std::isnan], [], + [#include + using std::isnan; int foo(float f) {return isnan(f);}]) +]) + +AC_DEFUN([AC_FUNC_ISINF],[ +AC_SINGLE_CXX_CHECK([HAVE_ISINF_IN_MATH_H], [ac_cv_func_isinf_in_math_h], + [isinf], [], + [#include + int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_ISINF_IN_CMATH], [ac_cv_func_isinf_in_cmath], + [isinf], [], + [#include + int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_STD_ISINF_IN_CMATH], [ac_cv_func_std_isinf_in_cmath], + [std::isinf], [], + [#include + using std::isinf; int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_FINITE_IN_IEEEFP_H], [ac_cv_func_finite_in_ieeefp_h], + [finite], [], + [#include + int foo(float f) {return finite(f);}]) +]) +