51392a8a390421d7cd07231c62e067885c203295
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit, Index Data 1994-2001
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.55 2001-11-18 21:14:22 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 1.8.3)
6 dnl
7 AC_SUBST(READLINE_LIBS)
8 dnl ------ Checking programs
9 AC_PROG_CC
10 AC_PROG_CPP
11 AC_PROG_INSTALL
12 AM_DISABLE_SHARED
13 AM_PROG_LIBTOOL
14 dnl 
15 dnl ----- yaz-comp: The Yaz Compiler
16 AC_SUBST(EXTRAMODULE)
17 AC_SUBST(EXTRALIB)
18
19 EXTRAMODULE="z39.50 zutil"
20
21 AC_ARG_ENABLE(modules,[  --enable-modules=\"mod ..\" ill],[
22 if test "$enable_modules" != "no"; then
23                 EXTRAMODULE="$EXTRAMODULE $enable_modules"
24 fi
25 ],[
26 EXTRAMODULE="$EXTRAMODULE ill ccl zoom"
27 ])
28 EXTRALIB=""
29 for module in $EXTRAMODULE; do
30         EXTRALIB="$EXTRALIB ../$module/lib${module}.la"
31         if test $module = "z39.50"; then
32                 module=z3950
33         fi
34         AC_DEFINE_UNQUOTED(YAZ_MODULE_${module})
35 done
36 dnl ----- Sockets
37 checkBoth=0
38 AC_CHECK_FUNC(connect)
39 if test "$ac_cv_func_connect" = "no"; then
40         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
41 fi
42 if test "$checkBoth" = "1"; then
43         oldLibs=$LIBS
44         LIBS="$LIBS -lsocket -lnsl"
45         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
46 fi
47 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
48 dnl
49 dnl ------ Open SSL
50 openssl=no
51 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    OpenSSL library in DIR], [openssl=$withval])
52 if test "$openssl" = "yes"; then
53         AC_CHECK_LIB(crypto, main)
54         AC_CHECK_LIB(ssl, SSL_new)
55         if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
56                 AC_CHECK_HEADERS(openssl/ssl.h)
57         fi
58 fi
59 dnl ------ GNU Readline
60 READLINE_SHARED_LIBADD=""
61 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
62         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
63 )
64 READLINE_LIBS=""
65 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
66 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
67 if test "$ac_cv_lib_readline_readline" = "yes"; then
68         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
69 fi
70 dnl ------ various functions
71 AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
72 if test "$ac_cv_func_poll" = "yes"; then
73         AC_CHECK_HEADERS(sys/poll.h)
74 fi
75 dnl
76 dnl ------ tcpd
77 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
78 if test "$enable_tcpd" != ""; then
79         oldLibs=$LIBS
80         oldCPPFLAGS=$CPPFLAGS
81         if test "$enable_tcpd" != "yes"; then
82                 LIBS="$LIBS -L$enable_tcpd/lib"
83                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
84         fi
85         AC_MSG_CHECKING(for working tcpd.h)
86         LIBS="$LIBS -lwrap -lnsl"
87         AC_TRY_LINK([#include <syslog.h>
88 #include <tcpd.h>
89         int allow_severity = LOG_INFO;
90         int deny_severity = LOG_WARNING;],
91         [struct request_info request_info; int i;
92         i = hosts_access(&request_info);],
93         tcpd_ok=1, tcpd_ok=0)
94         if test "$tcpd_ok" = "0"; then
95                 AC_MSG_RESULT(no)
96                 LIBS=$oldLibs
97                 CPPFLAGS=$oldCPPFLAGS
98         else
99                 AC_MSG_RESULT(yes)
100                 AC_DEFINE(HAVE_TCPD_H)
101         fi
102 fi
103 dnl
104 dnl ------ Headers
105 AC_STDC_HEADERS
106 if test "$ac_cv_header_stdc" = "no"; then
107         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
108 fi
109 dnl
110 AC_SUBST(LIBTHREAD)
111 AC_SUBST(CFLAGSTHREADS)
112 HAVETHREADS=0
113 CFLAGSTHREADS=""
114 LIBTHREAD=""
115 dnl
116 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
117 AC_SUBST(LIBPTH)
118 if test "$enable_pth" = "yes"; then
119         OLIBS=$LIBS
120         AC_CHECK_LIB(pth,main)
121         if test "$ac_cv_lib_pth_main" = "yes"; then
122                 AC_CHECK_HEADERS(pth.h)
123                 if test "$ac_cv_header_pth_h" = "yes"; then
124                         LIBTHREAD="-lpth"
125                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
126                         HAVETHREADS=1
127                 fi
128         fi      
129         LIBS=$OLIBS
130 fi
131 dnl
132 dnl ------ POSIX Threads
133 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
134 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
135         OLIBS=$LIBS
136         OCC=$CC
137         AC_CHECK_LIB(pthread,main)
138         AC_MSG_CHECKING(for working POSIX Threads)
139         AC_TRY_LINK([#include <pthread.h>
140         void *func(void *p) { return 0; }
141         ],[
142         pthread_t pthread_id;
143         pthread_create (&pthread_id, 0, func, 0);],
144                 thread_ok=yes,thread_ok=no)
145         if test "$thread_ok" = "yes"; then
146                 AC_MSG_RESULT(yes)
147                 LIBTHREAD=-lpthread
148                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
149                 HAVETHREADS=1
150         else
151                 CC="$CC -pthread"
152                 AC_TRY_LINK([#include <pthread.h>
153                         void *func(void *p) { return 0; }
154                         ],[
155                         pthread_t pthread_id;
156                         pthread_create (&pthread_id, 0, func, 0);],
157                         thread_ok=yes,thread_ok=no)
158                 if test "$thread_ok" = "yes"; then
159                         AC_MSG_RESULT([yes,BSD])
160                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
161                         HAVETHREADS=1
162                 fi
163         fi
164         if test "$thread_ok" = "no"; then
165                 AC_MSG_RESULT(no)
166         fi
167         CC=$OCC
168         LIBS=$OLIBS
169 fi
170 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
171 dnl ------ Using this for "in-source" yaz-config
172 AC_SUBST(YAZ_SRC_ROOT)
173 AC_SUBST(YAZ_BUILD_ROOT)
174 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
175 YAZ_BUILD_ROOT=`pwd`
176 dnl
177 if test -f ${srcdir}/lib/yaz-config.in; then
178         rm ${srcdir}/lib/yaz-config.in
179 fi
180 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < ${srcdir}/yaz-config.in >${srcdir}/lib/yaz-config.in
181 dnl
182 SUBDIRS_VAR="util odr comstack $EXTRAMODULE tab retrieval server include lib include client ztest"
183 AC_SUBST(SUBDIRS_VAR)
184 dnl ------ Makefiles
185 dnl
186 AC_OUTPUT([
187 Makefile
188 util/Makefile
189 odr/Makefile
190 z39.50/Makefile
191 ill/Makefile
192 zutil/Makefile
193 comstack/Makefile
194 ccl/Makefile
195 tab/Makefile
196 retrieval/Makefile
197 server/Makefile
198 include/Makefile
199 include/yaz/Makefile
200 lib/Makefile
201 zoom/Makefile
202 client/Makefile
203 ztest/Makefile
204 doc/Makefile
205 yaz-config
206 lib/yaz-config
207 ],[chmod +x yaz-config lib/yaz-config])