1dnl Process this file with autoconf to produce a configure script. 2AC_INIT(crf_learn.cpp) 3AH_TEMPLATE([HAVE_TLS_KEYWORD], []) 4AH_TEMPLATE([HAVE_SYS_CONF_SC_NPROCESSORS_CONF], []) 5AM_INIT_AUTOMAKE(CRF++, 0.59) 6 7dnl Checks for programs. 8AC_PROG_CC 9AC_PROG_CXX 10AC_PROG_GCC_TRADITIONAL 11AC_PROG_MAKE_SET 12AC_ISC_POSIX 13AC_CYGWIN 14AC_LANG_CPLUSPLUS 15AC_PROG_LIBTOOL 16AC_CONFIG_MACRO_DIR([m4]) 17 18dnl Checks for libraries. 19 20dnl Checks for header files. 21AC_HEADER_STDC 22AC_CHECK_HEADERS(string.h stdlib.h unistd.h fcntl.h \ 23 sys/stat.h sys/mman.h sys/times.h \ 24 ctype.h sys/types.h math.h pthread.h) 25 26AC_TYPE_SIZE_T 27 28dnl Checks for libraries. 29AC_CHECK_LIB(m,pow) 30AC_CHECK_LIB(m,exp) 31AC_CHECK_LIB(m,log) 32AC_CHECK_LIB(pthread,pthread_create) 33AC_CHECK_LIB(pthread,pthread_join) 34AC_FUNC_MMAP 35 36dnl 37dnl Check for GNU make 38dnl 39AC_MSG_CHECKING(whether make is GNU Make) 40if $ac_make --version 2>/dev/null | grep '^GNU Make ' >/dev/null ; then 41 AC_MSG_RESULT(yes) 42else 43 AC_MSG_RESULT(no) 44 if test "$host_vendor" = "sun" ; then 45 AC_MSG_ERROR("SUN make does not work for building maxent. Please install GNU make") 46 fi 47fi 48 49dnl 50dnl check gcc 51dnl 52if test -n "$GCC"; then 53 CFLAGS="-O3 -Wall"; 54 CXXFLAGS="-O3 -Wall"; 55fi 56 57AC_DEFUN(ADD_CC_FLAG, [ 58 AC_MSG_CHECKING(whether ${CC-cc} accepts $1) 59 AC_LANG_SAVE 60 AC_LANG_C 61 XCFLAGS="$CFLAGS" 62 CFLAGS="$CFLAGS $1" 63 AC_TRY_LINK([], [], 64 [AC_MSG_RESULT([ ok, adding $1 to CFLAGS])], 65 [CFLAGS="$XCFLAGS"]) 66 AC_LANG_RESTORE 67]) 68 69AC_DEFUN(ADD_CXX_FLAG, [ 70 AC_MSG_CHECKING(whether ${CXX-c++} accepts $1) 71 AC_LANG_SAVE 72 AC_LANG_CPLUSPLUS 73 XCXXFLAGS="$CXXFLAGS" 74 CXXFLAGS="$CXXFLAGS $1" 75 AC_TRY_LINK([], [], 76 [AC_MSG_RESULT([ ok, adding $1 to CXXFLAGS])], 77 [CXXFLAGS="$XCXXFLAGS"]) 78 AC_LANG_RESTORE 79]) 80 81# On Intel systems with gcc, we may need to compile with -mieee-fp to 82# get full support for IEEE floating point. 83# 84# On Alpha/OSF systems, we need -mieee. 85# 86# On AIX systems, we need to limit the amount of stuff that goes in 87# the TOC. 88case "$host" in 89changequote(,)dnl 90 i[3456789]86-*-*) 91changequote([,])dnl 92 ADD_CC_FLAG(-mieee-fp) 93 ADD_CXX_FLAG(-mieee-fp) 94 ;; 95 alpha*-*-*) 96 ADD_CC_FLAG(-mieee) 97 ADD_CXX_FLAG(-mieee) 98 ;; 99 *ibm-aix4*) 100 ADD_CC_FLAG(-mminimal-toc) 101 ADD_CXX_FLAG(-mminimal-toc) 102 ;; 103esac 104 105dnl 106dnl check C++ features 107dnl 108AC_DEFUN(CHECK_CXX_STL, [ 109 AC_MSG_CHECKING(if ${CXX-c++} supports stl <$1> (required)) 110 AC_TRY_COMPILE( 111 [ 112 #include <$1> 113 ], [ 114 ; 115 ], [ 116 ac_stl_$1=yes 117 ], [ 118 config_error=yes 119 AC_WARN(${CXX-c++} stl <$1> does not work) 120 ]) 121 AC_MSG_RESULT([$ac_stl_$1]) 122]) 123 124CHECK_CXX_STL(string) 125CHECK_CXX_STL(vector) 126CHECK_CXX_STL(map) 127CHECK_CXX_STL(set) 128CHECK_CXX_STL(iostream) 129CHECK_CXX_STL(fstream) 130CHECK_CXX_STL(sstream) 131CHECK_CXX_STL(stdexcept) 132 133# check for const_cast 134AC_MSG_CHECKING([if ${CXX-c++} supports template <class T> (required)]) 135AC_TRY_COMPILE( 136[ 137 template <class T> T foo (T &i) { return i++; }; 138],[ 139 int i = 0; 140 double d = 0.0; 141 foo(i); foo(d); 142],[ 143 ac_template=yes 144],[ 145 AC_WARN(${CXX-c++} template <class T> does not work) 146 config_error=yes 147]) 148AC_MSG_RESULT([$ac_template]) 149 150# check for const_cast 151AC_MSG_CHECKING([if ${CXX-c++} supports const_cast<> (required)]) 152AC_TRY_COMPILE( 153[ 154 class foo; 155],[ 156 const foo *c=0; 157 foo *c1=const_cast<foo*>(c); 158],[ 159 ac_const_cast=yes 160],[ 161 AC_WARN(${CXX-c++} const_cast<> does not work) 162 config_error=yes 163]) 164AC_MSG_RESULT([$ac_const_cast]) 165 166# check for static_cast<> 167AC_MSG_CHECKING(if ${CXX-c++} supports static_cast<> (required)) 168AC_TRY_COMPILE( 169[ 170 class foo; 171],[ 172 foo *c = 0; 173 void *c1 = static_cast<void *>(c); 174],[ 175 ac_static_cast=yes 176],[ 177 AC_WARN(${CXX-c++} static_cast<> does not work) 178 config_error=yes 179]) 180AC_MSG_RESULT([$ac_static_cast]) 181 182# check for dynamic_cast<> 183AC_MSG_CHECKING(if ${CXX-c++} supports dynamic_cast<> (required)) 184AC_TRY_COMPILE( 185[ 186 class foo {}; 187 class bar: public foo {}; 188],[ 189 bar *c = 0; 190 foo *c1 = dynamic_cast<foo *>(c); 191],[ 192 ac_dynamic_cast=yes 193],[ 194 AC_WARN(${CXX-c++} dynamic_cast<> does not work) 195 config_error=yes 196]) 197AC_MSG_RESULT([$ac_dynamic_cast]) 198 199# check for try 200AC_MSG_CHECKING(if ${CXX-c++} supports exception handler (required)) 201AC_TRY_COMPILE( 202[ 203 ; 204],[ 205 try { 206 int i = 0; 207 } 208 catch (char *e) { 209 } 210 catch (...) { 211 } 212],[ 213 ac_exception=yes 214],[ 215 AC_WARN(${CXX-c++} exception does not work) 216 config_error=yes 217]) 218AC_MSG_RESULT([$ac_exception]) 219 220# check for namespaces 221AC_MSG_CHECKING(if ${CXX-c++} supports namespaces (required) ) 222AC_TRY_COMPILE( 223[ 224namespace Foo { struct A {}; } 225using namespace Foo; 226],[ 227A a; 228],[ 229 ac_namespaces=yes 230dnl AC_DEFINE(HAVE_CXX_NAMESPACE) 231],[ 232 config_error=yes 233 ac_namespaces=no 234]) 235AC_MSG_RESULT([$ac_namespaces]) 236 237 238dnl __thread keyword 239AC_MSG_CHECKING([if ${CXX-c++} supports __thread (optional)]) 240AC_TRY_COMPILE( 241[ 242__thread int a = 0; 243],[ 244 a = 10; 245],[ 246 enable_tls=yes 247],[ 248 enable_tls=no 249]) 250AC_MSG_RESULT([$enable_tls]) 251 252if test "$enable_tls" = "no"; then 253AC_MSG_WARN([__thread keyword is not supported on this environment. \ 254Error handling of CRF++, e.g., CRFPP::getLastError(), is not thread safe.]) 255else 256AC_DEFINE([HAVE_TLS_KEYWORD]) 257fi 258 259AC_MSG_CHECKING([if ${CXX-c++} supports _SC_NPROCESSORS_CONF (optional)]) 260AC_TRY_COMPILE( 261[ 262 #include <unistd.h> 263 long n = sysconf(_SC_NPROCESSORS_CONF); 264],[ 265 n = 10; 266],[ 267 enable_sysconf_sc_nprocessors_conf=yes 268],[ 269 enable_sysconf_sc_nprocessors_conf=no 270]) 271AC_MSG_RESULT([$enable_sysconf_sc_nprocessors_conf]) 272 273if test "$enable_sysconf_sc_nprocessors_conf" = "no"; then 274AC_MSG_WARN([_SC_NPROCESSORS_CONF on this environment.]) 275else 276AC_DEFINE([HAVE_SYS_CONF_SC_NPROCESSORS_CONF]) 277fi 278 279AC_MSG_CHECKING(if ${CXX-c++} environment provides all required features) 280if test "x$config_error" = xyes ; then 281 AC_MSG_RESULT([no]) 282 AC_MSG_ERROR([Your compiler is not powerful enough to compile CRF++. \ 283 If it should be, see config.log for more information of why it failed.]) 284fi 285AC_MSG_RESULT([yes]) 286 287AC_SUBST(datarootdir) 288AM_CONFIG_HEADER(config.h) 289AC_OUTPUT([Makefile Makefile.msvc swig/version.h]) 290 291