Provide a mechanism whereby a server drone can terminate immediately,
[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 AC_INIT([OpenSRF],[trunk],[open-ils-dev@list.georgialibraries.org])
25 AM_INIT_AUTOMAKE([OpenSRF], [trunk])
26 AC_REVISION($Revision: 0.1 $)
27 AC_CONFIG_SRCDIR([configure.ac])
28 AC_PREFIX_DEFAULT([/opensrf])
29 AC_CONFIG_MACRO_DIR([m4])
30
31 # Enable $prefix to resolve to a reasonable value in substitutions in
32 # scripts if no explict value was passed in to configure
33 if test "$prefix" == "NONE"; then
34    prefix=$ac_default_prefix
35 fi
36
37 # Perl and Python scripts don't want ${prefix} if no value was specified
38 eval "eval CONF_DIR=$sysconfdir"
39 AC_SUBST([CONF_DIR])
40
41 AC_SUBST(prefix)
42 AC_SUBST(bindir)
43
44
45 AC_DEFUN([AC_PYTHON_MOD],[
46     if test -z $PYTHON;
47     then
48         PYTHON="python"
49     fi
50     AC_MSG_CHECKING($PYTHON_NAME module: $1)
51         $PYTHON -c "import $1" 2>/dev/null
52         if test $? -eq 0;
53         then
54                 AC_MSG_RESULT(yes)
55                 eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
56         else
57                 AC_MSG_ERROR(failed to find required module $1)
58                 exit 1
59         fi
60 ])
61
62 #-------------------------------
63 # Installation options
64 #-------------------------------
65
66 # build and install the java libs?
67 AC_ARG_ENABLE([java],
68 [  --enable-java    enable building and installing the java libraries],
69 [case "${enableval}" in
70     yes) OSRF_INSTALL_JAVA=true ;;
71     no) OSRF_INSTALL_JAVA=false ;; 
72   *) AC_MSG_ERROR([please choose another value for --enable-java (supported values are yes or no)]) ;;
73 esac],
74 [OSRF_INSTALL_JAVA=false])
75
76 AM_CONDITIONAL([BUILDJAVA], [test x$OSRF_INSTALL_JAVA = xtrue])
77 AC_SUBST([OSRF_INSTALL_JAVA])
78
79 # install the javascript files?
80 AC_ARG_ENABLE([javascript],
81 [  --disable-javascript    disable installing JavaScript libraries],
82 [case "${enableval}" in
83     yes) OSRF_INSTALL_JAVASCRIPT=true ;;
84     no) OSRF_INSTALL_JAVASCRIPT=false ;; 
85   *) AC_MSG_ERROR([please choose another value for --disable-javascript (supported values are yes or no)]) ;;
86 esac],
87 [OSRF_INSTALL_JAVASCRIPT=true])
88
89 AM_CONDITIONAL([INSTALLJAVASCRIPT], [test x$OSRF_INSTALL_JAVASCRIPT = xtrue])
90 AC_SUBST([OSRF_INSTALL_JAVASCRIPT])
91
92 # install the OpenSRF core files?
93 AC_ARG_ENABLE([core],
94 [  --disable-core    disable installing core files],
95 [case "${enableval}" in
96     yes) OSRF_INSTALL_CORE=true ;;
97     no) OSRF_INSTALL_CORE=false ;; 
98   *) AC_MSG_ERROR([please choose another value for --disable-core (supported values are yes or no)]) ;;
99 esac],
100 [OSRF_INSTALL_CORE=true])
101
102 AM_CONDITIONAL([BUILDCORE], [test x$OSRF_INSTALL_CORE = xtrue])
103 AC_SUBST([OSRF_INSTALL_CORE])
104
105
106 # build and install the python modules
107 AC_ARG_ENABLE([python],
108 [  --enable-python  enable building and installing python modules],
109 [case "${enableval}" in
110   yes) OSRF_INSTALL_PYTHON=true ;;
111   no) OSRF_INSTALL_PYTHON=false ;;
112   *) AC_MSG_ERROR([please choose another value for --enable-python (supported values are yes or no)]) ;;
113 esac],
114 [OSRF_INSTALL_PYTHON=false])
115
116 AM_CONDITIONAL([BUILDPYTHON], [test x$OSRF_INSTALL_PYTHON = xtrue])
117 AC_SUBST([OSRF_INSTALL_PYTHON])
118
119 # enable chopchop, the basic XMPP server
120
121 AC_ARG_ENABLE([chopchop],
122 [  --enable-chopchop    build and install chopchop, a basic XMPP server],
123 [case "${enableval}" in
124     yes) OSRF_INSTALL_CHOPCHOP=true ;;
125     no) OSRF_INSTALL_CHOPCHOP=false ;; 
126   *) AC_MSG_ERROR([please choose another value for --enable-chopchop (supported values are yes or no)]) ;;
127 esac],
128 [OSRF_INSTALL_CHOPCHOP=false])
129
130 AM_CONDITIONAL([BUILDCHOPCHOP], [test x$OSRF_INSTALL_CHOPCHOP = xtrue])
131 AC_SUBST([OSRF_INSTALL_CHOPCHOP])
132
133 # enable debug?
134
135 AC_ARG_ENABLE(debug,
136 [  --enable-debug    Turn on debugging],
137 [case "${enableval}" in
138   yes) debug=true ;;
139   no)  debug=false ;;
140   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
141 esac],[debug=false])
142 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
143  
144 # path to the directory containing the java dependency jar files (included if java installs)
145 if test $OSRF_INSTALL_JAVA; then
146         AC_SUBST([OSRF_JAVA_DEPSDIR], [/opt/java])
147     AC_CONFIG_FILES([src/java/Makefile])
148 fi
149
150 #--------------------------------
151 # Checks for programs.
152 #--------------------------------
153
154 AC_PROG_LIBTOOL
155 AC_PROG_AWK
156 AC_PROG_CC
157 AC_PROG_INSTALL
158 AC_PROG_MAKE_SET
159
160 #------------------------------
161 # Set install path variables
162 #------------------------------
163 AC_ARG_WITH([tmp],
164 [  --with-tmp=path                  location for the temporary directory for OpenSRF (default is /tmp)],
165 [TMP=${withval}],
166 [TMP=/tmp])
167 AC_SUBST([TMP])
168
169 AC_ARG_WITH([apxs],
170 [  --with-apxs=path                 location of the apxs (Apache extension) tool (default is /usr/bin/apxs2)],
171 [APXS2=${withval}],
172 [APXS2=/usr/bin/apxs2])
173 if ! test -x "$APXS2"; then
174         for i in /usr/bin /usr/sbin /usr/local/apache/bin /usr/local/apache2/bin ; do
175                 for j in apxs apxs2 ; do
176                         if test -x "$i/$j"; then
177                                 APXS2="$i/$j"
178                                 break
179                         fi
180                 done
181         done
182 fi
183 AC_SUBST([APXS2])
184
185 AC_ARG_WITH([apache],
186 [  --with-apache=path               location of the Apache headers (default is /usr/include/apache2)],
187 [APACHE2_HEADERS=${withval}],
188 [APACHE2_HEADERS=/usr/include/apache2])
189 if ! test -d "$APACHE2_HEADERS"; then
190         for i in /usr/include/httpd ; do
191                 if test -d "$i"; then
192                         APACHE2_HEADERS="$i"
193                         break
194                 fi
195         done
196 fi
197 AC_SUBST([APACHE2_HEADERS])
198
199 AC_ARG_WITH([apr],
200 [  --with-apr=path                  location of the Apache Portable Runtime headers (default is /usr/include/apr-1.0/)],
201 [APR_HEADERS=${withval}],
202 [APR_HEADERS=/usr/include/apr-1.0])
203 if ! test -d "$APR_HEADERS"; then
204         for i in /usr/include/apr-1 ; do
205                 if test -d "$i"; then
206                         APR_HEADERS="$i"
207                         break
208                 fi
209         done
210 fi
211 AC_SUBST([APR_HEADERS])
212
213 AC_ARG_WITH([libxml],
214 [  --with-libxml=path               location of the libxml2 headers (default is /usr/include/libxml2/))],
215 [LIBXML2_HEADERS=${withval}],
216 [LIBXML2_HEADERS=/usr/include/libxml2/])
217 AC_SUBST([LIBXML2_HEADERS])
218
219 AC_ARG_WITH([includes],
220 [  --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)],
221 [EXTRA_USER_INCLUDES=${withval}])
222
223 AC_ARG_WITH([libraries],
224 [  --with-libraries=DIRECTORIES     a colon-separated list of directories to search for libraries (Example: --with-libraries=/lib:/usr/lib)],
225 [EXTRA_USER_LIBRARIES=${withval}])
226
227 # Change these lists to proper compiler/linker options
228
229 IFSBAK=${IFS}
230 IFS="${IFS}:"
231
232 for dir in $EXTRA_USER_INCLUDES; do
233         if test -d "$dir"; then
234           INCLUDES="$INCLUDES -I$dir"
235         else
236           AC_MSG_WARN([*** Include directory $dir does not exist.])
237         fi
238 done
239 AC_SUBST(INCLUDES)
240
241 for dir in $EXTRA_USER_LIBRARIES; do
242         if test -d "$dir"; then
243           LIBDIRS="$LIBDIRS -L$dir"
244         else
245           AC_MSG_WARN([*** Library directory $dir does not exist.])
246         fi
247 done
248 AC_SUBST(LIBDIRS)
249
250 IFS=${IFSBAK}
251
252 AC_CONFIG_FILES([Makefile
253         src/Makefile])
254
255 #PYTHON TESTS
256 if test x$OSRF_INSTALL_PYTHON = xtrue; then
257     AC_CHECK_PROG([HAVE_PYTHON],python,yes,no)
258     if test $HAVE_PYTHON = "no"; then
259         AC_MSG_ERROR([*** python not found, aborting])
260     fi
261     AC_PYTHON_MOD([setuptools])
262     AC_CONFIG_FILES([
263         examples/math_client.py
264         src/python/Makefile
265     ])
266 fi
267
268 if test "x$OSRF_INSTALL_CORE" = "xtrue"; then
269         #--------------------------------
270         # Check for dependencies.
271         #--------------------------------
272
273         #APACHE PREFORK DEV TEST
274         AC_MSG_CHECKING([APXS])
275         if test -f "${APXS2}"; then
276         AC_MSG_RESULT([yes])
277         else
278         AC_MSG_ERROR([*** apxs not found, aborting])
279         fi  
280
281         #-----------------------------
282         # Checks for libraries.
283         #-----------------------------
284
285         AC_SEARCH_LIBS([dlerror], [dl], [],AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()]))
286         AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses development headers))
287         AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline development headers))
288         AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires xml2 development headers))
289         # Check for libmemcached and set flags accordingly
290         PKG_CHECK_MODULES(memcached, libmemcached >= 0.8.0)
291         AC_SUBST(memcached_CFLAGS)
292         AC_SUBST(memcached_LIBS)
293
294         #-----------------------------
295         # Checks for header files.
296         #-----------------------------
297
298         AC_HEADER_STDC
299         AC_HEADER_SYS_WAIT
300         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])
301
302         #------------------------------------------------------------------
303         # Checks for typedefs, structures, and compiler characteristics.
304         #------------------------------------------------------------------
305
306         AC_C_CONST
307         AC_C_INLINE
308         AC_TYPE_PID_T
309         AC_TYPE_SIZE_T
310         AC_HEADER_TIME
311         AC_STRUCT_TM
312
313         #----------------------------------
314         # Checks for library functions.
315         #----------------------------------
316
317         AC_FUNC_FORK
318         AC_FUNC_MALLOC
319         AC_FUNC_SELECT_ARGTYPES
320         AC_TYPE_SIGNAL
321         AC_FUNC_STRFTIME
322         AC_FUNC_STRTOD
323         AC_FUNC_VPRINTF
324         AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday malloc_stats memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol])
325
326         #------------------------------------
327         # Configuration and output
328         #------------------------------------
329
330         AC_CONFIG_FILES([doc/dokuwiki-doc-stubber.pl
331                          examples/math_xul_client/Makefile
332                          examples/math_bench.pl
333                          examples/multisession-test.pl
334                          src/c-apps/Makefile
335                          src/gateway/Makefile
336                          src/jserver/Makefile
337                          src/libopensrf/Makefile
338                          src/perl/Makefile
339                          src/ports/strn_compat/Makefile
340                          src/router/Makefile
341                          src/srfsh/Makefile
342                          bin/opensrf-perl.pl
343                          bin/osrf_config
344                          bin/osrf_ctl.sh])
345 fi
346
347 AC_OUTPUT
348
349 AC_MSG_RESULT([])
350 AC_MSG_RESULT([--------------------- Configuration options:  -----------------------])
351
352 if test "$OSRF_INSTALL_JAVA" = "true" ; then
353         AC_MSG_RESULT([OSRF install Java support?       yes])
354         AC_MSG_RESULT([Java support files               $OSRF_JAVA_DEPSDIR])
355 else
356         AC_MSG_RESULT([OSRF install Java support?       no])
357 fi
358
359 if test "$OSRF_INSTALL_PYTHON" = "true" ; then
360         AC_MSG_RESULT([OSRF install Python support?     yes])
361 else
362         AC_MSG_RESULT([OSRF install Python support?     no])
363 fi
364
365 if test "$OSRF_INSTALL_CHOPCHOP" = "true" ; then
366         AC_MSG_RESULT([OSRF install chopchop?           yes])
367 else
368         AC_MSG_RESULT([OSRF install chopchop?           no])
369 fi
370
371         AC_MSG_RESULT(Installation directory prefix:   ${prefix})
372         AC_MSG_RESULT(Temporary directory:             ${TMP})
373         AC_MSG_RESULT(APXS2 location:                  ${APXS2})
374         AC_MSG_RESULT(Apache headers location:         ${APACHE2_HEADERS})
375         AC_MSG_RESULT(APR headers location:            ${APR_HEADERS})
376         AC_MSG_RESULT(libxml2 headers location:        ${LIBXML2_HEADERS})
377
378 AC_MSG_RESULT([----------------------------------------------------------------------])