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