LP#1551090: Enable mod_perl2 on Ubuntu 16.04 (Xenial Xerus).
[OpenSRF.git] / configure.ac
1 # Copyright (C) 2008 Equinox Software, Inc.
2 # Kevin Beswick <kevinbeswick00@gmail.com>
3 # Copyright (C) 2009-2010 Dan Scott <dscott@laurentian.ca>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # Process this file with autoconf to produce a configure script.
16
17
18 #-------------------------------
19 # Initialization
20 #-------------------------------
21
22 export PATH=${PATH}:/usr/sbin
23 AC_PREREQ(2.59)
24
25 # Get our version number from one file
26 m4_include([version.m4])
27
28 # Version number gets turned into @PACKAGE_VERSION@
29 AC_INIT([OpenSRF],m4_defn([VERSION_NUMBER]),[open-ils-dev@list.georgialibraries.org])
30 AM_INIT_AUTOMAKE([OpenSRF], m4_defn([VERSION_NUMBER]))
31
32 AC_REVISION($Revision: 0.1 $)
33 AC_CONFIG_SRCDIR([configure.ac])
34
35 # Enable $prefix to resolve to a reasonable value in substitutions in
36 # scripts if no explict value was passed in to configure
37 if test "$prefix" == "NONE"; then
38    prefix=$ac_default_prefix
39 fi
40
41 # Perl and Python scripts don't want ${prefix} if no value was specified
42 eval "eval CONF_DIR=$sysconfdir"
43 eval "eval PID_DIR=$localstatedir"
44 AC_SUBST([CONF_DIR])
45 AC_SUBST([PID_DIR])
46
47 AC_SUBST(prefix)
48 AC_SUBST(bindir)
49
50
51 AC_DEFUN([AC_PYTHON_MOD],[
52     if test -z $PYTHON;
53     then
54         PYTHON="python"
55     fi
56     AC_MSG_CHECKING($PYTHON_NAME module: $1)
57         $PYTHON -c "import $1" 2>/dev/null
58         if test $? -eq 0;
59         then
60                 AC_MSG_RESULT(yes)
61                 eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
62         else
63                 AC_MSG_ERROR(failed to find required module $1)
64                 exit 1
65         fi
66 ])
67
68 #-------------------------------
69 # Installation options
70 #-------------------------------
71
72 # build and install the java libs?
73 AC_ARG_ENABLE([java],
74 [  --enable-java    enable building and installing the java libraries],
75 [case "${enableval}" in
76     yes) OSRF_INSTALL_JAVA=true ;;
77     no) OSRF_INSTALL_JAVA=false ;; 
78   *) AC_MSG_ERROR([please choose another value for --enable-java (supported values are yes or no)]) ;;
79 esac],
80 [OSRF_INSTALL_JAVA=false])
81
82 AM_CONDITIONAL([BUILDJAVA], [test x$OSRF_INSTALL_JAVA = xtrue])
83 AC_SUBST([OSRF_INSTALL_JAVA])
84
85 # install the javascript files?
86 AC_ARG_ENABLE([javascript],
87 [  --disable-javascript    disable installing JavaScript libraries],
88 [case "${enableval}" in
89     yes) OSRF_INSTALL_JAVASCRIPT=true ;;
90     no) OSRF_INSTALL_JAVASCRIPT=false ;; 
91   *) AC_MSG_ERROR([please choose another value for --disable-javascript (supported values are yes or no)]) ;;
92 esac],
93 [OSRF_INSTALL_JAVASCRIPT=true])
94
95 AM_CONDITIONAL([INSTALLJAVASCRIPT], [test x$OSRF_INSTALL_JAVASCRIPT = xtrue])
96 AC_SUBST([OSRF_INSTALL_JAVASCRIPT])
97
98 # install the OpenSRF core files?
99 AC_ARG_ENABLE([core],
100 [  --disable-core    disable installing core files],
101 [case "${enableval}" in
102     yes) OSRF_INSTALL_CORE=true ;;
103     no) OSRF_INSTALL_CORE=false ;; 
104   *) AC_MSG_ERROR([please choose another value for --disable-core (supported values are yes or no)]) ;;
105 esac],
106 [OSRF_INSTALL_CORE=true])
107
108 AM_CONDITIONAL([BUILDCORE], [test x$OSRF_INSTALL_CORE = xtrue])
109 AC_SUBST([OSRF_INSTALL_CORE])
110
111
112 # build and install the python modules
113 AC_ARG_ENABLE([python],
114 [  --enable-python  enable building and installing python modules],
115 [case "${enableval}" in
116   yes) OSRF_INSTALL_PYTHON=true ;;
117   no) OSRF_INSTALL_PYTHON=false ;;
118   *) AC_MSG_ERROR([please choose another value for --enable-python (supported values are yes or no)]) ;;
119 esac],
120 [OSRF_INSTALL_PYTHON=false])
121
122 AM_CONDITIONAL([BUILDPYTHON], [test x$OSRF_INSTALL_PYTHON = xtrue])
123 AC_SUBST([OSRF_INSTALL_PYTHON])
124
125 # enable debug?
126
127 AC_ARG_ENABLE(debug,
128 [  --enable-debug    Turn on debugging],
129 [case "${enableval}" in
130   yes) debug=true ;;
131   no)  debug=false ;;
132   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
133 esac],[debug=false])
134 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
135  
136 # path to the directory containing the java dependency jar files (included if java installs)
137 if test $OSRF_INSTALL_JAVA; then
138         AC_SUBST([OSRF_JAVA_DEPSDIR], [deps])
139     AC_CONFIG_FILES([src/java/Makefile])
140 fi
141
142 #--------------------------------
143 # Checks for programs.
144 #--------------------------------
145
146 AC_PROG_LIBTOOL
147 AC_PROG_AWK
148 AC_PROG_CC
149 AC_PROG_INSTALL
150 AC_PROG_MAKE_SET
151
152 #------------------------------
153 # Set install path variables
154 #------------------------------
155 AC_ARG_WITH([tmp],
156 [  --with-tmp=path                  location for the temporary directory for OpenSRF (default is /tmp)],
157 [TMP=${withval}],
158 [TMP=/tmp])
159 AC_SUBST([TMP])
160
161 AC_ARG_WITH([apxs],
162 [  --with-apxs=path                 location of the apxs (Apache extension) tool (default is /usr/bin/apxs2)],
163 [APXS2=${withval}],
164 [APXS2=/usr/bin/apxs2])
165 if ! test -x "$APXS2"; then
166         for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
167                 for j in apxs apxs2 ; do
168                         if test -x "$i/$j"; then
169                                 APXS2="$i/$j"
170                                 break
171                         fi
172                 done
173         done
174 fi
175 AC_SUBST([APXS2])
176
177 AC_ARG_WITH([apache],
178 [  --with-apache=path               location of the Apache headers (default is /usr/include/apache2)],
179 [APACHE2_HEADERS=${withval}],
180 [APACHE2_HEADERS=/usr/include/apache2])
181 if ! test -d "$APACHE2_HEADERS"; then
182         for i in /usr/include/httpd ; do
183                 if test -d "$i"; then
184                         APACHE2_HEADERS="$i"
185                         break
186                 fi
187         done
188 fi
189 AC_SUBST([APACHE2_HEADERS])
190
191 AC_ARG_WITH([apr],
192 [  --with-apr=path                  location of the Apache Portable Runtime headers (default is /usr/include/apr-1.0/)],
193 [APR_HEADERS=${withval}],
194 [APR_HEADERS=/usr/include/apr-1.0])
195 if ! test -d "$APR_HEADERS"; then
196         for i in /usr/include/apr-1 ; do
197                 if test -d "$i"; then
198                         APR_HEADERS="$i"
199                         break
200                 fi
201         done
202 fi
203 AC_SUBST([APR_HEADERS])
204
205 # The following Apache version detection code is adapted from
206 # http://www.gnu.org/software/autoconf-archive/ax_prog_apache.html
207 # licensed under version 2 of the GNU General Public License, or
208 # (at your discretion) any later version.
209 #
210 # Copyright (c) 2008 Loic Dachary <loic@senga.org>
211 #
212 # Collect apache version number. If for nothing else, this
213 # guarantees that httpd is a working apache executable.
214 #
215 APACHE=`$APXS2 -q progname`
216 AC_PATH_PROG(APACHE_PATH, [$APACHE], [])
217 if test -z "$APACHE_PATH" ; then
218         for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
219         if test -x "$i/$APACHE"; then
220             APACHE_PATH="$i/$APACHE"
221             break
222         fi
223         done
224 fi
225 changequote(<<, >>)dnl
226 APACHE_READABLE_VERSION=`$APACHE_PATH -v | grep 'Server version' | sed -e 's;.*Apache/\([0-9\.][0-9\.]*\).*;\1;'`
227 changequote([, ])dnl
228 APACHE_VERSION=`echo $APACHE_READABLE_VERSION | sed -e 's/\.//g'`
229 if test -z "$APACHE_VERSION" ; then
230     AC_MSG_ERROR("could not determine apache version number");
231 fi
232 APACHE_MAJOR=`expr $APACHE_VERSION : '\(..\)'`
233 APACHE_MINOR=`expr $APACHE_VERSION : '..\(.*\)'`
234 AM_CONDITIONAL(APACHE_MIN_24, test "$APACHE_MAJOR" -ge "24")
235 AC_SUBST([APACHE_MIN_24])
236
237 AC_ARG_WITH([libxml],
238 [  --with-libxml=path               location of the libxml2 headers (default is /usr/include/libxml2/))],
239 [LIBXML2_HEADERS=${withval}],
240 [LIBXML2_HEADERS=/usr/include/libxml2/])
241 AC_SUBST([LIBXML2_HEADERS])
242
243 AC_ARG_WITH([includes],
244 [  --with-includes=DIRECTORIES      a colon-separated list of directories that will be added to the list the compiler searches for header files (Example: --with-includes=/path/headers:/anotherpath/moreheaders)],
245 [EXTRA_USER_INCLUDES=${withval}])
246
247 AC_ARG_WITH([libraries],
248 [  --with-libraries=DIRECTORIES     a colon-separated list of directories to search for libraries (Example: --with-libraries=/lib:/usr/lib)],
249 [EXTRA_USER_LIBRARIES=${withval}])
250
251 # Change these lists to proper compiler/linker options
252
253 IFSBAK=${IFS}
254 IFS="${IFS}:"
255
256 for dir in $EXTRA_USER_INCLUDES; do
257         if test -d "$dir"; then
258           INCLUDES="$INCLUDES -I$dir"
259         else
260           AC_MSG_WARN([*** Include directory $dir does not exist.])
261         fi
262 done
263 AC_SUBST(INCLUDES)
264
265 for dir in $EXTRA_USER_LIBRARIES; do
266         if test -d "$dir"; then
267           LIBDIRS="$LIBDIRS -L$dir"
268         else
269           AC_MSG_WARN([*** Library directory $dir does not exist.])
270         fi
271 done
272 AC_SUBST(LIBDIRS)
273
274 IFS=${IFSBAK}
275
276 AC_CONFIG_FILES([Makefile
277         src/Makefile])
278
279 #PYTHON TESTS
280 if test x$OSRF_INSTALL_PYTHON = xtrue; then
281     AC_CHECK_PROG([HAVE_PYTHON],python,yes,no)
282     if test $HAVE_PYTHON = "no"; then
283         AC_MSG_ERROR([*** python not found, aborting])
284     fi
285     AC_PYTHON_MOD([setuptools])
286     AC_CONFIG_FILES([
287         examples/math_client.py
288         examples/simple_text.py
289         src/python/Makefile
290     ])
291 fi
292 # Check Unit test framework
293 PKG_CHECK_MODULES([CHECK], [check >= 0.9.0], [enable_tests=yes],
294                   [enable_tests=no])
295 AM_CONDITIONAL(CHECK_TESTS, test x$enable_tests = xyes)
296
297 if test "x$enable_tests" = "xno"; then
298   AC_MSG_WARN(Check unit testing framework not found.)
299 fi
300
301 if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
302         #--------------------------------
303         # Check for dependencies.
304         #--------------------------------
305
306         #APACHE PREFORK DEV TEST
307         AC_MSG_CHECKING([APXS])
308         if test -f "${APXS2}"; then
309         AC_MSG_RESULT([yes])
310         else
311         AC_MSG_ERROR([*** apxs not found, aborting])
312         fi  
313
314         #-----------------------------
315         # Checks for libraries.
316         #-----------------------------
317
318         AC_SEARCH_LIBS([dlerror], [dl], [],AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()]))
319         AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses development headers))
320         AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline development headers))
321         AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires xml2 development headers))
322         # Check for libmemcached and set flags accordingly
323         PKG_CHECK_MODULES(memcached, libmemcached >= 0.8.0)
324         AC_SUBST(memcached_CFLAGS)
325         AC_SUBST(memcached_LIBS)
326
327         #-----------------------------
328         # Checks for header files.
329         #-----------------------------
330
331         AC_HEADER_STDC
332         AC_HEADER_SYS_WAIT
333         AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h])
334
335         #------------------------------------------------------------------
336         # Checks for typedefs, structures, and compiler characteristics.
337         #------------------------------------------------------------------
338
339         AC_C_CONST
340         AC_C_INLINE
341         AC_TYPE_PID_T
342         AC_TYPE_SIZE_T
343         AC_HEADER_TIME
344         AC_STRUCT_TM
345     AM_PROG_CC_C_O
346
347         #----------------------------------
348         # Checks for library functions.
349         #----------------------------------
350
351         AC_FUNC_FORK
352         AC_FUNC_MALLOC
353         AC_FUNC_SELECT_ARGTYPES
354         AC_TYPE_SIGNAL
355         AC_FUNC_STRFTIME
356         AC_FUNC_STRTOD
357         AC_FUNC_VPRINTF
358         AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday malloc_stats memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol])
359
360         #------------------------------------
361         # Configuration and output
362         #------------------------------------
363
364         AC_CONFIG_FILES([doc/dokuwiki-doc-stubber.pl
365                          examples/math_xul_client/Makefile
366                          examples/math_bench.pl
367                          examples/multisession-test.pl
368                          src/c-apps/Makefile
369                          src/gateway/Makefile
370                          src/libopensrf/Makefile
371                          src/perl/Makefile
372                          src/ports/strn_compat/Makefile
373                          src/python/opensrf.py
374                          src/router/Makefile
375                          src/srfsh/Makefile
376              tests/Makefile
377                          bin/opensrf-perl.pl
378                          bin/osrf_config])
379 fi
380
381 AC_OUTPUT
382
383 AC_MSG_RESULT([])
384 AC_MSG_RESULT([--------------------- Configuration options:  -----------------------])
385
386 if test "$OSRF_INSTALL_JAVA" = "true" ; then
387         AC_MSG_RESULT([OSRF install Java support?       yes])
388         AC_MSG_RESULT([Java support files               $OSRF_JAVA_DEPSDIR])
389 else
390         AC_MSG_RESULT([OSRF install Java support?       no])
391 fi
392
393 if test "$OSRF_INSTALL_PYTHON" = "true" ; then
394         AC_MSG_RESULT([OSRF install Python support?     yes])
395 else
396         AC_MSG_RESULT([OSRF install Python support?     no])
397 fi
398
399         AC_MSG_RESULT(Installation directory prefix:   ${prefix})
400         AC_MSG_RESULT(Temporary directory:             ${TMP})
401         AC_MSG_RESULT(APXS2 location:                  ${APXS2})
402         AC_MSG_RESULT(Apache headers location:         ${APACHE2_HEADERS})
403         AC_MSG_RESULT(APR headers location:            ${APR_HEADERS})
404         AC_MSG_RESULT(Apache version:                  ${APACHE_READABLE_VERSION})
405         AC_MSG_RESULT(libxml2 headers location:        ${LIBXML2_HEADERS})
406
407 AC_MSG_RESULT([----------------------------------------------------------------------])