Bump to 3.0.27.
[yaz-moved-to-github.git] / configure.ac
1 dnl YAZ Toolkit, Index Data 1995-2008
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.111 2008-02-21 10:48:44 adam Exp $
4 AC_PREREQ(2.60)
5 AC_INIT([yaz],[3.0.27],[yaz-help@indexdata.dk])
6 AC_CONFIG_SRCDIR(configure.ac)
7 AC_CONFIG_AUX_DIR([config])
8 AM_INIT_AUTOMAKE([1.9])
9 dnl
10 AC_SUBST(READLINE_LIBS)
11 AC_SUBST(YAZ_CONF_CFLAGS)
12 dnl ------ Checking programs
13 AC_PROG_CC
14 AC_PROG_CPP
15 AC_CHECK_PROGS(YACC, 'bison -y')
16 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
17 AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
18 AC_PROG_INSTALL
19 AM_PROG_LIBTOOL
20 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
21 dnl
22 YAZ_DOC
23 dnl 
24 dnl
25 dnl ------ Headers
26 AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h])
27 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
28  #if HAVE_SYS_TYPES_H
29  #include <sys/types.h>
30  #endif
31  #if HAVE_SYS_SOCKET_H
32  #include <sys/socket.h>
33  #endif
34  #if HAVE_NET_IF_H
35  #include <net/if.h>
36  #endif
37  #if HAVE_NETINET_IN_H
38  #include <netinet/in.h>
39  #endif
40 ])
41 AC_HEADER_STDC
42 if test "$ac_cv_header_stdc" = "no"; then
43     AC_MSG_WARN([Your system doesn not seem to support ANSI C])
44 fi
45 dnl ----- Types
46 AC_CHECK_TYPES([long long])
47 dnl
48 dnl ----- Sockets
49 checkBoth=0
50 AC_CHECK_FUNC(connect)
51 if test "$ac_cv_func_connect" = "no"; then
52     AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
53 fi
54 if test "$checkBoth" = "1"; then
55     oldLibs=$LIBS
56     LIBS="$LIBS -lsocket -lnsl"
57     AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
58 fi
59 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
60 dnl
61 dnl ------ OpenSSL
62 AC_SUBST(SSL_CFLAGS)
63 openssl=default
64 AC_ARG_WITH(openssl, [  --with-openssl[=PREFIX]   OpenSSL library in PREFIX], [openssl=$withval])
65 SSL_CFLAGS=""
66 SSL_LIBPATH=""
67 if test "$openssl" != "no"; then
68     sslver=no
69     if test "$openssl" != "yes" -a "$openssl" != "default"; then
70         if test -x $openssl/bin/pkg-config; then
71             if $openssl/bin/pkg-config --exists openssl; then
72                 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
73                 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
74                 sslver=`$openssl/bin/pkg-config --modversion openssl`
75             fi
76         fi
77         if test "$sslver" = "no"; then
78             SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
79             SSL_LIBPATH="-L$openssl/lib"
80         fi
81     else
82         if test "$pkgconfigpath" != "NONE"; then
83             if $pkgconfigpath --exists openssl; then
84                 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
85                 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
86                 sslver=`$pkgconfigpath --modversion openssl`
87             fi
88         fi
89         if test "$sslver" = "no"; then
90             SSL_CFLAGS="-I/usr/include/openssl"
91         fi
92     fi
93     if test "$sslver" = "no"; then
94         xLIBS="$LIBS";
95         xCPPFLAGS="$CPPFLAGS";
96         CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
97         AC_CHECK_LIB(crypto, main)
98         AC_CHECK_LIB(ssl, SSL_new)
99         if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
100             AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
101             LIBS="$SSL_LIBPATH $LIBS"
102         fi
103         if test "$sslver" != "yes"; then
104             LIBS="$xLIBS"
105         fi
106         CPPFLAGS="$xCPPFLAGS"
107     fi
108     AC_MSG_CHECKING([for SSL])
109     if test "$sslver" != "no"; then
110         SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
111         AC_MSG_RESULT([$sslver])
112     else
113         SSL_CFLAGS=""
114         AC_MSG_RESULT([None])
115         if test "$openssl" != "default"; then
116             AC_MSG_ERROR([OpenSSL development libraries missing])
117         fi
118     fi
119 fi
120 dnl
121 dnl ------ GNU Readline
122 READLINE_SHARED_LIBADD=""
123 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
124     AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
125 )
126 READLINE_LIBS=""
127 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
128 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
129 if test "$ac_cv_lib_readline_readline" = "yes"; then
130     AC_CHECK_HEADERS(readline/readline.h readline/history.h)
131     xLIBS=$LIBS
132     LIBS="$LIBS $READLINE_LIBS"
133     AC_TRY_LINK([
134         #include <stdio.h>
135         #include <readline/readline.h>
136             ],[
137             rl_attempted_completion_over = 0;
138             ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
139     AC_TRY_LINK([
140         #include <stdio.h>
141         #include <readline/readline.h>
142             ],[
143             rl_completion_matches (0, 0);
144             ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
145     LIBS=$xLIBS
146 fi
147 dnl ------ iconv
148 AC_ARG_WITH(iconv, [  --with-iconv[=PREFIX]     iconv library in PREFIX])
149 if test "$with_iconv" != "no"; then
150     AC_MSG_CHECKING(for iconv)
151     oldLIBS="$LIBS"
152     oldCPPFLAGS="${CPPFLAGS}"
153     if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
154         LIBS="$LIBS -L${with_iconv}/lib"
155         CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
156     fi
157     AC_TRY_LINK([
158                 #include <iconv.h>
159             ],[
160             iconv_t t = iconv_open("", "");
161             ],[
162             AC_DEFINE(HAVE_ICONV_H)
163             AC_MSG_RESULT(yes)
164             ],[
165             LIBS="$LIBS -liconv"
166             AC_TRY_LINK([
167                         #include <iconv.h>
168                     ],[
169             iconv_t t = iconv_open("", "");
170                     ],[
171             AC_DEFINE(HAVE_ICONV_H)
172             AC_MSG_RESULT(yes)
173                     ],[
174             LIBS="$oldLIBS"
175             CPPFLAGS="$oldCPPFLAGS"
176             AC_MSG_RESULT(no)
177             ])
178     ])
179 fi
180 dnl ------ various functions
181 AC_CHECK_FUNCS(getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
182 case $host in
183     *-*-darwin*)
184         trypoll="no";
185         ;;
186     *)
187         trypoll="yes";
188         ;;
189 esac
190
191 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
192     AC_CHECK_HEADERS(sys/poll.h)
193 fi
194 dnl ------ socklen_t
195 dnl We check for socklen_t by making prototypes with the
196 dnl various types. First socklen_t, then size_t, finally int.
197 dnl If the prototype succeeds, we are probably safe.
198 dnl That works if accept is not preprocessor defined (such sa AIX)
199 AC_MSG_CHECKING([for socklen_t])
200 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
201         AC_TRY_COMPILE([
202 #include <sys/types.h>
203 #include <sys/socket.h>
204 #ifdef __cplusplus
205 extern "C" {
206 #endif
207 #define try 1
208 #ifdef AIX
209 #if AIX >= 51
210 #define try 0
211 #endif
212 #endif
213 #if try
214 extern int accept(int, struct sockaddr *, socklen_t *);
215 #endif
216 #ifdef __cplusplus
217 }
218 #endif
219         ],,[ac_cv_check_socklen_t=socklen_t],[
220                 AC_TRY_COMPILE([
221 #include <sys/types.h>
222 #include <sys/socket.h>
223 #ifdef __cplusplus
224 extern "C" {
225 #endif
226 #define try 1
227 #ifdef AIX
228 #if AIX >= 42
229 #define try 0
230 #endif
231 #endif
232 #if try
233 extern int accept(int, struct sockaddr *, size_t t *);
234 #endif
235 #ifdef __cplusplus
236 }
237 #endif
238 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
239                 ])
240         ])
241 AC_MSG_RESULT($ac_cv_check_socklen_t)
242 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
243 AC_DEFINE(YAZ_USE_NEW_LOG)
244 dnl
245 dnl ------ tcpd
246 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
247 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
248     oldLibs=$LIBS
249     oldCPPFLAGS=$CPPFLAGS
250     if test "$enable_tcpd" != "yes"; then
251         LIBS="$LIBS -L$enable_tcpd/lib"
252         CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
253     fi
254     AC_MSG_CHECKING(for working tcpd.h)
255     LIBS="$LIBS -lwrap"
256     AC_TRY_LINK([#include <syslog.h>
257 #include <tcpd.h>
258             int allow_severity = LOG_INFO;
259             int deny_severity = LOG_WARNING;],
260         [struct request_info request_info; int i;
261             i = hosts_access(&request_info);],
262         tcpd_ok=1, tcpd_ok=0)
263     if test "$tcpd_ok" = "0"; then
264         AC_MSG_RESULT(no)
265         AC_MSG_ERROR([tcpd development libraries missing])
266                 LIBS=$oldLibs
267                 CPPFLAGS=$oldCPPFLAGS
268     else
269         AC_MSG_RESULT(yes)
270         AC_DEFINE(HAVE_TCPD_H)
271     fi
272 fi
273 dnl
274 AC_SUBST(YAZ_CONFIG_CFLAGS)
275 dnl ------ GNU threads
276 HAVETHREADS=0
277 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
278 AC_SUBST(LIBPTH)
279 if test "$enable_pth" = "yes"; then
280     PTH_LIBS=""
281     OLIBS=$LIBS
282     AC_CHECK_LIB(pth,main)
283     if test "$ac_cv_lib_pth_main" = "yes"; then
284         AC_CHECK_HEADERS(pth.h)
285         if test "$ac_cv_header_pth_h" = "yes"; then
286             PTH_LIBS="-lpth"
287             CFLAGS="$CFLAGS -DYAZ_GNU_THREADS=1"
288             HAVETHREADS=1
289         fi
290     fi  
291     LIBS="$OLIBS $PTH_LIBS"
292 fi
293 dnl
294 dnl ------ POSIX Threads
295 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
296 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
297     ACX_PTHREAD([
298             OCFLAGS=$CFLAGS
299             CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
300             dnl unfortunately empty thread lib spec is problematic because 
301             dnl 'yaz-config --cflags' is not always passed to linker in 
302             dnl applications using YAZ (such as Zebra).
303             if test "x$PTHREAD_LIBS" = "x"; then
304                 OLIBS=$LIBS
305                 for lib in -lpthread -lpthreads -lc_r; do
306                     LIBS="$lib $OLIBS"
307                     AC_TRY_LINK([ #include <pthread.h> ],
308                             [ pthread_t id; pthread_join(id, 0); ],
309                             [ PTHREAD_LIBS=$lib; break ]
310                         )
311                 done
312                 LIBS=$OLIBS
313             fi
314             CFLAGS=$OCFLAGS
315             PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
316             ])
317 fi
318
319 dnl ----- libXSLT/libEXLT/libXML2
320 AC_SUBST(XML2_CFLAGS)
321
322 xml_enabled=false
323 YAZ_LIBXML2(
324     [
325         AC_DEFINE(YAZ_HAVE_XML2) 
326         YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
327         xml_enabled=true
328     ]
329 )
330
331 YAZ_LIBXSLT(
332     [
333         AC_DEFINE(YAZ_HAVE_XSLT)
334         YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
335     ]
336 )
337 YAZ_LIBEXSLT(
338     [
339         AC_DEFINE(YAZ_HAVE_EXSLT)
340         YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
341     ]
342 )
343         
344 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
345
346 if test "$XML2_LIBS"; then
347     LIBS="$XML2_LIBS $LIBS"
348 fi
349
350 dnl
351 dnl 
352 AC_CHECK_ICU([3.6],[
353         if test "$xml_enabled" = "true"; then
354             ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
355         else
356             ICU_CPPFLAGS=""
357             AC_MSG_WARN([ICU support disabled because XML support is unavailable])
358         fi
359 ])
360 dnl
361 dnl ------ Memory debugging
362 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
363 if test "$enable_memdebug" = "yes"; then
364     AC_DEFINE(TRACE_XMALLOC,2)
365 elif test "$enable_memdebug" = "no"; then
366     AC_DEFINE(TRACE_XMALLOC,0)
367 fi
368 dnl
369 dnl ------ Using this for "in-source" yaz-config
370 AC_SUBST(YAZ_SRC_ROOT)
371 AC_SUBST(YAZ_BUILD_ROOT)
372 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
373 YAZ_BUILD_ROOT=`pwd`
374
375 dnl ------ windows version files
376 WIN_FILEVERSION=`echo $PACKAGE_VERSION|tr . ,`.1
377 dnl
378 dnl ------ Makefiles
379 dnl
380 AC_OUTPUT([
381 Makefile
382 yaz.spec
383 src/Makefile
384 test/Makefile
385 util/Makefile
386 include/Makefile
387 include/yaz/Makefile
388 client/Makefile
389 ztest/Makefile
390 zoom/Makefile
391 doc/Makefile
392 doc/local.ent
393 doc/common/Makefile
394 doc/common/print.dsl
395 etc/Makefile
396 yaz-config
397 yaz.pc
398 Doxyfile
399 ],[
400         sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
401     ]
402 )
403
404
405 echo \
406 "------------------------------------------------------------------------
407 Configuration:
408
409   YAZ Package:                ${PACKAGE}
410   YAZ Version:                ${VERSION}
411   Bugreport:                  ${PACKAGE_BUGREPORT}
412   Source code location:       ${srcdir}
413   C Preprocessor:             ${CPP}
414   C Preprocessor flags:       ${CPPFLAGS}
415   C Compiler:                 ${CC}
416   C Compiler flags:           ${CFLAGS}
417   Linker flags:               ${LDFLAGS}
418   Linked libs:                ${LIBS}
419   Host System Type:           ${host}
420   Install path:               ${prefix}
421   Automake:                   ${AUTOMAKE}
422   Archiver:                   ${AR}
423   Ranlib:                     ${RANLIB}
424
425 ------------------------------------------------------------------------"
426 dnl Local Variables:
427 dnl mode:shell-script
428 dnl sh-indentation: 2
429 dnl sh-basic-offset: 4
430 dnl End: