Merge branch 'master' of git://git.evergreen-ils.org/OpenSRF
[opensrf-equinox.git] / configure.ac
index c5e04e9..3169958 100644 (file)
@@ -1,5 +1,6 @@
 # Copyright (C) 2008 Equinox Software, Inc.
 # Kevin Beswick <kevinbeswick00@gmail.com>
+# Copyright (C) 2009-2010 Dan Scott <dscott@laurentian.ca>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # Initialization
 #-------------------------------
 
+libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac,
+libtoolize: and rerunning libtoolize and aclocal.
+libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
+
+
 export PATH=${PATH}:/usr/sbin
 AC_PREREQ(2.59)
-AC_INIT([OpenSRF],[trunk],[open-ils-dev@list.georgialibraries.org])
-AM_INIT_AUTOMAKE([OpenSRF], [trunk])
-AC_REVISION($Revision: 0.1 $)
+
+# Get our version number from one file
+m4_include([version.m4])
+
+# Version number gets turned into @PACKAGE_VERSION@
+AC_INIT([OpenSRF], [VERSION_NUMBER])
 AC_CONFIG_SRCDIR([configure.ac])
-AC_PREFIX_DEFAULT([/opensrf])
-AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE
+AC_CONFIG_MACRO_DIRS([m4])
+
+AC_REVISION($Revision: 0.1 $)
 
 # Enable $prefix to resolve to a reasonable value in substitutions in
 # scripts if no explict value was passed in to configure
-if test "$prefix" = "NONE"; then
+if test "$prefix" == "NONE"; then
    prefix=$ac_default_prefix
 fi
 
 # Perl and Python scripts don't want ${prefix} if no value was specified
 eval "eval CONF_DIR=$sysconfdir"
+eval "eval PID_DIR=$localstatedir"
 AC_SUBST([CONF_DIR])
+AC_SUBST([PID_DIR])
 
 AC_SUBST(prefix)
 AC_SUBST(bindir)
@@ -58,8 +71,6 @@ AC_DEFUN([AC_PYTHON_MOD],[
         fi
 ])
 
-
-
 #-------------------------------
 # Installation options
 #-------------------------------
@@ -117,20 +128,6 @@ esac],
 AM_CONDITIONAL([BUILDPYTHON], [test x$OSRF_INSTALL_PYTHON = xtrue])
 AC_SUBST([OSRF_INSTALL_PYTHON])
 
-# enable chopchop, the basic XMPP server
-
-AC_ARG_ENABLE([chopchop],
-[  --enable-chopchop    build and install chopchop, a basic XMPP server],
-[case "${enableval}" in
-    yes) OSRF_INSTALL_CHOPCHOP=true ;;
-    no) OSRF_INSTALL_CHOPCHOP=false ;; 
-  *) AC_MSG_ERROR([please choose another value for --enable-chopchop (supported values are yes or no)]) ;;
-esac],
-[OSRF_INSTALL_CHOPCHOP=false])
-
-AM_CONDITIONAL([BUILDCHOPCHOP], [test x$OSRF_INSTALL_CHOPCHOP = xtrue])
-AC_SUBST([OSRF_INSTALL_CHOPCHOP])
-
 # enable debug?
 
 AC_ARG_ENABLE(debug,
@@ -144,7 +141,8 @@ AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
  
 # path to the directory containing the java dependency jar files (included if java installs)
 if test $OSRF_INSTALL_JAVA; then
-       AC_SUBST([OSRF_JAVA_DEPSDIR], [/opt/java])
+       AC_SUBST([OSRF_JAVA_DEPSDIR], [deps])
+    AC_CONFIG_FILES([src/java/Makefile])
 fi
 
 #--------------------------------
@@ -170,20 +168,90 @@ AC_ARG_WITH([apxs],
 [  --with-apxs=path                 location of the apxs (Apache extension) tool (default is /usr/bin/apxs2)],
 [APXS2=${withval}],
 [APXS2=/usr/bin/apxs2])
+if ! test -x "$APXS2"; then
+       for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
+               for j in apxs apxs2 ; do
+                       if test -x "$i/$j"; then
+                               APXS2="$i/$j"
+                               break
+                       fi
+               done
+       done
+fi
 AC_SUBST([APXS2])
 
 AC_ARG_WITH([apache],
 [  --with-apache=path               location of the Apache headers (default is /usr/include/apache2)],
 [APACHE2_HEADERS=${withval}],
 [APACHE2_HEADERS=/usr/include/apache2])
+if ! test -d "$APACHE2_HEADERS"; then
+       for i in /usr/include/httpd ; do
+               if test -d "$i"; then
+                       APACHE2_HEADERS="$i"
+                       break
+               fi
+       done
+fi
 AC_SUBST([APACHE2_HEADERS])
 
 AC_ARG_WITH([apr],
 [  --with-apr=path                  location of the Apache Portable Runtime headers (default is /usr/include/apr-1.0/)],
 [APR_HEADERS=${withval}],
 [APR_HEADERS=/usr/include/apr-1.0])
+if ! test -d "$APR_HEADERS"; then
+       for i in /usr/include/apr-1 ; do
+               if test -d "$i"; then
+                       APR_HEADERS="$i"
+                       break
+               fi
+       done
+fi
 AC_SUBST([APR_HEADERS])
 
+AC_ARG_WITH([perlbase],
+[  --with-perlbase=path             base location to install Perl modules (default based on Config.pm)],
+[PERL_BASE=${withval}],
+[PERL_BASE=x])
+AC_SUBST([PERL_BASE])
+
+AC_ARG_WITH([websockets-port],
+[  --with-websockets-port=path             WebSockets port to use (default is 7682)],
+[WS_PORT=${withval}],
+[WS_PORT=7682])
+AC_SUBST([WS_PORT])
+
+# The following Apache version detection code is adapted from
+# http://www.gnu.org/software/autoconf-archive/ax_prog_apache.html
+# licensed under version 2 of the GNU General Public License, or
+# (at your discretion) any later version.
+#
+# Copyright (c) 2008 Loic Dachary <loic@senga.org>
+#
+# Collect apache version number. If for nothing else, this
+# guarantees that httpd is a working apache executable.
+#
+APACHE=`$APXS2 -q progname`
+AC_PATH_PROG(APACHE_PATH, [$APACHE], [])
+if test -z "$APACHE_PATH" ; then
+       for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
+        if test -x "$i/$APACHE"; then
+            APACHE_PATH="$i/$APACHE"
+            break
+        fi
+       done
+fi
+changequote(<<, >>)dnl
+APACHE_READABLE_VERSION=`$APACHE_PATH -v | grep 'Server version' | sed -e 's;.*Apache/\([0-9\.][0-9\.]*\).*;\1;'`
+changequote([, ])dnl
+APACHE_VERSION=`echo $APACHE_READABLE_VERSION | sed -e 's/\.//g'`
+if test -z "$APACHE_VERSION" ; then
+    AC_MSG_ERROR("could not determine apache version number");
+fi
+APACHE_MAJOR=`expr $APACHE_VERSION : '\(..\)'`
+APACHE_MINOR=`expr $APACHE_VERSION : '..\(.*\)'`
+AM_CONDITIONAL(APACHE_MIN_24, test "$APACHE_MAJOR" -ge "24")
+AC_SUBST([APACHE_MIN_24])
+
 AC_ARG_WITH([libxml],
 [  --with-libxml=path               location of the libxml2 headers (default is /usr/include/libxml2/))],
 [LIBXML2_HEADERS=${withval}],
@@ -205,12 +273,12 @@ IFS="${IFS}:"
 
 for dir in $EXTRA_USER_INCLUDES; do
        if test -d "$dir"; then
-         INCLUDES="$INCLUDES -I$dir"
+         AM_CPPFLAGS="$AM_CPPFLAGS -I$dir"
        else
          AC_MSG_WARN([*** Include directory $dir does not exist.])
        fi
 done
-AC_SUBST(INCLUDES)
+AC_SUBST(AM_CPPFLAGS)
 
 for dir in $EXTRA_USER_LIBRARIES; do
        if test -d "$dir"; then
@@ -226,6 +294,28 @@ IFS=${IFSBAK}
 AC_CONFIG_FILES([Makefile
        src/Makefile])
 
+#PYTHON TESTS
+if test x$OSRF_INSTALL_PYTHON = xtrue; then
+    AC_CHECK_PROG([HAVE_PYTHON],python,yes,no)
+    if test $HAVE_PYTHON = "no"; then
+        AC_MSG_ERROR([*** python not found, aborting])
+    fi
+    AC_PYTHON_MOD([setuptools])
+    AC_CONFIG_FILES([
+        examples/math_client.py
+        examples/simple_text.py
+        src/python/Makefile
+    ])
+fi
+# Check Unit test framework
+PKG_CHECK_MODULES([CHECK], [check >= 0.9.0], [enable_tests=yes],
+                  [enable_tests=no])
+AM_CONDITIONAL(CHECK_TESTS, test x$enable_tests = xyes)
+
+if test "x$enable_tests" = "xno"; then
+  AC_MSG_WARN(Check unit testing framework not found.)
+fi
+
 if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
        #--------------------------------
        # Check for dependencies.
@@ -239,27 +329,18 @@ if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
        AC_MSG_ERROR([*** apxs not found, aborting])
        fi  
 
-       #PYTHON TESTS
-       if test x$OSRF_INSTALL_PYTHON = xtrue; then
-               AC_CHECK_PROG([HAVE_PYTHON],python,yes,no)
-               if test $HAVE_PYTHON = "no"; then
-                       AC_MSG_ERROR([*** python not found, aborting])
-               fi
-               AC_PYTHON_MOD([setuptools])
-       fi
-
-
        #-----------------------------
        # Checks for libraries.
        #-----------------------------
 
-       AC_CHECK_LIB([dl], [dlerror], [],AC_MSG_ERROR(***OpenSRF requires libdl))
-       AC_SEARCH_LIBS([mc_req_free], [memcache], [], AC_MSG_ERROR(***OpenSRF requires memcache headers))
-       AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses headers))
-       AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline headers))
-       AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires libxml2 headers))
-
-
+       AC_SEARCH_LIBS([dlerror], [dl], [],AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()]))
+       AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses development headers))
+       AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline development headers))
+       AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires xml2 development headers))
+       # Check for libmemcached and set flags accordingly
+       PKG_CHECK_MODULES(memcached, libmemcached >= 0.8.0)
+       AC_SUBST(memcached_CFLAGS)
+       AC_SUBST(memcached_LIBS)
 
        #-----------------------------
        # Checks for header files.
@@ -279,6 +360,7 @@ if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
        AC_TYPE_SIZE_T
        AC_HEADER_TIME
        AC_STRUCT_TM
+    AM_PROG_CC_C_O
 
        #----------------------------------
        # Checks for library functions.
@@ -291,7 +373,7 @@ if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
        AC_FUNC_STRFTIME
        AC_FUNC_STRTOD
        AC_FUNC_VPRINTF
-       AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol])
+       AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday malloc_stats memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol])
 
        #------------------------------------
        # Configuration and output
@@ -300,21 +382,21 @@ if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
        AC_CONFIG_FILES([doc/dokuwiki-doc-stubber.pl
                         examples/math_xul_client/Makefile
                         examples/math_bench.pl
-                        examples/math_client.py
                         examples/multisession-test.pl
                         src/c-apps/Makefile
                         src/gateway/Makefile
-                        src/java/Makefile
-                        src/jserver/Makefile
+                        src/javascript/opensrf_ws.js
+                        src/javascript/opensrf_ws_shared.js
                         src/libopensrf/Makefile
                         src/perl/Makefile
                         src/ports/strn_compat/Makefile
-                        src/python/Makefile
+                        src/python/opensrf.py
                         src/router/Makefile
                         src/srfsh/Makefile
+                        src/websocket-stdio/Makefile
+             tests/Makefile
                         bin/opensrf-perl.pl
-                        bin/osrf_config
-                        bin/osrf_ctl.sh])
+                        bin/osrf_config])
 fi
 
 AC_OUTPUT
@@ -335,17 +417,12 @@ else
         AC_MSG_RESULT([OSRF install Python support?     no])
 fi
 
-if test "$OSRF_INSTALL_CHOPCHOP" = "true" ; then
-        AC_MSG_RESULT([OSRF install chopchop?           yes])
-else
-        AC_MSG_RESULT([OSRF install chopchop?           no])
-fi
-
         AC_MSG_RESULT(Installation directory prefix:   ${prefix})
         AC_MSG_RESULT(Temporary directory:             ${TMP})
         AC_MSG_RESULT(APXS2 location:                  ${APXS2})
         AC_MSG_RESULT(Apache headers location:         ${APACHE2_HEADERS})
         AC_MSG_RESULT(APR headers location:            ${APR_HEADERS})
+        AC_MSG_RESULT(Apache version:                  ${APACHE_READABLE_VERSION})
         AC_MSG_RESULT(libxml2 headers location:        ${LIBXML2_HEADERS})
 
 AC_MSG_RESULT([----------------------------------------------------------------------])