AC_INIT(libmonetra, 5.0.0, "support@mainstreetsoftworks.com") AM_INIT_AUTOMAKE(libmonetra, 5.0.0) AM_CONFIG_HEADER(libmonetra_config_pre.h) case `uname -s` in AIX) AM_DISABLE_SHARED ;; *) AM_ENABLE_SHARED ;; esac AC_PROG_CC AC_PROG_INSTALL AM_PROG_LIBTOOL AC_C_CONST AC_HEADER_STDC AC_CHECK_TYPE(socklen_t, [ have_socklen_t="yes" ], [ have_socklen_t="no" ], [ [ #include ] [ #include ] [ #include ] ]) AC_CHECK_DECL(socklen_t, [ have_decl_socklen_t="yes" ], [ have_decl_socklen_t="no" ], [ [ #include ] [ #include ] [ #include ] ]) if test "$have_socklen_t" = "yes" ; then AC_DEFINE([HAVE_SOCKLEN_T], 1, [is socklen_t defined or typedefd]) AC_SUBST(HAVE_SOCKLEN_T) elif test "$have_decl_socklen_t" = "yes" ; then AC_DEFINE([HAVE_SOCKLEN_T], 1, [is socklen_t defined or typedefd]) AC_SUBST(HAVE_SOCKLEN_T) fi AC_CHECK_TYPE(long long, [ no_long_long="no" ], [ no_long_long="yes"]) if test "$no_long_long" = "yes" ; then AC_DEFINE([NO_LONG_LONG], 1, [does a long long type exist]) AC_SUBST(NO_LONG_LONG) fi AC_CHECK_FUNC(atoll, [ no_atoll="no" ], [ no_atoll="yes" ]) if test "$no_atoll" = "yes" ; then AC_DEFINE([NO_ATOLL], 1, [does atoll exist]) AC_SUBST(NO_ATOLL) fi dnl -------------------- CHECKING FOR STRTOLL() ------------------------- AC_CHECK_FUNC(strtoll, [ no_strtoll="no" ], [ no_strtoll="yes" ]) if test "$no_strtoll" = "yes" ; then AC_DEFINE([NO_STRTOLL], 1, [does strtoll exist]) AC_SUBST(NO_STRTOLL) fi AC_CHECK_LIB(socket, shutdown, [], []) AC_CHECK_LIB(nsl, gethostbyname, [], [], -lsocket) dnl check for existing /dev/random or /dev/urandom AC_MSG_CHECKING(for /dev/random and /dev/urandom support) monetra_random="no" if test -r /dev/random -o -r /dev/urandom ; then monetra_random="yes" fi if test "$monetra_random" = "no" ; then AC_DEFINE([NEED_SEED], 1, [do we need to seed the random number generator]) AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi krb5headers="" AC_ARG_WITH(krb5headers, [ --with-krb5headers where krb5.h resides if openssl requires it], [ krb5headers="$with_krb5headers" ], [ krb5headers="" ]) AC_ARG_WITH(ssl, [ --with-ssl[=dir] enable ssl support [default=yes]], [ if test "$with_ssl" = "no" ; then want_ssl="no" ssl_dir="" else want_ssl="yes" ssl_dir=$withval fi ], [ want_ssl="yes" ssl_dir="" ]) want_ip="yes" AC_ARG_WITH(ip, [ --with-ip enable ip support [default=yes]], [ if test "$with_ip" = "no" ; then want_ip="no" else want_ip="yes" fi ], [ want_ip="yes" ]) if test "$want_ip" = "no" ; then want_ssl="no" fi if test "$want_ssl" = "yes" ; then AC_MSG_CHECKING(for ssl library location) if test -r $ssl_dir/lib/libssl.a -o -r $ssl_dir/lib/libssl.so -o -r $ssl_dir/lib/libssl.dylib -o -r $ssl_dir/lib/libssl.sl ; then LIBM_LDFLAGS="-L$ssl_dir/lib" LIBM_CFLAGS="-I$ssl_dir/include" AC_MSG_RESULT($ssl_dir); elif test -r /usr/local/ssl/lib/libssl.a -o -r /usr/local/ssl/lib/libssl.so -o -r /usr/local/ssl/lib/libssl.dylib -o -r /usr/local/ssl/lib/libssl.sl ; then LIBM_LDFLAGS="-L/usr/local/ssl/lib" LIBM_CFLAGS="-I/usr/local/ssl/include" AC_MSG_RESULT(/usr/local/ssl); elif test -r /usr/lib/libssl.a -o -r /usr/lib/libssl.so -o -r /usr/lib/libssl.dylib -o -r /usr/lib/libssl.sl ; then LIBM_LDFLAGS="-L/usr/lib" LIBM_CFLAGS="-I/usr/include" AC_MSG_RESULT(/usr); else AC_MSG_RESULT(unknown); fi want_ssl="yes" fi if test "$want_ssl" = "yes" ; then old_CFLAGS="$CFLAGS" old_CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS $LIBM_CFLAGS" CPPFLAGS="$CFLAGS $LIBM_CFLAGS" openssl_requires_krb5="no" AC_MSG_CHECKING([if openssl requires krb5]) AC_EGREP_CPP(yes,[ #include #ifndef OPENSSL_NO_KRB5 yes #endif ],[ AC_MSG_RESULT([yes]) openssl_requires_krb5="yes" ],[ AC_MSG_RESULT(no) ]) CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" if test "$openssl_requires_krb5" = "yes" ; then AC_MSG_CHECKING(for ssl library location) if test -r $krb5headers/krb5.h ; then AC_MSG_RESULT($krb5headers) elif test -r /usr/include/krb5.h ; then krb5headers="/usr/include/krb5" AC_MSG_RESULT($krb5headers) else AC_MSG_ERROR(could not find krb5.h please specify directory using --with-krb5headers=) fi fi fi CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" if test "$openssl_requires_krb5" = "yes" ; then LIBM_CFLAGS="$LIBM_CFLAGS -I$krb5headers" fi CFLAGS="$CFLAGS $LIBM_CFLAGS" LDFLAGS="$CFLAGS $LIBM_LDFLAGS" if test "$want_ssl" = "yes" ; then dnl Darwin/MacOSX always wants to link to the system OpenSSL, dnl instead of obeying the path from the CFLAGS first, so we dnl do not let libmonetra link with OpenSSL, just remember its dnl required for external apps that link with libmonetra to also dnl link with OpenSSL case `uname -s` in *Darwin*) LIBCRYPTO="" ;; *) LIBCRYPTO="-lcrypto -lssl" ;; esac AC_SUBST(LIBCRYPTO) AC_SUBST(LIBCRYPTO) AC_DEFINE([ENABLE_SSL], 1, [should SSL be enabled]) AC_SUBST(ENABLE_SSL) fi if test "$want_ip" = "yes" ; then want_ip="yes" else AC_DEFINE([DISABLE_IP], 1, [should IP be enabled]) AC_SUBST(DISABLE_IP) fi dnl -------------------- CHECKING FOR GETHOSTBYNAME_R() ----------------------- ghbn="4" dnl point to this is to first verify gethostbyname_r exists, then dnl in a multi-tiered fashion, check for which implementation exists. AC_CHECK_FUNC(gethostbyname_r, [ AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he; struct hostent_data data; (void) gethostbyname_r(name, he, &data); ], ghbn="3", [ AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he, *res; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop); ], ghbn="1", [ AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he; char buffer[2048]; int buflen=2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop); ], ghbn="2", [ ghbn="4" ] ) ] ) ] ) ], ghbn="4") if test "$ghbn" = "1" ; then AC_DEFINE([GETHOSTBYNAME_1], 1, [gethostbyname_r takes 6 args]) AC_SUBST(GETHOSTBYNAME_1) elif test "$ghbn" = "2" ; then AC_DEFINE([GETHOSTBYNAME_2], 1, [gethostbyname_r takes 5 args]) AC_SUBST(GETHOSTBYNAME_2) elif test "$ghbn" = "3" ; then AC_DEFINE([GETHOSTBYNAME_3], 1, [gethostbyname_r takes 3 args]) AC_SUBST(GETHOSTBYNAME_3) elif test "$ghbn" = "4" ; then AC_DEFINE([GETHOSTBYNAME_4], 1, [gethostbyname_r does not exist]) AC_SUBST(GETHOSTBYNAME_4) fi CFLAGS="${CFLAGS} -DLIBMONETRA_INTERNAL" AC_SUBST(prefix) AC_OUTPUT(Makefile) AC_MSG_RESULT(libmonetra configured:) AC_MSG_RESULT(ip support enabled: $want_ip) AC_MSG_RESULT(ssl support enabled: $want_ssl) AC_MSG_RESULT(gethostbyname type: $ghbn) echo "Writing stripped libmonetra_config.h" cat libmonetra_config_pre.h | grep -v "#define PACKAGE" | grep -v "#define VERSION" | grep -v "#define PAKCAGE_VERSION" | grep -v "#define PACKAGE_NAME" | grep -v "#define PACKAGE_STRING" | grep -v "#define PACKAGE_TARNAME" > libmonetra_config.h