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