LP#1824184: Change potentially slow log statements to subroutines
[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 AC_ARG_WITH([perlbase],
206 [  --with-perlbase=path             base location to install Perl modules (default based on Config.pm)],
207 [PERL_BASE=${withval}],
208 [PERL_BASE=x])
209 AC_SUBST([PERL_BASE])
210
211 AC_ARG_WITH([websockets-port],
212 [  --with-websockets-port=path             WebSockets port to use (default is 7682)],
213 [WS_PORT=${withval}],
214 [WS_PORT=7682])
215 AC_SUBST([WS_PORT])
216
217 # The following Apache version detection code is adapted from
218 # http://www.gnu.org/software/autoconf-archive/ax_prog_apache.html
219 # licensed under version 2 of the GNU General Public License, or
220 # (at your discretion) any later version.
221 #
222 # Copyright (c) 2008 Loic Dachary <loic@senga.org>
223 #
224 # Collect apache version number. If for nothing else, this
225 # guarantees that httpd is a working apache executable.
226 #
227 APACHE=`$APXS2 -q progname`
228 AC_PATH_PROG(APACHE_PATH, [$APACHE], [])
229 if test -z "$APACHE_PATH" ; then
230         for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
231         if test -x "$i/$APACHE"; then
232             APACHE_PATH="$i/$APACHE"
233             break
234         fi
235         done
236 fi
237 changequote(<<, >>)dnl
238 APACHE_READABLE_VERSION=`$APACHE_PATH -v | grep 'Server version' | sed -e 's;.*Apache/\([0-9\.][0-9\.]*\).*;\1;'`
239 changequote([, ])dnl
240 APACHE_VERSION=`echo $APACHE_READABLE_VERSION | sed -e 's/\.//g'`
241 if test -z "$APACHE_VERSION" ; then
242     AC_MSG_ERROR("could not determine apache version number");
243 fi
244 APACHE_MAJOR=`expr $APACHE_VERSION : '\(..\)'`
245 APACHE_MINOR=`expr $APACHE_VERSION : '..\(.*\)'`
246 AM_CONDITIONAL(APACHE_MIN_24, test "$APACHE_MAJOR" -ge "24")
247 AC_SUBST([APACHE_MIN_24])
248
249 AC_ARG_WITH([libxml],
250 [  --with-libxml=path               location of the libxml2 headers (default is /usr/include/libxml2/))],
251 [LIBXML2_HEADERS=${withval}],
252 [LIBXML2_HEADERS=/usr/include/libxml2/])
253 AC_SUBST([LIBXML2_HEADERS])
254
255 AC_ARG_WITH([includes],
256 [  --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)],
257 [EXTRA_USER_INCLUDES=${withval}])
258
259 AC_ARG_WITH([libraries],
260 [  --with-libraries=DIRECTORIES     a colon-separated list of directories to search for libraries (Example: --with-libraries=/lib:/usr/lib)],
261 [EXTRA_USER_LIBRARIES=${withval}])
262
263 # Change these lists to proper compiler/linker options
264
265 IFSBAK=${IFS}
266 IFS="${IFS}:"
267
268 for dir in $EXTRA_USER_INCLUDES; do
269         if test -d "$dir"; then
270           INCLUDES="$INCLUDES -I$dir"
271         else
272           AC_MSG_WARN([*** Include directory $dir does not exist.])
273         fi
274 done
275 AC_SUBST(INCLUDES)
276
277 for dir in $EXTRA_USER_LIBRARIES; do
278         if test -d "$dir"; then
279           LIBDIRS="$LIBDIRS -L$dir"
280         else
281           AC_MSG_WARN([*** Library directory $dir does not exist.])
282         fi
283 done
284 AC_SUBST(LIBDIRS)
285
286 IFS=${IFSBAK}
287
288 AC_CONFIG_FILES([Makefile
289         src/Makefile])
290
291 #PYTHON TESTS
292 if test x$OSRF_INSTALL_PYTHON = xtrue; then
293     AC_CHECK_PROG([HAVE_PYTHON],python,yes,no)
294     if test $HAVE_PYTHON = "no"; then
295         AC_MSG_ERROR([*** python not found, aborting])
296     fi
297     AC_PYTHON_MOD([setuptools])
298     AC_CONFIG_FILES([
299         examples/math_client.py
300         examples/simple_text.py
301         src/python/Makefile
302     ])
303 fi
304 # Check Unit test framework
305 PKG_CHECK_MODULES([CHECK], [check >= 0.9.0], [enable_tests=yes],
306                   [enable_tests=no])
307 AM_CONDITIONAL(CHECK_TESTS, test x$enable_tests = xyes)
308
309 if test "x$enable_tests" = "xno"; then
310   AC_MSG_WARN(Check unit testing framework not found.)
311 fi
312
313 if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
314         #--------------------------------
315         # Check for dependencies.
316         #--------------------------------
317
318         #APACHE PREFORK DEV TEST
319         AC_MSG_CHECKING([APXS])
320         if test -f "${APXS2}"; then
321         AC_MSG_RESULT([yes])
322         else
323         AC_MSG_ERROR([*** apxs not found, aborting])
324         fi  
325
326         #-----------------------------
327         # Checks for libraries.
328         #-----------------------------
329
330         AC_SEARCH_LIBS([dlerror], [dl], [],AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()]))
331         AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses development headers))
332         AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline development headers))
333         AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires xml2 development headers))
334         # Check for libmemcached and set flags accordingly
335         PKG_CHECK_MODULES(memcached, libmemcached >= 0.8.0)
336         AC_SUBST(memcached_CFLAGS)
337         AC_SUBST(memcached_LIBS)
338
339         #-----------------------------
340         # Checks for header files.
341         #-----------------------------
342
343         AC_HEADER_STDC
344         AC_HEADER_SYS_WAIT
345         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])
346
347         #------------------------------------------------------------------
348         # Checks for typedefs, structures, and compiler characteristics.
349         #------------------------------------------------------------------
350
351         AC_C_CONST
352         AC_C_INLINE
353         AC_TYPE_PID_T
354         AC_TYPE_SIZE_T
355         AC_HEADER_TIME
356         AC_STRUCT_TM
357     AM_PROG_CC_C_O
358
359         #----------------------------------
360         # Checks for library functions.
361         #----------------------------------
362
363         AC_FUNC_FORK
364         AC_FUNC_MALLOC
365         AC_FUNC_SELECT_ARGTYPES
366         AC_TYPE_SIGNAL
367         AC_FUNC_STRFTIME
368         AC_FUNC_STRTOD
369         AC_FUNC_VPRINTF
370         AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday malloc_stats memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol])
371
372         #------------------------------------
373         # Configuration and output
374         #------------------------------------
375
376         AC_CONFIG_FILES([doc/dokuwiki-doc-stubber.pl
377                          examples/math_xul_client/Makefile
378                          examples/math_bench.pl
379                          examples/multisession-test.pl
380                          src/c-apps/Makefile
381                          src/gateway/Makefile
382                          src/javascript/opensrf_ws.js
383                          src/javascript/opensrf_ws_shared.js
384                          src/libopensrf/Makefile
385                          src/perl/Makefile
386                          src/ports/strn_compat/Makefile
387                          src/python/opensrf.py
388                          src/router/Makefile
389                          src/srfsh/Makefile
390                          src/websocket-stdio/Makefile
391              tests/Makefile
392                          bin/opensrf-perl.pl
393                          bin/osrf_config])
394 fi
395
396 AC_OUTPUT
397
398 AC_MSG_RESULT([])
399 AC_MSG_RESULT([--------------------- Configuration options:  -----------------------])
400
401 if test "$OSRF_INSTALL_JAVA" = "true" ; then
402         AC_MSG_RESULT([OSRF install Java support?       yes])
403         AC_MSG_RESULT([Java support files               $OSRF_JAVA_DEPSDIR])
404 else
405         AC_MSG_RESULT([OSRF install Java support?       no])
406 fi
407
408 if test "$OSRF_INSTALL_PYTHON" = "true" ; then
409         AC_MSG_RESULT([OSRF install Python support?     yes])
410 else
411         AC_MSG_RESULT([OSRF install Python support?     no])
412 fi
413
414         AC_MSG_RESULT(Installation directory prefix:   ${prefix})
415         AC_MSG_RESULT(Temporary directory:             ${TMP})
416         AC_MSG_RESULT(APXS2 location:                  ${APXS2})
417         AC_MSG_RESULT(Apache headers location:         ${APACHE2_HEADERS})
418         AC_MSG_RESULT(APR headers location:            ${APR_HEADERS})
419         AC_MSG_RESULT(Apache version:                  ${APACHE_READABLE_VERSION})
420         AC_MSG_RESULT(libxml2 headers location:        ${LIBXML2_HEADERS})
421
422 AC_MSG_RESULT([----------------------------------------------------------------------])