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