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