# # OpenEvidence # # version of autoconf needed. AC_PREREQ(2.59) # distribution versionning. AC_INIT(OE, 1.1.1, contact@openevidence.org) AC_CANONICAL_SYSTEM # generate oeconfig.h from oeconfig.h.in. AC_CONFIG_HEADER(oeconfig.h) # only for automake. AM_INIT_AUTOMAKE # libtool option AC_ARG_ENABLE(shared, [AC_HELP_STRING([--disable-shared], [compile all in static])], [ AC_MSG_RESULT([disable shared library, so compile all in static]) AC_DISABLE_SHARED ], [AC_MSG_RESULT([compile all in shared library])]) # check some platform. # for future version! AC_AIX AC_ISC_POSIX AC_MINIX AC_SYS_LARGEFILE # Checks for programs. AC_MSG_RESULT([ ******** Checks for programs. ******** ]) AC_PROG_CXX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB AC_PROG_LIBTOOL AC_PROG_LEX AC_PROG_YACC AC_CHECK_PROG(AR, ar, ar, ar) AC_CHECK_PROG(PERL, perl, perl, perl) dnl Needed for the test suite (only) ### APPLICATION PACKAGE # for OEMIEL AC_ARG_ENABLE(oemiel, [AC_HELP_STRING([--disable-oemiel], [build without OEMIEL GUI on wxWindows])], [disable_oemiel=yes], [disable_oemiel=no]) # for makefile AM_CONDITIONAL([APP_OEMIEL], [test "$disable_oemiel" = no]) # for configure if test "$disable_oemiel" = no; then AC_CONFIG_SUBDIRS(src/apps/oemiel) fi # etc... ### # Checks for header files. AC_MSG_RESULT([ ******** Checks for header files. ******** ]) AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_SYS_WAIT AC_HEADER_TIME AC_CHECK_HEADERS([\ errno.h \ assert.h \ ctype.h \ sys/cdefs.h \ stdio.h \ sys/types.h \ sys/param.h \ unistd.h \ sys/stat.h \ stdlib.h \ stddef.h \ stdarg.h \ memory.h \ string.h \ inttypes.h \ sys/socket.h \ netinet/in.h \ netinet/tcp.h \ netdb.h \ arpa/inet.h \ dlfcn.h \ fcntl.h \ limits.h \ stdint.h \ signal.h \ syslog.h \ sysexits.h \ malloc.h \ sys/uio.h \ setjmp.h \ grp.h \ pwd.h \ pthread.h ]) # Checks for typedefs, structures, and compiler characteristics. AC_MSG_RESULT([ ******** Checks for typedefs, structures, and compiler characteristics. ]) AC_C_CONST AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM # Checks for standard library functions. AC_MSG_RESULT([ ******** Checks for standard library functions. ******** ]) AC_FUNC_CLOSEDIR_VOID AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_ALLOCA AC_FUNC_REALLOC AC_FUNC_STAT AC_FUNC_MEMCMP AC_FUNC_MKTIME AC_FUNC_STRFTIME AC_FUNC_SELECT_ARGTYPES AC_FUNC_VPRINTF AC_FUNC_WAIT3 AC_CHECK_FUNCS([\ atexit \ select \ dup2 \ fdatasync \ memmove \ memset \ bzero \ strdup \ strerror \ strchr \ strrchr \ strcasecmp \ strncasecmp \ strstr \ strtol \ strtoul \ alarm \ getcwd \ gettimeofday \ ]) ### ### Begin of special functions checks. ### AC_MSG_RESULT([ ******** Begin of special functions checks. ******** ]) AC_DEFUN(AC_CHECK_SYMBOL, [dnl AC_MSG_CHECKING(for $1) AC_CACHE_VAL(ac_cv_check_symbol_$1, [ AC_TRY_LINK(, [extern char *sys_siglist[]; puts(*sys_siglist);], ac_cv_check_symbol_$1=yes, ac_cv_check_symbol_$1=no) ]) if test "$ac_cv_check_symbol_$1" = yes; then changequote(,)dnl ac_tr_symbol=`echo $1 | tr '[a-z]' '[A-Z]'` changequote([,])dnl AC_DEFINE_UNQUOTED(HAVE_${ac_tr_symbol}) fi AC_MSG_RESULT($ac_cv_check_symbol_$1)])dnl # clock_gettime is in -lposix4 in Solaris 2.6. AC_MSG_RESULT([ ******** clock_gettime is in -lposix4 in Solaris 2.6. ******** ]) AC_CHECK_LIB(posix4, clock_gettime) # network functions. AC_MSG_RESULT([ ******** network functions. ******** ]) AC_CHECK_LIB(nsl_r, gethostbyname_r, [], AC_CHECK_LIB(nsl, gethostbyname_r)) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt)) AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind)) AC_CHECK_FUNC(gethostbyname_r) AC_CHECK_FUNC(gethostbyname) AC_CHECK_FUNC(inet_ntoa) AC_CHECK_FUNC(socket) # missing functions. AC_MSG_RESULT([ ******** Test some missing functions. ******** ]) AC_CHECK_FUNC([wsainit], [ AC_DEFINE([HAVE_WIN32_INIT],[1],[Have Win32 init function]) ]) AC_CHECK_FUNC([daemon], [ AC_DEFINE([HAVE_FUNC_DAEMON],[1],[Have func daemon]) ], [ TEST_DAEMON="yes" ]) AM_CONDITIONAL([MISSFUNC_DAEMON], [dnl eat \n changequote(,) dnl [ ".$TEST_DAEMON" != . ] dnl changequote([,]) dnl ]) AC_CHECK_FUNC([strsep], [ AC_DEFINE([HAVE_FUNC_STRSEP],[1],[Have func strsep]) ], [ TEST_STRSEP="yes" \ ]) AM_CONDITIONAL([MISSFUNC_STRSEP], [dnl changequote(,) dnl [ ".$TEST_STRSEP" != . ] dnl changequote([,]) dnl ]) AC_CHECK_FUNC([errx], [ AC_DEFINE([HAVE_FUNC_ERRX],[1],[Have func errx]) ], [ TEST_ERRX="yes" ]) AM_CONDITIONAL([MISSFUNC_ERRX], [dnl changequote(,) dnl [ ".$TEST_ERRX" != . ] dnl changequote([,]) dnl ]) AC_CHECK_HEADER([expat.h], [ AC_CHECK_LIB(expat, XML_ParserCreate, [AC_DEFINE([HAVE_LIB_EXPAT],[1],[Have lib expat])] ) ], [ TEST_EXPAT="yes" ]) AM_CONDITIONAL([MISSLIB_EXPAT], [dnl changequote(,) dnl [ ".$TEST_EXPAT" != . ] dnl changequote([,]) dnl ]) ### End ### ### ### Begin of customization part. ### AC_MSG_RESULT([ ******** Begin of customization part. ******** ]) # Should we build server? AC_ARG_ENABLE(server, [AC_HELP_STRING([--enable-server], [build TSA server too (default: yes)])], [enable_server=yes], [enable_server=yes]) AM_CONDITIONAL(OETS_SERVER_ENABLED, test "x$enable_server" = "xyes") # Special note: know, all things that refer to this choose is enclosed # by BEGIN: SERVER-SPECIFIC and END: SERVER-SPECIFIC # # Special features about sockets # BEGIN: SERVER-SPECIFIC TSLINKD_SOCKET="${localstatedir}/oets/tslinkd.socket" AC_SUBST(TSLINKD_SOCKET) TSEXTD_SOCKET="${localstatedir}/oets/tsextd.socket" AC_SUBST(TSEXTD_SOCKET) # END: SERVER-SPECIFIC ### End ### ### Begin of special library handling. ### ### for each needed library we create a couple of variable _CFLAGS & _LIBS. ### use it in Makefile.am that need this library. ### AC_MSG_RESULT([ ******** Begin of special library handling. ******** ]) # PTHREAD # Checks for platform independant thread support. AC_MSG_RESULT([ ******** PTHREAD ******** ]) case "$target" in *-*-linux-*) PTHREAD_CFLAGS="-D_REENTRANT" PTHREAD_LIBS="-lpthread" ;; *-*-solaris*) PTHREAD_CFLAGS="-D_REENTRANT" PTHREAD_LIBS="-lpthread -lposix4" ;; *-*-freebsd*) PTHREAD_CFLAGS="" PTHREAD_LIBS="-pthread" ;; *) AC_MSG_ERROR([Target "$target" is not supported (dont know how to enable thread support)]) ;; esac # export this variable for Makefile.am AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_LIBS) # DEBUG # Main debugging option. Must be done before AC_PROG_CC! AC_MSG_RESULT([ ******** DEBUG ******** ]) AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug], [build with debug options])], [enable_debug=yes], [enable_debug=no]) if test "x$enable_debug" = "xyes" ; then DBG_CFLAGS="-g -O0" # Force debugging build else AC_DEFINE([NDEBUG],[],[Disable assertions etc.]) fi # Various debugging options AC_ARG_ENABLE(efence, [AC_HELP_STRING([--enable-efence], [link with Electric Fence malloc-debugging library])], [enable_efence=yes], [enable_efence=no]) if test "x$enable_efence" = "xyes" ; then DBG_LIBS="$LIBS -lefence" fi AC_ARG_ENABLE(ccmalloc, [AC_HELP_STRING([--enable-ccmalloc], [use ccmalloc memory debugger (mutually exclusive with --enable-efence)])], [enable_ccmalloc=yes], [enable_ccmalloc=no]) if test "x$enable_ccmalloc" = "xyes" ; then if test "x$enable_efence" = "xyes" ; then AC_MSG_ERROR([--enable-efence and --enable-ccmalloc cannot be used together]) fi CC="ccmalloc gcc" fi # export this variable for Makefile.am AC_SUBST(DBG_CFLAGS) AC_SUBST(DBG_LIBS) # OPENSSL # OpenSSL installation directory and version AC_MSG_RESULT([ ******** OPENSSL ******** ]) AC_MSG_CHECKING([OpenSSL]) AC_ARG_WITH(OpenSSL, [AC_HELP_STRING([--with-OpenSSL=DIR], [use OpenSSL library from directory DIR])], :, [with_OpenSSL=yes]) # always yes OPENSSL_CFLAGS="-I/usr/local/ssl/include" OPENSSL_LIBS="-lssl -lcrypto" OPENSSL_LDFLAGS="/usr/local/ssl/lib" CFLAGS=${OPENSSL_CFLAGS} LDFLAGS=${OPENSSL_LIBS} case "x$with_OpenSSL" in xno | x) AC_MSG_ERROR([compilation without OpenSSL is not supported]) ;; xyes | x/usr) # let's hope it can be found in one of the standard include directories ;; *) with_OpenSSL=`echo ${with_OpenSSL} | sed 's%/$%%'` OPENSSL_CFLAGS="-I${with_OpenSSL}/include" OPENSSL_LIBS="-L${with_OpenSSL}/lib ${OPENSSL_LIBS}" OPENSSL_LDFLAGS="${with_OpenSSL}/lib" #try to compile with the selected location CFLAGS=${OPENSSL_CFLAGS} LDFLAGS=${OPENSSL_LIBS} ;; esac AC_TRY_COMPILE([#include ], [ #if OPENSSL_VERSION_NUMBER < 0x0090703fL #error Too old OpenSSL version #endif ], :, AC_MSG_ERROR([OpenSSL version 0.9.7c or better is required])) AC_MSG_RESULT([CFLAGS=\"$OPENSSL_CFLAGS\" LIBS=\"$OPENSSL_LIBS\"]) # export this variable for Makefile.am AC_SUBST(OPENSSL_CFLAGS) AC_SUBST(OPENSSL_LIBS) AC_SUBST(OPENSSL_LDFLAGS) # CURL # libcurl-sepcific flags AC_MSG_RESULT([ ******** CURL ******** ]) AC_MSG_CHECKING([curl-config]) AC_ARG_WITH(curl-config, [AC_HELP_STRING([--with-curl-config=CMD], [execute curl-config as CMD (use this if curl-config is not found in your PATH). It's even possible to specify --without-curl-config to disable support for HTTP connections])], :, [with_curl_config=yes]) if test "x$with_curl_config" = "xno" ; then AC_MSG_RESULT([building without curl (no HTTP support)]) else test "x$with_curl_config" = "xyes" && with_curl_config=curl-config # current curl LIBCURL_CFLAGS=`${with_curl_config} --cflags` changequote(,)dnl LIBCURL_LIBS=`${with_curl_config} --libs \ | sed 's%-L/usr/lib%%g' | sed 's%-L[^ ]*ssl[^ ]*%%g' \ | sed 's%-lssl%%g'| sed 's%-lcrypto%%g' | sed 's%//%/%g'` LIBCURL_LDFLAGS=`echo $LIBCURL_LIBS | sed 's%-L\([^ ]*\)\(.*\)%\1%g'` dnl LIBCURL_OPENSSL=`${with_curl_config} --libs | sed 's%\(.*\)-L\([^ ]*ssl[^ ]*\)\(.*\)%\2%g' | sed 's%//%/%g'` changequote([,])dnl # if test "$OPENSSL_LDFLAGS" != "$LIBCURL_OPENSSL" ; then # AC_MSG_ERROR([ # libcurl must used the same OpenSSL library # that the library defined by --with-OpenSSL: # $OPENSSL_LDFLAGS != $LIBCURL_OPENSSL # ]) # fi CFLAGS=${LIBCURL_CFLAGS} LDFLAGS=${LIBCURL_LIBS} AC_TRY_COMPILE([#include ], [#if LIBCURL_VERSION_MAJOR*1000+LIBCURL_VERSION_MINOR < 7011 #error Unsupported libcurl version #endif ], :, AC_MSG_ERROR([libcurl version 7.9.5 or newer is required])) AC_DEFINE([OETS_USE_LIBCURL], [], [Define usage of Curl]) fi AC_MSG_RESULT([ CFLAGS=\"$LIBCURL_CFLAGS\" LIBS=\"$LIBCURL_LIBS\" LDFLAGS=\"$LIBCURL_LDFLAGS\"]) # export this variable for Makefile.am AC_SUBST(LIBCURL_CFLAGS) AC_SUBST(LIBCURL_LIBS) AC_SUBST(LIBCURL_LDFLAGS) # PYTHON # python only if you compile a server # BEGIN: SERVER-SPECIFIC # Where's python? AC_MSG_RESULT([ ******** PYTHON ******** ]) AC_ARG_WITH(python, [AC_HELP_STRING([--with-python=CMD], [use python interpreter CMD (use this if not found in your PATH or you want to use specific version)])], :, [with_python="$enable_server"]) if test "x$with_python" = "xno" ; then if test "x$enable_server" = "xyes" ; then AC_MSG_ERROR([Sorry, you need python in order to run TSA]) fi else AC_MSG_CHECKING([python executable]) if test "x$with_python" = "xyes" ; then with_python="`which python`" if test -z "$with_python" ; then AC_MSG_ERROR([python interpreter not found]) fi fi if test "x`echo $with_python | cut -c 1`" != "x/" ; then AC_MSG_ERROR([please specify absolute path for python interpreter]) fi PYTHON_INTERPRETER="$with_python" AC_MSG_RESULT([using $PYTHON_INTERPRETER]) AC_SUBST(PYTHON_INTERPRETER) fi # END: SERVER-SPECIFIC ### End of special library handling ### ### ### basic CFLAGS & LIBS AC_MSG_CHECKING([setting environnement]) CFLAGS="$CFLAGS $DBG_FLAGS" LIBS="$LIBS $DBG_LIBS" # for all module that need to use open evidence include OE_CPPFLAGS="-I`pwd`/include/" AC_SUBST(OE_CPPFLAGS) ### # # After checking all basic things we can create Makefiles AC_MSG_RESULT([ ******** Finish, create Makefiles. ******** ]) AC_OUTPUT( Makefile src/Makefile src/lib/Makefile src/lib/base/Makefile src/lib/server/Makefile src/lib/api/Makefile src/lib/api/oe-config src/lib/api/examples/Makefile src/services/Makefile src/services/tslinkd/Makefile src/services/tsextd/Makefile src/services/tspd/Makefile src/admin/Makefile src/apache/Makefile src/apache/cgi/Makefile src/apache/mod/Makefile src/apache/mod/oets/Makefile src/apps/Makefile src/missing/expat/Makefile )