1dnl Process this file with autoconf to produce a configure script. 2AC_INIT(darts.cpp) 3AM_INIT_AUTOMAKE(darts, 0.32) 4 5dnl Checks for programs. 6AC_PROG_CC 7AC_PROG_CXX 8AC_PROG_MAKE_SET 9AC_LANG_CPLUSPLUS 10 11dnl Checks for libraries. 12 13dnl Checks for header files. 14AC_HEADER_STDC 15# AC_CHECK_HEADERS(string.h) 16 17dnl Checks for typedefs, structures, and compiler characteristics. 18AC_TYPE_OFF_T 19AC_TYPE_SIZE_T 20AC_CHECK_SIZEOF(char) 21AC_CHECK_SIZEOF(short) 22AC_CHECK_SIZEOF(int) 23AC_CHECK_SIZEOF(long) 24AC_CHECK_SIZEOF(long long) 25 26dnl 27dnl check gcc 28dnl 29if test -n "$GCC"; then 30 CFLAGS="-O3 -Wall" 31 CXXFLAGS="-O3 -Wall" 32fi 33 34dnl check C++ features 35dnl 36AC_DEFUN(CHECK_CXX_STL, [ 37 AC_MSG_CHECKING(if ${CXX-c++} supports stl <$1> (required)) 38 AC_TRY_COMPILE( 39 [ 40 #include <$1> 41 ], [ 42 ; 43 ], [ 44 ac_stl_$1=yes 45 ], [ 46 config_error=yes 47 AC_WARN(${CXX-c++} stl <$1> does not work) 48 ]) 49 AC_MSG_RESULT([$ac_stl_$1]) 50]) 51 52CHECK_CXX_STL(vector) 53CHECK_CXX_STL(cstdio) 54CHECK_CXX_STL(cstring) 55CHECK_CXX_STL(string) 56 57# check for namespaces 58AC_MSG_CHECKING(if ${CXX-c++} supports namespaces (required) ) 59AC_TRY_COMPILE( 60[ 61namespace Foo { struct A {}; } 62using namespace Foo; 63],[ 64A a; 65],[ 66 ac_namespaces=yes 67dnl AC_DEFINE(HAVE_CXX_NAMESPACE) 68],[ 69 config_error=yes 70 ac_namespaces=no 71]) 72AC_MSG_RESULT([$ac_namespaces]) 73 74# namespace 75if test "x$ac_namespaces" = xyes ; then 76AC_MSG_CHECKING(if ${CXX-c++} uses std namespace ) 77AC_TRY_COMPILE( 78[ 79#include <iostream> 80namespace std{} 81using namespace std; 82],[ 83cout << "test" << endl; 84],[ 85 ac_std_namespace=yes 86 AC_DEFINE(HAVE_CXX_STD_NAMESPACE) 87],[ 88 ac_std_namespace=maybe 89]) 90 91# std namespace 92if test "x$ac_std_namespace" = xmaybe ; then 93AC_TRY_COMPILE( 94[ 95#include <iostream.h> 96namespace std{} 97using namespace std; 98],[ 99cout << "test" << endl; 100],[ 101 ac_std_namespace=yes 102 AC_DEFINE(HAVE_CXX_STD_NAMESPACE) 103],[ 104 ac_std_namespace=no 105]) 106fi 107AC_MSG_RESULT([$ac_std_namespace]) 108fi 109 110dnl 111dnl check C++ features 112dnl 113AC_DEFUN(CHECK_CXX_STL, [ 114 AC_MSG_CHECKING(if ${CXX-c++} supports stl <$1> (required)) 115 AC_TRY_COMPILE( 116 [ 117 #include <$1> 118 ], [ 119 ; 120 ], [ 121 ac_stl_$1=yes 122 ], [ 123 config_error=yes 124 AC_WARN(${CXX-c++} stl <$1> does not work) 125 ]) 126 AC_MSG_RESULT([$ac_stl_$1]) 127]) 128 129AC_MSG_CHECKING(if ${CXX-c++} environment provides all required features) 130if test "x$config_error" = xyes ; then 131 AC_MSG_RESULT([no]) 132 AC_MSG_ERROR([Your compiler is not powerful enough to compile Darts. \ 133 If it should be, see config.log for more information of why it failed.]) 134fi 135AC_MSG_RESULT([yes]) 136 137DARTS_DEFAULT_ARRAY_SIZE=4 138DARTS_DEFAULT_NODE_SIZE=1 139 140DARTS_SIZEOF_CHAR=$ac_cv_sizeof_char 141DARTS_SIZEOF_SHORT=$ac_cv_sizeof_short 142DARTS_SIZEOF_INT=$ac_cv_sizeof_int 143DARTS_SIZEOF_LONG=$ac_cv_sizeof_long 144DARTS_SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long 145 146AC_SUBST(DARTS_DEFAULT_ARRAY_SIZE) 147AC_SUBST(DARTS_DEFAULT_NODE_SIZE) 148AC_SUBST(DARTS_SIZEOF_CHAR) 149AC_SUBST(DARTS_SIZEOF_SHORT) 150AC_SUBST(DARTS_SIZEOF_INT) 151AC_SUBST(DARTS_SIZEOF_LONG) 152AC_SUBST(DARTS_SIZEOF_LONG_LONG) 153 154DARTS_HAVE_ZLIB_H=0 155AC_ARG_WITH( 156 zlib, 157 [ --with-zlib use zlib] 158) 159 160if test "$with_zlib" != "no"; then 161 AC_CHECK_HEADERS(zlib.h) 162 AC_CHECK_LIB(z,gzopen) 163fi 164 165if test "$ac_cv_header_zlib_h" = "yes"; then 166 DARTS_HAVE_ZLIB_H=1 167fi 168AC_SUBST(DARTS_HAVE_ZLIB_H) 169 170AM_CONFIG_HEADER(config.h) 171AC_OUTPUT([Makefile tests/Makefile darts.h darts.spec]) 172