dnl configure.in -- main autoconf macro definition file dnl dnl Process this file with autoconf to produce a configure script. dnl This file is part of the Kannel WAP and SMS gateway project. dnl initialization AC_PREREQ(2.13) AC_INIT(gw/alt_charsets.h) AC_CONFIG_HEADER(config.h) AC_SUBST(SHELL) AC_CONFIG_AUX_DIR(.) AC_SET_TERMINAL_SEQUENCES() dnl Check gateway version number. VERSION=`head -1 VERSION` AC_DEFINE_UNQUOTED(VERSION, "$VERSION") AC_CONFIG_SECTION([Configuring for Kannel gateway version $VERSION]) if test "x$VERSION" = "xcvs"; then AC_MSG_CHECKING([cvs checkout date]) cvs_date=`ls -lcda . | awk '{print $6,$7,$8}'` AC_MSG_RESULT([$cvs_date]) fi dnl Solaris pkgadd support definitions PKGADD_PKG="KANNELgateway" PKGADD_NAME="Kannel - WAP and SMS gateway" PKGADD_VENDOR="www.kannel.org" AC_SUBST(PKGADD_PKG) AC_SUBST(PKGADD_NAME) AC_SUBST(PKGADD_VENDOR) dnl Target installation directory for documentation AC_SUBST(docdir) docdir='${prefix}/share/doc/kannel' dnl Checks system type. AC_CONFIG_SECTION([Running system checks]) AC_CANONICAL_HOST dnl Apply system specific rules. dnl Executable extension for systems that need one, i.e. Cygwin EXE_EXT="" case "$host" in *-sun-solaris*) CFLAGS="$CFLAGS -DSunOS=1" ;; *-cygwin*) EXE_EXT=".exe" ;; esac AC_SUBST(EXE_EXT) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB AC_PROG_YACC AC_PROG_LEX AC_PATH_PROG(CONVERT, convert) AC_PATH_PROG(PERL, perl) dnl Checks for libraries. AC_CHECK_LIB(m, log) AC_CHECK_LIB(socket, accept) AC_CHECK_LIB(nsl, inet_ntoa) AC_CHECK_LIB(resolv, inet_ntop) AC_CHECK_LIB(bind, inet_ntop) AC_CHECK_LIB(pthread, pthread_exit) if test -z "$pthread"; then AC_CHECK_LIB(c_r, pthread_exit, [LIBS="$LIBS -lc_r"]) fi dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(sys/ioctl.h sys/time.h sys/types.h unistd.h sys/poll.h) AC_CHECK_HEADERS(pthread.h getopt.h syslog.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_TRY_COMPILE(, [char *func = __FUNCTION__;], AC_DEFINE(HAVE___FUNCTION__)) AC_TRY_COMPILE(, [char *func = __func__;], AC_DEFINE(HAVE___FUNC__)) dnl Checks for library functions. AC_CHECK_FUNCS(gettimeofday select socket strdup getopt_long) AC_CHECK_FUNC(getopt, , LIBOBJS="$LIBOBJS utils/attgetopt.o") AC_SUBST(LIBOBJS) dnl Extra feature checks dnl GW_HAVE_TYPE_FROM(HDRNAME, TYPE, HAVENAME, DESCRIPTION) AC_DEFUN(GW_HAVE_TYPE_FROM, [ AC_CACHE_CHECK([for $2 in <$1>], gw_cv_type_$3, AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H #include #endif #include <$1> ], [$2 foo;], gw_cv_type_$3=yes, gw_cv_type_$3=no)) if test $gw_cv_type_$3 = yes; then AC_DEFINE($3, 1, $4) fi ]) dnl GW_HAVE_FUNC_FROM(HDRNAME, FUNC, HAVENAME, DESCRIPTION) AC_DEFUN(GW_HAVE_FUNC_FROM, [ AC_CACHE_CHECK([for $2 in <$1>], gw_cv_func_$3, AC_TRY_COMPILE([#include <$1>], [void *foo = $2;], gw_cv_func_$3=yes, gw_cv_func_$3=no)) if test $gw_cv_func_$3 = yes; then AC_DEFINE($3, 1, $4) fi ]) GW_HAVE_TYPE_FROM(sys/socket.h, socklen_t, HAVE_SOCKLEN_T, [Defined if there is a socklen_t in ]) GW_HAVE_FUNC_FROM(stdio.h, getopt, HAVE_GETOPT_IN_STDIO_H, [Does declare getopt()?]) GW_HAVE_FUNC_FROM(unistd.h, getopt, HAVE_GETOPT_IN_UNISTD_H, [Does declare getopt()?]) dnl Misfeature checks AC_CONFIG_SECTION([Checking POSIX threads support]) AC_MSG_CHECKING(for working pthreads) AC_TRY_RUN([#include #include int pid; void testpid(void* foo); int main(void){ pthread_t child; pid=getpid(); pthread_create(&child,NULL,(void*)testpid,NULL); pthread_join(child,NULL); return 0; } void testpid(void* foo){ int mypid=getpid(); if(mypid!=pid){ /* Pthreads states that all threads should have the same PID * we dont! */ exit(1); }else{ exit(0); } } ],echo yes , echo no ;CFLAGS="$CFLAGS -DBROKEN_PTHREADS=1", echo Cross compiling - assuming they work) dnl Check if we have libxml2 installed and which version it is. dnl Kannel requires currently at least version 2.2.5 of libxml2. AC_CONFIG_SECTION([Checking for libxml2 support]) xml_ver_required="2.2.5" AC_PATH_PROGS(XML_CONFIG, xml2-config xml-config, no) if test "$XML_CONFIG" = "no"; then AC_MSG_ERROR([You MUST have the libxml2 (aka gnome-xml) library installed]) else AC_MSG_CHECKING([libxml version]) xml_version=`$XML_CONFIG --version` AC_MSG_RESULT([$xml_version]) AC_CHECK_VERSION($xml_version, $xml_ver_required, [ LIBS="$LIBS `$XML_CONFIG --libs`" CFLAGS="$CFLAGS `$XML_CONFIG --cflags`" ],[ AC_MSG_ERROR([libxml2 version $xml_version is too old. You need at least $xml_ver_required]) ]) fi dnl DocBook stuff AC_CONFIG_SECTION([Configuring DocBook support]) AC_CHECK_PROG(JADE, jade, jade, :) AC_CHECK_PROG(JADETEX, jadetex, jadetex, :) AC_CHECK_PROG(DVIPS, dvips, dvips, :) AC_CHECK_PROG(FIG2DEV, fig2dev, fig2dev, :) AC_CHECK_PROG(CONVERT, convert, convert, :) AC_CHECK_PROG(PS2PDF, ps2pdf, ps2pdf, :) AC_SUBST(HTML_DSL) for loc in /usr /usr/local; do for file in ${loc}/lib/sgml/stylesheet/dsssl/docbook/nwalsh/html/docbook.dsl \ ${loc}/lib/sgml/stylesheets/nwalsh-modular/html/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl-stylesheets-1.59/html/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl-stylesheets/html/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl/modular/html/docbook.dsl do AC_CHECK_FILE($file,HTML_DSL=$file) done done AC_SUBST(TEX_DSL) for loc in /usr /usr/local; do for file in ${loc}/lib/sgml/stylesheet/dsssl/docbook/nwalsh/print/docbook.dsl \ ${loc}/lib/sgml/stylesheets/nwalsh-modular/print/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl-stylesheets-1.59/print/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl-stylesheets/print/docbook.dsl \ ${loc}/share/sgml/docbook/dsssl/modular/print/docbook.dsl do AC_CHECK_FILE($file,TEX_DSL=$file) done done dnl Implement --enable-docs option. AC_SUBST(DOCSTARGET) if test "x$HTML_DSL" = "x" -o "x$TEX_DSL" = "x" then DOCSTARGET="no-docs" else DOCSTARGET="docs" fi AC_ARG_ENABLE(docs, [ --enable-docs enable building of documentation (default: enabled)], [ if test "$enableval" = "yes" then DOCSTARGET="docs" else DOCSTARGET="no-docs" fi ]) case "$DOCSTARGET" in no-docs) echo Not building documentation. ;; docs) echo Documentation will be built as well. ;; esac dnl Implement --with-defaults=speed/debug option. AC_ARG_WITH(defaults, [ --with-defaults set default configure options: speed/debug (default: debug) this will set assertion checking and malloc wrapper accordingly], [ case "$withval" in speed) assertiondefault=no mallocdefault=native ;; debug) assertiondefault=yes mallocdefault=check ;; *) echo "unknown --with-defaults parameter $withval" exit 1 ;; esac ], [ dnl Same as debug assertiondefault=yes mallocdefault=check ]) dnl Implement --with-malloc=[native|check|slow] option. AC_CONFIG_SECTION([Configuring malloc wrapper]) AC_ARG_WITH(malloc, [ --with-malloc select malloc wrapper to use: native/check/slow (default: check)], [ case "$withval" in native) AC_DEFINE(USE_GWMEM_NATIVE) echo using native malloc ;; check) AC_DEFINE(USE_GWMEM_CHECK) echo using checking malloc ;; slow) AC_DEFINE(USE_GWMEM_SLOW) echo using slow malloc ;; *) echo "Unknown malloc wrapper $withval. Oops."; exit 1 ;; esac ], [ case "$mallocdefault" in native) AC_DEFINE(USE_GWMEM_NATIVE) echo using native malloc ;; slow) AC_DEFINE(USE_GWMEM_SLOW) echo using slow malloc ;; *) AC_DEFINE(USE_GWMEM_CHECK) echo using checking malloc ;; esac ]) dnl Implement --disable-assertions option. AC_ARG_ENABLE(assertions, [ --disable-assertions turn off assertion checking], [ if test "$enableval" = "no" then echo disabling assertion checking AC_DEFINE(NO_GWASSERT) fi ], [ if test "$assertiondefault" = "no" then echo disabling assertion checking AC_DEFINE(NO_GWASSERT) fi ]) dnl Implement the --enable-pam option. AC_ARG_ENABLE(pam, [ --enable-pam enable pam authentication (default: disabled)], [ if test "$enableval" = "yes" then AC_CHECK_LIB(pam, pam_end) AC_CHECK_LIB(dl,main) AC_CHECK_HEADERS(security/pam_appl.h) PAMTARGET="pam" else PAMTARGET="no-pam" fi ]) case "$PAMTARGET" in no-pam) echo pam authentication is disabled. ;; pam) echo pam authentication is enabled. ;; esac dnl Implement --enable-debug option. AC_ARG_ENABLE(debug, [ --enable-debug enable non-reentrant debugging for wmls compiler (default: disabled)], [ echo enabling WMLScript compiler debugging if test -n "$GCC"; then CFLAGS="$CFLAGS -Wall" fi AC_DEFINE(WS_DEBUG) ]) dnl Implement --enable-localtime option. AC_ARG_ENABLE(localtime, [ --enable-localtime log file time stamps in local time, not GMT (default: disabled)], [ if test "$enableval" = yes; then echo enabling local time AC_DEFINE(LOG_TIMESTAMP_LOCALTIME) fi ]) dnl --enable-mutex-stats option. AC_ARG_ENABLE(mutex-stats, [ --enable-mutex-stats produce information about lock contention], [ if test "$enableval" = yes; then AC_DEFINE(MUTEX_STATS) fi ]) dnl --enable-cookies option. AC_ARG_ENABLE(cookies, [ --enable-cookies enable cookie support for WSP (default: disabled)], [ if test "$enableval" = yes; then AC_DEFINE(ENABLE_COOKIES) fi ]) dnl --enable-start-stop-daemon option. AC_ARG_ENABLE(start-stop-daemon, [ --enable-start-stop-daemon compile the start-stop-daemon program], [ if test "$enableval" = yes; then STARTSTOPDAEMONSRC="utils/start-stop-daemon.c" fi ]) AC_SUBST(STARTSTOPDAEMONSRC) dnl Implement the --with-ssl option. AC_CONFIG_SECTION([Configuring OpenSSL support]) AC_ARG_WITH(ssl, [ --with-ssl[=DIR] where to look for OpenSSL libs and header files DIR points to the installation [/usr/local/ssl]], [ if test -d "$withval"; then ssllib="$withval/lib"; sslinc="$withval/include" else AC_MSG_ERROR(Unable to find OpenSSL libs and/or directories at $withval) fi ]) dnl Implement --enable-ssl option. AC_MSG_CHECKING([whether to compile with SSL support]) AC_ARG_ENABLE(ssl, [ --enable-ssl enable SSL client and server support (default: enabled)], [ if test "$enableval" = no ; then AC_MSG_RESULT(disabled) fi ],[ dnl test only if --with-ssl has not been used if test "x$ssllib" = "x" && test "x$sslinc" = "x"; then for loc in /usr/lib /usr/local/ssl/lib /usr/local/openssl/lib; do if test -f "$loc/libssl.a"; then ssllib="$loc" fi done for loc in /usr/include/ssl /usr/include/openssl /usr/local/ssl/include \ /usr/local/openssl/include; do if test -d "$loc"; then sslinc="$loc" fi done fi AC_MSG_RESULT($ssllib $sslinc) ]) dnl Implement the SSL library checking routine. dnl This will define HAVE_LIBSSL in config.h if test "x$ssllib" != "x" && test "x$sslinc" != "x"; then CFLAGS="$CFLAGS -I$sslinc" LIBS="$LIBS -L$ssllib" AC_PATH_PROG(OPENSSL, openssl, no) if test "$OPENSSL" != "yes"; then AC_MSG_CHECKING([openssl version]) openssl_version=`$OPENSSL version | awk '{print $2}'` AC_MSG_RESULT([$openssl_version]) fi AC_CHECK_LIB(crypto, CRYPTO_lock, [ LIBS="$LIBS -lcrypto" AC_CHECK_LIB(ssl, SSL_library_init, [ AC_CHECK_LIB(ssl, SSL_connect) AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \ openssl/pem.h openssl/ssl.h openssl/err.h) AC_MSG_CHECKING(whether the OpenSSL library is multithread-enabled) AC_TRY_RUN([ #define OPENSSL_THREAD_DEFINES #include int main(void) { #if defined(THREADS) exit(0); #else exit(1); #endif } ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LIBSSL) LIBS="$LIBS -lssl" ], [ AC_ARG_ENABLE(ssl-thread-test, [ --disable-ssl-thread-test disable the multithread test for the OpenSSL library this will force to continue even if the test fails], [ if test "$enableval" = no ; then AC_MSG_RESULT([no, continue forced]) fi ], [ AC_MSG_RESULT(no) AC_MSG_ERROR(Either get a multithread-enabled SSL or configure with --disable-ssl) ]) ], echo "Cross-compiling; make sure your SSL library is multithread-enabled" ) ]) ]) fi dnl Implement the --with-mysql option. This will set HAVE_MYSQL in config.h dnl accordingly and enable the usage of the libmysqlclient routines. AC_ARG_WITH(mysql, [ --with-mysql[=DIR] where to look for MySQL libs and header files DIR points to the installation [/usr/local]], [AC_CONFIG_SECTION([Configuring MySQL support]) AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, no) dnl check for MySQL 4.x style mysql_config information if test "$MYSQL_CONFIG" = "no"; then dnl mysql-3.x style AC_MSG_CHECKING([for MySQL client support in]) if test "$withval" = "yes"; then loc="/usr/local" else loc="$withval" fi AC_MSG_RESULT($loc) AC_CHECK_FILE("$loc/include/mysql/mysql.h", [CFLAGS="$CFLAGS -I$loc/include/mysql"; LIBS="$LIBS -L$loc/lib/mysql -lmysqlclient"], [AC_CHECK_FILE("$loc/include/mysql.h", [CFLAGS="$CFLAGS -I$loc/include"; LIBS="$LIBS -L$loc/lib -lmysqlclient"], [AC_MSG_ERROR(Unable to find mysql.h under $loc)] )] ) else dnl mysql-4.x style AC_MSG_CHECKING([mysql version]) mysql_version=`$MYSQL_CONFIG --version` AC_MSG_RESULT([$mysql_version]) LIBS="$LIBS `$MYSQL_CONFIG --libs`" CFLAGS="$CFLAGS `$MYSQL_CONFIG --cflags`" fi AC_CHECK_HEADERS(mysql/mysql.h mysql/mysql_com.h mysql/mysql_version.h) AC_CHECK_LIB(mysqlclient, mysql_init) AC_DEFINE(HAVE_MYSQL) MYSQL="yes" ]) dnl Implement the --with-dlr option. dnl Checks which external DLR storage should be used. AC_ARG_WITH(dlr, [ --with-dlr[=TYPE] select DLR storage to use: internal/mysql (default: internal)], [ AC_CONFIG_SECTION([Configuring DLR support]) AC_MSG_CHECKING([for DLR storage type]) AC_MSG_RESULT($withval) case "$withval" in internal) ;; mysql) if test "$MYSQL" != "yes"; then AC_MSG_ERROR(Option --with-dlr=mysql requires MySQL client support) else AC_DEFINE(DLR_MYSQL) fi ;; *) AC_MSG_ERROR(Unknown DLR storage support!) exit 1 ;; esac ]) dnl Implement the --with-wtls option. dnl Check to see if we should include WTLS support, and which library to use. AC_ARG_WITH(wtls, [ --with-wtls[=TYPE] select WTLS version to use: openssl/baltimore], [ AC_CONFIG_SECTION([Configuring WTLS support]) AC_MSG_CHECKING([for WTLS library]) AC_MSG_RESULT($withval) case "$withval" in openssl) OLDLIBS="$LIBS" LIBS="$LIBS -L/usr/local/ssl/lib -lcrypto" AC_CHECK_LIB(crypto, RSA_new, [ AC_CHECK_HEADERS(openssl/objects.h openssl/rc5.h, AC_DEFINE(HAVE_WTLS_OPENSSL), AC_MSG_WARN(OpenSSL installation seems to lack RC5 algorithm!) ) ]) ;; baltimore) AC_MSG_ERROR(This WTLS library is yet not supported!) ;; *) AC_MSG_ERROR(Unknown WTLS libary support!) exit 1 ;; esac ]) dnl Final Output AC_CONFIG_SECTION([Generating output files]) AC_OUTPUT(Makefile)