dnl Process this file with autoconf to produce a configure script. AC_INIT AC_CONFIG_SRCDIR([src]) AC_PREREQ(2.59) AC_CANONICAL_HOST AC_CANONICAL_TARGET libprelude_major=0 libprelude_minor=9 libprelude_micro=14 libprelude_patchlevel= dnl version and release information libprelude_version=$libprelude_major.$libprelude_minor.$libprelude_micro$libprelude_patchlevel dnl library soname dnl check http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 libprelude_current=12 libprelude_revision=0 libprelude_age=10 libprelude_soname=$libprelude_current:$libprelude_revision:$libprelude_age AC_SUBST(libprelude_soname) AM_INIT_AUTOMAKE(libprelude, $libprelude_version) AC_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE dnl Check for GNUlib # for prelude-config.h generation AC_PATH_PROG(GREP, grep, no) AC_PROG_CC AC_PROG_CPP gl_EARLY dnl Checks for programs. AC_PROG_INSTALL AC_PROG_MAKE_SET AC_C_INLINE AM_PROG_LEX AC_PROG_YACC AC_LIBLTDL_CONVENIENCE AC_LIBTOOL_DLOPEN AC_LTDL_DLLIB AC_LIBTOOL_WIN32_DLL AM_DISABLE_STATIC AC_PROG_LIBTOOL AC_SUBST(CFLAGS) # We need to compile and run a program on the build machine. AC_MSG_CHECKING(for cc for build) if test "$cross_compiling" = "yes"; then CC_FOR_BUILD="${CC_FOR_BUILD-cc}" else CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" fi AC_MSG_RESULT($CC_FOR_BUILD) AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) AC_SYS_LARGEFILE AX_CREATE_PRELUDE_INTTYPES_H(src/include/prelude-inttypes.h) dnl Expand $prefix. if test "x$prefix" = "xNONE"; then prefix="/usr/local" fi if test "x$localstatedir" = "x\${prefix}/var"; then localstatedir="$prefix/var" fi if test "x$sysconfdir" = "x\${prefix}/etc"; then sysconfdir="$prefix/etc" fi if test "x$datadir" = "x\${prefix}/share"; then datadir="$prefix/share" fi AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(libprelude_libs) AC_SUBST(libprelude_cflags) AC_SUBST(prelude_adduser_libs) dnl ********************************************************** dnl * Check for platform specific flags * dnl ********************************************************** AC_MSG_CHECKING(for platform-specific compiler flags) case "$host_os" in darwin*) # # It may be called "cc", but it's really a GCC derivative # with a problematic special precompiler and precompiled # headers; turn off the special precompiler, as some # apparently-legal code won't compile with its precompiled # headers. # AC_MSG_RESULT(Darwin: adding -no-cpp-precomp) AX_CFLAGS_GCC_OPTION(-no-cpp-precomp) ;; *) AC_MSG_RESULT(none needed) ;; esac dnl ********************************************************** dnl * Checks to see if ANSI C99 CPP variable __func__ works. * dnl ********************************************************** dnl From http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html AC_DEFUN([AC_CPP_FUNC], [AC_REQUIRE([AC_PROG_CC_STDC])dnl AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[char *foo = __func__;]])], [ac_cv_cpp_func=yes], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[char *foo = __FUNCTION__;]])], [ac_cv_cpp_func=__FUNCTION__], [ac_cv_cpp_func=no])])]) if test $ac_cv_cpp_func = yes; then AC_DEFINE(__PRELUDE_FUNC__, __func__, [Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C.]) elif test $ac_cv_cpp_func = __FUNCTION__; then AC_DEFINE(__PRELUDE_FUNC__, __FUNCTION__, [Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C.]) elif test $ac_cv_cpp_func = no; then AC_DEFINE(__PRELUDE_FUNC__, "", [Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C.]) fi ]) AC_CPP_FUNC dnl ************************************************** dnl * Check for Pthread library * dnl ************************************************** dnl *** dnl *** Can we use -Werror -Wmissing-braces for some checks ? *** AX_CFLAGS_GCC_OPTION(-Werror -Wmissing-braces, buggy_pthread_cppflags) ACX_PTHREAD(, AC_MSG_ERROR(couldn't find suitable pthread implementation)) dnl The above is from GnuLib. dnl # On Solaris and HP-UX, most pthread functions exist also in libc. # Therefore pthread_in_use() needs to actually try to create a # thread: pthread_create from libc will fail, whereas # pthread_create will actually create a thread. case "$host_os" in solaris* | hpux*) AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1, [Define if the __prelude_thread_in_use() detection is hard.]) esac dnl Check whether the compiler and linker support weak declarations. AC_MSG_CHECKING([whether imported symbols can be declared weak]) gl_have_weak=no AC_TRY_LINK([ extern void xyzzy (); #pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) AC_MSG_RESULT([$gl_have_weak]) if test $gl_have_weak = yes; then AC_DEFINE([USE_POSIX_THREADS_WEAK], 1, [Define if references to the POSIX multithreading library should be made weak.]) fi dnl Export pthread stuff wide for libmissing and libprelude-error LIBS="$LIBS $PTHREAD_LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" AC_CHECK_FUNC(pthread_atfork, have_pthread_atfork=yes, have_pthread_atfork=no) if test x$have_pthread_atfork = xyes; then AC_DEFINE_UNQUOTED(HAVE_PTHREAD_ATFORK, , Define wether pthread_atfork is available) fi AC_CHECK_FUNC(pthread_condattr_setclock, have_pthread_condattr_setclock=yes, have_pthread_condattr_setclock=no) if test x$have_pthread_condattr_setclock = xyes; then AC_DEFINE_UNQUOTED(HAVE_PTHREAD_CONDATTR_SETCLOCK, , Define wether pthread_condattr_setclock is available) fi old_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $buggy_pthread_cppflags" AC_MSG_CHECKING(for buggy pthread mutex initializers) AC_TRY_COMPILE( [ #include ], [ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; ], compile_ok="yes", compile_ok="no") CFLAGS="$old_CFLAGS" if test x$compile_ok = xyes; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) buggy_pthread_initializers="yes" fi dnl ************************************************** dnl * Check endianess * dnl ************************************************** AC_C_BIGENDIAN(AC_DEFINE_UNQUOTED(PRELUDE_WORDS_BIGENDIAN, , Byte ordering)) dnl ************************************************** dnl * Check for networking function * dnl ************************************************** LIBS_bkp=$LIBS LIBS="" AC_SEARCH_LIBS(socket, socket nsl resolv) COMMON_LIBS="$LIBS" LIBS=$LIBS_bkp dnl ************************************************** dnl * Check for POSIX timer function * dnl ************************************************** LIBS_bkp=$LIBS LIBS="" AC_SEARCH_LIBS(clock_gettime, [rt posix4]) COMMON_LIBS="$LIBS" LIBS=$LIBS_bkp dnl ************************************************** dnl * System wide libltdl support * dnl ************************************************** AC_ARG_WITH(system-ltdl, AC_HELP_STRING(--with-system-ltdl@<:@=PATH@:>@, Use system provided libtool dynamic loader @<:@default=auto@:>@), [system_ltdl_required=true; if test x$withval = xyes; then with_system_ltdl="/usr"; fi]) if test x$with_system_ltdl != xno; then CPPFLAGS_bkp=$CPPFLAGS LDFLAGS_bkp=$LIBS CPPFLAGS="-I$with_system_ltdl/include" LDFLAGS="-L$with_system_ltdl/lib" AC_CHECK_HEADER(ltdl.h, AC_CHECK_LIB(ltdl, lt_dlopen, have_system_ltdl=yes)) CPPFLAGS=$CPPFLAGS_bkp LDFLAGS=$LDFLAGS_bkp if test x$have_system_ltdl != xyes && test x$system_ltdl_required = xtrue; then AC_MSG_ERROR([Could not find system wide ltdl library]) fi fi if test x$have_system_ltdl != xyes; then with_ltdl_type="Convenience" else with_ltdl_type="System" INCLTDL="-I$with_system_ltdl/include" LIBLTDL="-L$with_system_ltdl/lib -lltdl" fi AC_CONFIG_SUBDIRS(libltdl) AM_CONDITIONAL(HAVE_SYSTEM_LIBLTDL, test x$have_system_ltdl = xyes) AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) AC_SUBST(LIBADD_DL) dnl ************************************************** dnl * Check for GnuTLS. * dnl ************************************************** AM_PATH_LIBGNUTLS(1.0.17, gnutls=yes, gnutls=no) if test x$gnutls != xyes; then AC_MSG_ERROR(libgnutls is required in order to build libprelude.) fi old_LIBS=$LIBS old_CPPFLAGS=$CPPFLAGS LIBS="$LIBGNUTLS_LIBS" CPPFLAGS="$LIBGNUTLS_CFLAGS" AC_CHECK_HEADER(gnutls/gnutls.h, , AC_MSG_ERROR("libgnutls development headers are required to build libprelude")) dnl dnl Recent GnuTLS version moved SRP function from libgnutls-extra to libgnutls dnl AC_CHECK_LIB(gnutls, gnutls_srp_verifier, srp_available=yes, srp_available=no) LIBS=$old_LIBS CPPFLAGS=$old_CPPFLAGS AC_SUBST(PRELUDE_ADDUSER_LIBS) AC_SUBST(PRELUDE_ADDUSER_CFLAGS) if test x$srp_available = xno; then dnl ************************************************** dnl * Check for SRP function in GnuTLS extra. * dnl ************************************************** AM_PATH_LIBGNUTLS_EXTRA(1.0.17, gnutls_extra=yes, gnutls_extra=no) if test x$gnutls_extra != xyes; then AC_MSG_ERROR(libgnutls-extra is required in order to build libprelude.) fi old_LIBS=$LIBS LIBS="$LIBGNUTLS_EXTRA_LIBS" old_CPPFLAGS=$CPPFLAGS CPPFLAGS="$LIBGNUTLS_EXTRA_CFLAGS" AC_CHECK_HEADER(gnutls/extra.h, , AC_MSG_ERROR("libgnutls-extra development headers are required to build libprelude")) AC_CHECK_LIB(gnutls-extra, gnutls_srp_verifier, srp_available=yes, AC_DEFINE_UNQUOTED(GNUTLS_SRP_DISABLED, , Define whether SRP support is disabled)) if test x$srp_available = xyes; then PRELUDE_ADDUSER_CFLAGS="-DNEED_GNUTLS_EXTRA $LIBGNUTLS_EXTRA_CFLAGS" PRELUDE_ADDUSER_LIBS="$LIBGNUTLS_EXTRA_LIBS $COMMON_LIBS" fi LIBS=$old_LIBS CPPFLAGS=$old_CPPFLAGS fi dnl ************************************************** dnl * Check for Gcrypt. * dnl ************************************************** AM_PATH_LIBGCRYPT(1:1.1.94,, AC_MSG_ERROR([[ *** *** libgcrypt was not found. You may want to get it from *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/ *** ]])) libprelude_libs="$libprelude_libs $LIBGNUTLS_LIBS $LIBGCRYPT_LIBS $COMMON_LIBS" dnl ************************************************** dnl * Check for Ipv6. * dnl ************************************************** AC_CHECK_TYPES([struct sockaddr_in6], have_ipv6_type=yes,, [ #include #include #include ]) AC_CHECK_DECL(AF_INET6, have_ipv6_def=yes,, [ #include #include #include ]) if test x$have_ipv6_type = xyes && test x$have_ipv6_def = xyes; then AC_DEFINE_UNQUOTED(HAVE_IPV6, , Define whether Ipv6 is available on this system) fi dnl ************************************************** dnl * Check for variadic macros * dnl ************************************************** AC_MSG_CHECKING(whether variadic macros are supported) AC_TRY_COMPILE( [ #include #include #define print_me(...) printf(__VA_ARGS__) ], [ print_me("test __VA_ARGS__: %s, %d, %d", "a", 0, 1); return 0; ], have_variadic_macros=yes, have_variadic_macros=no) if test x$have_variadic_macros = xyes; then AC_MSG_RESULT(yes) AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS, 1, [Define whether variadic macros are supported]) else AC_MSG_RESULT(no) fi dnl ************************************************** dnl * Do we need aligned access ? (from tcpdump) * dnl ************************************************** AC_MSG_CHECKING(if unaligned accesses fail) AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, [case "$host_cpu" in # XXX: should also check that they don't do weird things (like on arm) alpha*|arm*|hp*|mips*|sparc*|ia64) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[[1]]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then dnl failed to compile for some reason ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f conftest* core core.conftest ;; esac]) AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) if test $ac_cv_lbl_unaligned_fail = yes ; then AC_DEFINE_UNQUOTED(PRELUDE_ALIGNED_ACCESS, , Define wether we need to take care with alignment) fi dnl ************************************ dnl * va_copy checks (Thanks Glib!) * dnl ************************************ dnl dnl we currently check for all three va_copy possibilities, so we get dnl all results in config.log for bug reports. AC_CACHE_CHECK([for an implementation of va_copy()],prelude_cv_va_copy,[ AC_LINK_IFELSE([#include void f (int i, ...) { va_list args1, args2; va_start (args1, i); va_copy (args2, args1); if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; }], [prelude_cv_va_copy=yes], [prelude_cv_va_copy=no]) ]) AC_CACHE_CHECK([for an implementation of __va_copy()],prelude_cv___va_copy,[ AC_LINK_IFELSE([#include void f (int i, ...) { va_list args1, args2; va_start (args1, i); __va_copy (args2, args1); if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; }], [prelude_cv___va_copy=yes], [prelude_cv___va_copy=no]) ]) if test "x$prelude_cv_va_copy" = "xyes"; then g_va_copy_func=va_copy else if test "x$prelude_cv___va_copy" = "xyes"; then g_va_copy_func=__va_copy fi fi if test -n "$g_va_copy_func"; then AC_DEFINE_UNQUOTED(PRELUDE_VA_COPY,$g_va_copy_func,[A 'va_copy' style function]) fi AC_CACHE_CHECK([whether va_lists can be copied by value],prelude_cv_va_val_copy,[ AC_TRY_RUN([#include void f (int i, ...) { va_list args1, args2; va_start (args1, i); args2 = args1; if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; }], [prelude_cv_va_val_copy=yes], [prelude_cv_va_val_copy=no], [prelude_cv_va_val_copy=yes]) ]) if test "x$prelude_cv_va_val_copy" = "xno"; then AC_DEFINE(PRELUDE_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values]) fi dnl ************************************************** dnl * Swig support * dnl ************************************************** AC_ARG_WITH(swig, AC_HELP_STRING(--with-swig@<:@=PATH@:>@, Re-generate perl/python bindings sources @<:@default=auto@:>@), [swig_required=true; if test x$withval = xyes; then with_swig="swig"; fi], with_swig="swig") if test x$with_swig != xno; then AC_PATH_PROG(SWIG, `basename $with_swig`, no, `dirname $with_swig`:$PATH) if test x$SWIG = xno; then if test x$swig_required = xtrue; then AC_MSG_ERROR([Could not find $with_swig binary]) fi fi fi AM_CONDITIONAL(HAVE_SWIG, test x$SWIG != xno) dnl ************************************************** dnl * Perl support * dnl ************************************************** AC_ARG_WITH(perl, AC_HELP_STRING(--with-perl@<:@=PATH@:>@, Enable support for perl binding @<:@default=auto@:>@), [perl_required=true; if test x$withval = xyes; then with_perl="perl"; fi], with_perl="perl") if test x$with_perl != xno; then AC_PATH_PROG(PERL, `basename $with_perl`, no, `dirname $with_perl`:$PATH) if test x$PERL = xno; then if test x$perl_required = xtrue; then AC_MSG_ERROR([Could not find $with_perl binary]) fi with_perl=no else PERL_CFLAGS="-I`$PERL -e 'use Config; print $Config{archlib}'`/CORE" old_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PERL_CFLAGS" AC_CHECK_HEADER(EXTERN.h, [AC_CHECK_HEADER(perl.h, with_perl=yes, with_perl=no, [#include ])], with_perl=no) CPPFLAGS="$old_CPPFLAGS" fi fi AM_CONDITIONAL(HAVE_PERL, test x$with_perl = xyes) PERL_INSTALLDIRS="site" AC_ARG_WITH(perl-installdirs, AC_HELP_STRING(--with-perl-installdirs=@<:@site|vendor@:>@, Specify where to install the Perl module @<:@default=site@:>@), PERL_INSTALLDIRS="$withval") if test x$PERL_INSTALLDIRS != xsite && test x$PERL_INSTALLDIRS != xvendor; then AC_MSG_ERROR(Invalid value for --with-perl-installdirs: only "site" or "vendor" supported.) fi PERL_EXTRA_PARAMS="INSTALLDIRS=$PERL_INSTALLDIRS" AC_SUBST(PERL_EXTRA_PARAMS) dnl ************************************************** dnl * Python support * dnl ************************************************** AC_ARG_WITH(python, AC_HELP_STRING(--with-python@<:@=PATH@:>@, Enable support for python binding @<:@default=auto@:>@), [python_required=true; if test x$withval = xyes; then with_python="python"; fi], with_python="python") if test x$with_python != xno; then AC_PATH_PROG(PYTHON, `basename $with_python`, no, `dirname $with_python`:$PATH) if test x$PYTHON = xno; then if test x$python_required = xtrue; then AC_MSG_ERROR([Could not find $with_python binary]) fi with_python=no else old_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I`$PYTHON -c 'from distutils.sysconfig import get_python_inc; print get_python_inc()'`" AC_CHECK_HEADER(Python.h, with_python=yes, with_python=no) CPPFLAGS="$old_CPPFLAGS" fi fi AM_CONDITIONAL(HAVE_PYTHON, test x$with_python = xyes) dnl ************************************************** dnl * Check for missing function replacement * dnl ************************************************** gl_SOURCE_BASE(libmissing) gl_M4_BASE(libmissing/m4) gl_INIT dnl ************************************************** dnl * Check for GTK-DOC * dnl ************************************************** GTK_DOC_CHECK(1.0) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_UID_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME AC_TYPE_LONG_LONG_INT dnl Needed for FIONREAD under solaris AC_CHECK_HEADERS_ONCE(sys/filio.h sys/ioctl.h sys/un.h netinet/tcp.h) AC_CHECK_FUNCS(ftruncate chsize) prelude_config_dir=$sysconfdir/prelude prelude_spool_dir=$localstatedir/spool/prelude prelude_ident_file=$sysconfdir/prelude/sensors.ident AC_SUBST(prelude_spool_dir) AC_SUBST(prelude_config_dir) AC_SUBST(prelude_ident_file) AX_CFLAGS_GCC_OPTION(-Wall) AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes) AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes) AX_CFLAGS_GCC_OPTION(-Wmissing-declarations) AX_CFLAGS_GCC_OPTION(-Wbad-function-cast) AX_CFLAGS_GCC_OPTION(-Wcast-qual) AX_CFLAGS_GCC_OPTION(-Wcast-align) AX_CFLAGS_GCC_OPTION(-Wnested-externs) AX_CFLAGS_GCC_OPTION(-Wunused) AX_CFLAGS_GCC_OPTION(-Wformat) AX_CFLAGS_GCC_OPTION(-Wformat-security) if test x$buggy_pthread_initializers = xyes; then AX_CFLAGS_GCC_OPTION(-Wno-missing-braces) fi AC_CONFIG_FILES([ Makefile client.conf global.conf idmef-client.conf libprelude-config libmissing/Makefile m4/Makefile src/Makefile src/libprelude-error/Makefile src/include/Makefile src/include/prelude.h src/include/prelude-inttypes.h prelude-adduser/Makefile docs/Makefile docs/api/Makefile bindings/Makefile bindings/perl/Makefile.PL bindings/python/setup.py ]) AC_CONFIG_COMMANDS([default],[[ chmod +x libprelude-config ]],[[]]) AC_OUTPUT echo echo "*** Dumping configuration ***" echo " - Generate documentation : $enable_gtk_doc" echo " - Libtool dynamic loader : $with_ltdl_type" echo " - Perl binding : $with_perl" echo " - Python binding : $with_python"