dnl Process this file with autoconf to produce a configure script. AC_INIT AC_CONFIG_SRCDIR([src]) AC_PREREQ(2.53) AC_CANONICAL_TARGET([]) libprelude_major=0 libprelude_minor=8 libprelude_micro=10 dnl version and release information libprelude_version=$libprelude_major.$libprelude_minor.$libprelude_micro dnl library soname dnl check http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 libprelude_current=1 libprelude_revision=0 libprelude_age=1 libprelude_soname=$libprelude_current:$libprelude_revision:$libprelude_age AC_SUBST(libprelude_soname) AM_INIT_AUTOMAKE(libprelude, $libprelude_version) AM_CONFIG_HEADER(config.h) AM_DISABLE_STATIC AM_MAINTAINER_MODE dnl setup libltdl AC_CONFIG_SUBDIRS(libltdl) AC_LIBTOOL_DLOPEN AC_LIBLTDL_CONVENIENCE AM_PROG_LIBTOOL AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) dnl Checks for programs. AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_MAKE_SET AC_C_INLINE AM_PROG_LEX AC_PROG_YACC AC_SYS_LARGEFILE AC_C_BIGENDIAN(libprelude_cflags="$libprelude_cflags -DWORDS_BIGENDIAN") AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(pthread_cflags) AC_SUBST(libprelude_libs) AC_SUBST(libprelude_cflags) AC_CHECK_FUNCS(strndup) dnl ************************************************** dnl * Check for crypt library * dnl ************************************************** AC_CHECK_LIB(crypt, crypt, cryptlib=true) if test x$cryptlib = xtrue; then AC_DEFINE(HAVE_CRYPT, , 1) libprelude_libs="$libprelude_libs -lcrypt"; fi dnl ************************************************** dnl * Check for networking function * dnl ************************************************** AC_CHECK_LIB(c, inet_ntoa, libc_inet_ntoa=yes) if test x$libc_inet_ntoa != xyes; then AC_CHECK_LIB(nsl, inet_ntoa, libprelude_libs="$libprelude_libs -lnsl") fi AC_CHECK_LIB(c, socket, libc_socket=yes) if test x$libc_socket != xyes; then AC_CHECK_LIB(socket, socket, libprelude_libs="$libprelude_libs -lsocket") fi AC_CHECK_LIB(c, inet_aton, libc_inet_aton=yes) if test x$libc_inet_aton != xyes; then AC_CHECK_LIB(resolv, inet_aton, libprelude_libs="$libprelude_libs -lresolv") fi dnl ************************************************** dnl * Check for OpenSSL. * dnl ************************************************** AC_ARG_ENABLE(openssl, [ --enable-openssl Use OpenSSL to communicate with Manager [default=auto]], enable_openssl="$enableval", enable_openssl=yes) if test x$enable_openssl = xyes ; then AC_CHECK_HEADER(openssl/ssl.h, openssl_header=yes) if test x$openssl_header = xyes; then libprelude_libs="$libprelude_libs -lssl -lcrypto" AC_DEFINE(HAVE_SSL, , 1) else enable_openssl=no fi fi AM_CONDITIONAL(HAVE_SSL, test x$enable_openssl = xyes && test x$openssl_header = xyes) dnl ************************************************** dnl * Check for Pthread library * dnl ************************************************** pthrlib=no for dir in /usr /usr/local /usr/pkg; do AC_CHECK_FILE($dir/lib/libpthread.so, pthread_lib_dir=$dir) AC_CHECK_FILE($dir/lib/libpthread.dylib, pthread_lib_dir=$dir) AC_CHECK_FILE($dir/include/pthread.h, pthread_include_dir=$dir) done if test $pthread_include_dir = /usr; then pthread_include="" else pthread_include="-I$pthread_include/include" fi if test -n "$pthread_lib_dir"; then pthrlib=yes libprelude_libs="$libprelude_libs -L$pthread_lib_dir/lib -lpthread" pthread_cflags="$pthread_include -D_REENTRANT" else AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread) CFLAGS_bak=$CFLAGS CFLAGS="$CFLAGS -pthread" cat > conftest.c << EOF int main(void) { exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS >/dev/null 2>&1 CFLAGS=$CFLAGS_bak if test -x conftest; then pthrlib=yes libprelude_libs="$libprelude_libs -pthread" pthread_cflags="$pthread_cflags -D_THREAD_SAFE -D_REENTRANT $pthread_include" rm -f conftest AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi fi if test x$pthrlib != xyes; then AC_MSG_ERROR(couldn't find POSIX thread library) fi dnl ************************************************** dnl * Check for poll() * dnl ************************************************** AC_CHECK_LIB(c, poll, libc_poll=yes) if test x$libc_poll != xyes; then dnl SG: Special test for macosx, poll() is provided if libpoll dnl is installed by the Fink Package Manager http://fink.sf.net/ if test $host_cpu = "powerpc" && test $host_vendor = "apple"; then dnl save vars CFLAGS_SAVE=$CFLAGS LDFLAGS_SAVE=$LDFLAGS CPPFLAGS_SAVE=$CPPFLAGS dnl set specific macosx paths (fink) LDFLAGS="-L/sw/lib" CFLAGS="-I/sw/include" CPPFLAGS="-I/sw/include" AC_CHECK_LIB(poll, poll, libprelude_libs="$libprelude_libs -L/sw/lib -lpoll", AC_MSG_ERROR("Could not find libpoll. Try installing libpoll via the Fink Package Manager http://fink.sourceforge.net/")) AC_CHECK_HEADER(sys/poll.h, libprelude_cflags="$libprelude_cflags -I/sw/include", AC_MSG_ERROR("Could not find sys/poll.h.")) dnl restore vars CFLAGS=$CFLAGS_SAVE LDFLAGS=$LDFLAGS_SAVE CPPFLAGS=$CPPFLAGS_SAVE dnl poll() not found in libc, let's check in libpoll else AC_CHECK_LIB(poll, poll, libprelude_libs="$libprelude_libs -lpoll") fi fi dnl ************************************************** dnl * Check for socklen_t. * dnl ************************************************** AC_DATATYPE_GENERIC([ #include #include ], socklen_t, int size_t "unsigned long") 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 wether Ipv6 is available on this system) fi dnl ************************************************** dnl * Check for getaddrinfo. * dnl ************************************************** AC_CHECK_FUNC(getaddrinfo, , libprelude_cflags="$libprelude_cflags -DMISSING_GETADDRINFO") dnl ************************************************** dnl * Check for inet_ntop. * dnl ************************************************** AC_CHECK_FUNC(inet_ntop, AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, , Define wether inet_ntop is available on this system)) 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 libprelude_cflags="$libprelude_cflags -DNEED_ALIGNED_ACCESS" fi dnl ************************************************** dnl * Perl support * dnl ************************************************** AC_ARG_ENABLE(perl, [ --enable-perl Enable Perl binding [default=auto]], enable_perl="$enableval", enable_perl="yes") if test x$enable_perl = xyes; then AC_CHECK_PROG(PERL, perl, yes, no) fi if test x$enable_perl = xyes; then perl_includedir="`perl -e 'use Config; print $Config{archlib}'`/CORE" AC_CHECK_FILE($perl_includedir/perl.h, enable_perl=yes, enable_perl=no) fi if test x$enable_perl = xyes; then perl_privlib=`perl -e 'use Config; print $Config{privlib}'` if test -w $perl_privlib; then perl_dir=$perl_privlib else perl_dir=$libdir/libprelude/bindings/perl fi PERL_CFLAGS="-I$perl_includedir" AC_SUBST(perl_dir) AC_SUBST(PERL_CFLAGS) fi AM_CONDITIONAL(HAVE_PERL, test x$enable_perl = xyes) dnl ************************************************** dnl * Python support * dnl ************************************************** AC_ARG_ENABLE(python, [ --enable-python Enable Python binding [default=auto]], enable_python="$enableval", enable_python=yes) if test x$enable_python = xyes; then AC_CHECK_PROG(enable_python, python, yes, no) fi if test x$enable_python = xyes; then python_includedir=`python -c 'from distutils.sysconfig import get_python_inc print get_python_inc()'` AC_CHECK_FILE($python_includedir/Python.h, enable_python=yes, enable_python=no) fi if test x$enable_python = xyes; then python_lib_path=`python -c 'from distutils.sysconfig import get_python_lib print get_python_lib()'` if test -w $python_lib_path; then python_dir=$python_lib_path else python_dir=$libdir/libprelude/bindings/python fi PYTHON_CFLAGS="-I$python_includedir" AC_SUBST(PYTHON_CFLAGS) AC_SUBST(python_dir) fi AM_CONDITIONAL(HAVE_PYTHON, test x$enable_python = xyes) dnl ************************************************** dnl * Check for GTK-DOC * dnl ************************************************** AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ]) if test "x$with_html_dir" = "x" ; then HTML_DIR='${datadir}/gtk-doc/html'; else HTML_DIR=$with_html_dir; fi AC_SUBST(HTML_DIR) AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false) gtk_doc_min_version=0.6 if $GTKDOC; then gtk_doc_version=`gtkdoc-mkdb --version` AC_MSG_CHECKING([gtk-doc version ($gtk_doc_version) >= $gtk_doc_min_version]) if perl << EOF ; then exit (("$gtk_doc_version" =~ /^[[0-9]]+\.[[0-9]]+$/) && ("$gtk_doc_version" >= "$gtk_doc_min_version") ? 0 : 1); EOF AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); GTKDOC=false; fi fi dnl Let people disable the gtk-doc stuff. AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=no]], enable_gtk_doc="$enableval", enable_gtk_doc=no) AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes) dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME dnl Checks for library functions. AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(gettimeofday select socket strdup strerror strstr) sensors_spool_dir=$localstatedir/spool/prelude-sensors sensors_ident_file=$sysconfdir/prelude-sensors/sensors.ident sensors_config_dir=$sysconfdir/prelude-sensors AC_SUBST(sensors_spool_dir) AC_SUBST(sensors_ident_file) AC_SUBST(sensors_config_dir) dnl We use no-strict-prototype because of SSL warning. CFLAGS="$CFLAGS -Wall -Wno-strict-prototypes -Wmissing-prototypes -Wmissing-declarations \ -Wbad-function-cast -Wcast-qual -Wcast-align -Wnested-externs -Wunused" AC_SUBST(CFLAGS) AC_CONFIG_FILES([ Makefile libprelude-config src/Makefile src/include/Makefile sensor-adduser/Makefile docs/Makefile docs/api/Makefile bindings/Makefile bindings/perl/Makefile bindings/python/Makefile ]) AC_CONFIG_COMMANDS([default],[[ chmod +x libprelude-config ]],[[]]) AC_OUTPUT echo echo "*** Dumping configuration ***" echo " - Use OpenSSL : $enable_openssl" echo " - Generate documentation : $enable_gtk_doc" echo " - Perl binding : $enable_perl" echo " - Python binding : $enable_python"