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