dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.13) AC_INIT(src/jmintl.h) AM_ACLOCAL_INCLUDE(macros) # Enable the enable-gnome open AC_ARG_ENABLE(gnome, [ --enable-gnome=[yes/no] turn on Gnome support], enable_gnome=yes, ) # Enable the enable-openssl options AC_ARG_ENABLE(openssl, [ --enable-openssl=[yes/no] turn on OpenSSL support], enable_openssl=yes, ) AC_ARG_WITH(openssl-includes, [ --with-openssl-includes Specify location of OpenSSL headers],[CFLAGS="$CFLAGS -I$withval"]) AC_ARG_WITH(openssl-libs, [ --with-openssl-libs Specify location of OpenSSL libs],[LDFLAGS="$LDFLAGS -L$withval"]) JM_MAJOR_VERSION=0 JM_MINOR_VERSION=1 JM_MICRO_VERSION=11 AC_SUBST(JM_MAJOR_VERSION) AC_SUBST(JM_MINOR_VERSION) AC_SUBST(JM_MICRO_VERSION) JM_VERSION=$JM_MAJOR_VERSION.$JM_MINOR_VERSION.$JM_MICRO_VERSION AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(jm, $JM_VERSION, no-define) AM_MAINTAINER_MODE AC_MSG_CHECKING([whether to build documentation from scratch]) AC_ARG_ENABLE(build-docs, [ --enable-build-docs builds documentation from scratch (for experts only)], BUILD_DOCS=$enableval, BUILD_DOCS=no) AC_MSG_RESULT($BUILD_DOCS) AM_CONDITIONAL(BUILD_DOCS, test $BUILD_DOCS = yes) AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_DEFINE_UNQUOTED(VERSION, "$VERSION") # ######################################## # Set debugging flags # Figure out debugging default, prior to $ac_help setup if test `expr $JM_MINOR_VERSION \% 2` = 1 ; then debug_default=yes else debug_default=minimum fi # Declare --enable-* args and collect ac_help strings AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] Turn on debugging [default=$debug_default]],,enable_debug=$debug_default) # Set the debug flags if test "x$enable_debug" = "xyes"; then test "$cflags_set" = set || CFLAGS="$CFLAGS -g" JM_DEBUG_FLAGS="-DG_ENABLE_DEBUG" else if test "x$enable_debug" = "xno"; then JM_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" fi fi AC_SUBST(JM_DEBUG_FLAGS) # ######################################## # Check for programs AC_ISC_POSIX AC_PROG_CC AM_PROG_CC_STDC AC_PROG_INSTALL AM_PROG_LIBTOOL # Use an many warnings as possible changequote(,)dnl if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-Wall[\ \ ]*) ;; *) CFLAGS="$CFLAGS -Wall" ;; esac if test "x$enable_ansi" = "xyes"; then case " $CFLAGS " in *[\ \ ]-ansi[\ \ ]*) ;; *) CFLAGS="$CFLAGS -ansi" ;; esac case " $CFLAGS " in *[\ \ ]-pedantic[\ \ ]*) ;; *) CFLAGS="$CFLAGS -pedantic" ;; esac fi fi changequote([,])dnl # Setup gettext (for internationalization) ALL_LINGUAS="fr de" AM_GNU_GETTEXT # ######################################## # Check for libraries # Need GNet AM_PATH_GNET(1.1.0, [LIBS="$LIBS $GNET_LIBS" CFLAGS="$CFLAGS $GNET_CFLAGS"], AC_MSG_ERROR(Cannot find GNet: Is gnet-config in path?)) CFLAGS="$CFLAGS -DGNET_EXPERIMENTAL" # Check for new GNet features AC_CHECK_FUNC(gnet_sha_clone, AC_DEFINE(HAVE_GNET_SHA_CLONE)) # Need GTK AM_PATH_GTK(1.2.7, [LIBS="$LIBS $GTK_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"], AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path?)) # Need libglade if test "x$enable_gnome" = "xyes"; then libglade_modules="gnome" else libglade_modules="gtk" fi AM_PATH_LIBGLADE([LIBS="$LIBS $LIBGLADE_LIBS" CFLAGS="$CFLAGS $LIBGLADE_CFLAGS"], AC_MSG_ERROR(Cannot find Libglade: Is libglade-config in path?), $libglade_modules) # Check for sys/sockio.h, sys/poll.h. Needed for later tests AC_CHECK_HEADERS(sys/sockio.h, AC_DEFINE(HAVE_SYS_SOCKIO_H)) AC_CHECK_HEADERS(sys/poll.h, AC_DEFINE(HAVE_SYS_POLL_H)) # ######################################## # Check for OpenSSL # Check for OpenSSL if specified if test "x$enable_openssl" = "xyes"; then # Look for ERR_load_crypto_strings in libcrypto AC_CHECK_LIB(crypto, ERR_load_crypto_strings, [LIBS="$LIBS -lcrypto"], AC_MSG_ERROR(Cannot find OpenSSL crypto library)) # Look for ERR_load_crypto_strings in libcrypto AC_CHECK_LIB(crypto, RAND_egd, [AC_DEFINE(HAVE_OPENSSL_EGD)]) # Check if OpenSSL version 0.9.4 or better AC_MSG_CHECKING([for OpenSSL version >= 0.9.4]) AC_TRY_RUN([ #include #include int main() { exit (!(OPENSSL_VERSION_NUMBER >= 0x00904100L)); return 0; } ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_OPENSSL) # Check for a good RNG AC_MSG_CHECKING([for good RNG for OpenSSL]) AC_TRY_RUN([ #include #include #include #include int main() { int randnum; /* First try as is */ RAND_bytes ((unsigned char*) &randnum, sizeof (randnum)); if (ERR_get_error()) { char buffer[4096]; /* Get the default file name */ if (!RAND_file_name (buffer, sizeof(buffer))) goto try_egd; /* Try loading the file */ if (!RAND_load_file (buffer, 256)) goto try_egd; /* Try using the RNG again */ RAND_bytes ((unsigned char*) &randnum, sizeof (randnum)); if (!ERR_get_error()) goto try_egd; goto ok; /* If there was no file, try EGD */ try_egd: #ifdef HAVE_OPENSSL_EGD if (RAND_egd("/etc/entropy") == -1) #endif exit (EXIT_FAILURE); } ok: exit (EXIT_SUCCESS); return 0; } ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) [cat << "EOF" ********************************************************************** *** You do not have a good random number generator or entropy source. *** Don't worry - Jungle Monkey will still work. However, the files *** you add to JM are vulnerable to being removed by evil hackers. *** You should have your system administrator install a good entropy *** source. We recommend using OpenSSL 0.9.5 (or better) with the *** Entropy Gathering Daemon (EGD), available at *** http://www.lothar.com/tech/crypto. JM looks at $RANDFILE, *** $HOME/.rnd, and /etc/entropy for a RNG seed or entropy source. ********************************************************************** EOF] ],[ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) ],[ AC_MSG_ERROR(The OpenSSL development files are not installed or the installed OpenSSL library is too old.) ],[ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) fi # ######################################## # Checks for Gnome JM_GLADE_FILE="jm.glade" JM_GNOME_PIXMAP_FILE="" JM_GNOME_DESKTOP_FILE="" JM_HELPDIR="/doc/jm/html" if test "x$enable_gnome" = "xyes"; then GNOME_INIT_HOOK([ CFLAGS="$CFLAGS $GNOME_INCLUDEDIR -DJM_ENABLE_GNOME" LIBS="$LIBS $GNOME_LIBS $GNOMEUI_LIBS" JM_GLADE_FILE="jm-gnome.glade" JM_GNOME_PIXMAP_FILE="jm-logo.png" JM_GNOME_DESKTOP_FILE="jm.desktop" JM_HELPDIR="/gnome/help/jm/C" ], fail) else # If I don't have Gnome, I need the popt library straight # Need Popt option parsing library AC_CHECK_LIB(popt, poptPrintUsage, [LIBS="$LIBS -lpopt"], AC_MSG_ERROR(Cannot find Popt option parsing library (or you have an old version))) fi AC_SUBST(JM_GLADE_FILE) AC_SUBST(JM_GNOME_PIXMAP_FILE) AC_SUBST(JM_GNOME_DESKTOP_FILE) AC_SUBST(JM_HELPDIR) # ######################################## # Checks for header files. AC_HEADER_STDC #################### # Check for strict poll AC_ARG_ENABLE(strict-poll, [ --enable-strict-poll=[yes/no] turn on strict poll workaround], strict_poll=yes, ) AC_MSG_CHECKING([for strict poll]) if test "x$strict_poll" = "xyes"; then AC_MSG_RESULT([yes, --enable-strict-poll set]) AC_DEFINE(HAVE_STRICT_POLL) else AC_TRY_RUN([ #include #include #include #include #include #define NUMPOLLFD 33 /* In newer Linux kernels, this fails if > 32, which is NR_OPEN_DEFAULT defined in include/linux/sched.h */ static struct pollfd pollfds[NUMPOLLFD]; int main() { int i; int status; /* Set up a poll struct */ for (i = 0; i < NUMPOLLFD; ++i) { pollfds[i].fd = STDOUT_FILENO; pollfds[i].events = POLLHUP; pollfds[i].revents = 0; } /* Do the poll */ if (poll(pollfds, NUMPOLLFD, 1) == -1) status = EXIT_FAILURE; else status = EXIT_SUCCESS; exit (status); return 0; } ], AC_MSG_RESULT(no), strict_poll=yes AC_MSG_RESULT(yes) [cat << "EOF" ********************************************************************** *** The system call `poll' is strict on this system. GLib assumes *** that poll is not strict. Don't worry - Jungle Monkey can work *** around this, though it may be a bit slower. See GLib bug 11059 *** on http://bugzilla.gnome.org for more information. ********************************************************************** EOF] AC_DEFINE(HAVE_STRICT_POLL), [echo $ac_n "cross compiling; assumed OK... $ac_c"] ) fi # Check if needs to be included for fd_set AC_MSG_CHECKING([for fd_set]) AC_TRY_COMPILE([#include ], [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no) if test $gtk_ok = yes; then AC_MSG_RESULT([yes, found in sys/types.h]) else AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes) if test $gtk_ok = yes; then AC_DEFINE(HAVE_SYS_SELECT_H) AC_MSG_RESULT([yes, found in sys/select.h]) else AC_DEFINE(NO_FD_SET) AC_MSG_RESULT(no) fi fi AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H)) AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H)) #################### # Check for broken bind AC_ARG_ENABLE(broken-bind, [ --enable-broken-bind=[yes/no] turn on broken bind workaround], broken_bind=yes, ) AC_MSG_CHECKING([for broken bind/SO_REUSEADDR]) if test "x$broken_bind" = "xyes"; then AC_MSG_RESULT([yes, --enable-broken-bind set]) AC_DEFINE(HAVE_BROKEN_BIND_REUSEADDR) else AC_TRY_RUN([ #include #include #include #include #include #include #include #include #include #define MYASSERT(c) { if (!(c)) { printf("assert failed on line %d. I guess this ok.\n", __LINE__); exit(EXIT_SUCCESS);}} int main() { int sockfd; struct sockaddr sa; struct sockaddr_in* sa_in; int sockfd2; struct sockaddr sa2; struct sockaddr_in* sa_in2; int on = 1; int testport = 3521; int num_attempts = 0; /* **************************************** */ /* Create first socket */ /* Create socket */ sockfd = socket(AF_INET, SOCK_STREAM, 0); MYASSERT (sockfd >= 0); /* Set REUSEADDR so we can reuse the port */ on = 1; MYASSERT (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*) &on, sizeof(on)) == 0); try_again: /* Set up address and port for connection */ sa_in = (struct sockaddr_in*) &sa; sa_in->sin_family = AF_INET; sa_in->sin_addr.s_addr = htonl(INADDR_ANY); sa_in->sin_port = htons(testport); /* Bind */ if (bind(sockfd, &sa, sizeof(sa)) != 0) { /* Try another port */ testport += 731; /* move up 731 ports - hopefully next port is free */ MYASSERT (++num_attempts < 16); goto try_again; } /* Listen */ MYASSERT (listen(sockfd, 10) == 0); /* **************************************** */ /* Create second socket */ /* Create socket */ sockfd2 = socket(AF_INET, SOCK_STREAM, 0); MYASSERT (sockfd2 >= 0); /* Set up address and port for connection */ sa_in2 = (struct sockaddr_in*) &sa2; sa_in2->sin_family = AF_INET; sa_in2->sin_addr.s_addr = htonl(INADDR_ANY); sa_in2->sin_port = htons(testport); /* Set REUSEADDR so we can reuse the port */ on = 1; MYASSERT (setsockopt(sockfd2, SOL_SOCKET, SO_REUSEADDR, (void*) &on, sizeof(on)) == 0); /* Bind - should fail */ if (bind(sockfd2, &sa2, sizeof(sa2)) == 0) exit (EXIT_FAILURE); /* bind should not success */ else exit (EXIT_SUCCESS); exit (EXIT_SUCCESS); return 0; } ], AC_MSG_RESULT(no), AC_MSG_RESULT(yes) AC_DEFINE(HAVE_BROKEN_BIND_REUSEADDR) [cat << "EOF" ********************************************************************** *** The system call `bind' seems to be broken (it doesn't handle *** setsockopt SO_REUSEADDR properly). This probably means *** you're using Linux 2.2.10. Don't worry - Jungle Monkey can work *** around this. If you don't have Linux 2.2.10 and you see *** you see this message, please write the Jungle Monkey team at *** jm-dev@eecs.umich.edu. ********************************************************************** EOF], [echo $ac_n "cross compiling; assumed OK... $ac_c"] ) fi # ######################################## # Checks for library functions. # ######################################## AC_OUTPUT([Makefile src/Makefile src/util/Makefile src/btp/Makefile src/crp/Makefile src/mtp/Makefile src/jmchat/Makefile src/jmmsearch/Makefile src/jmchannel/Makefile src/jmlite/Makefile src/gtkgnome/Makefile src/gtkgnome/glade/Makefile src/icons/Makefile doc/Makefile doc/C/Makefile pixmaps/Makefile intl/Makefile po/Makefile.in jm.spec jm-gnome.spec])