SSL comstack now uses yaz.pem certificate file on server side
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit, Index Data 1994-2004
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.137 2004-04-28 22:44:58 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.19)
6 AM_MAINTAINER_MODE
7 dnl
8 AC_SUBST(READLINE_LIBS)
9 AC_SUBST(YAZ_CONF_CFLAGS)
10 dnl ------ Checking programs
11 AC_PROG_CC
12 AC_PROG_CPP
13 AC_CHECK_PROGS(YACC, 'bison -y')
14 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
15 AC_PROG_INSTALL
16 AM_DISABLE_SHARED
17 AM_PROG_LIBTOOL
18 AC_PATH_PROG(pkgconfig, pkg-config, NONE)
19 dnl
20 dnl ----- DOCBOOK DTD
21 AC_SUBST(DTD_DIR)
22 AC_ARG_WITH(dtd, [  --with-dtd[=DIR]        use docbookx.dtd in DIR],
23 [
24    if test -f "$withval/docbookx.dtd"; then
25       DTD_DIR=$withval
26    fi
27 ],[
28    AC_MSG_CHECKING(for docbookx.dtd)
29    for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
30          /usr/share/sgml/docbook/xml-dtd-4.1.2* \
31          /usr/share/sgml/docbook/xml-dtd-4.1 \
32          /usr/share/sgml/docbook/dtd/xml/4.0 \
33             /usr/lib/sgml/dtd/docbook-xml 
34    do
35      if test -f $d/docbookx.dtd; then
36        AC_MSG_RESULT($d)
37        DTD_DIR=$d
38        break
39      fi
40    done
41    if test -z "$DTD_DIR"; then
42       AC_MSG_RESULT(Not found)
43    fi
44 ])
45 AC_SUBST(DSSSL_DIR)
46 AC_ARG_WITH(dsssl,[  --with-dsssl[=DIR]      use Docbook DSSSL in DIR/{html,print}/docbook.dsl],
47 [
48    if test -f "$withval/html/docbook.dsl"; then
49       DSSSL_DIR=$withval
50    fi
51 ],[
52    AC_MSG_CHECKING(for docbook.dsl)
53    for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
54             /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
55             /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh 
56    do
57      if test -f $d/html/docbook.dsl; then
58        AC_MSG_RESULT($d)
59        DSSSL_DIR=$d
60        break
61      fi
62    done
63    if test -z "$DSSSL_DIR"; then
64       AC_MSG_RESULT(Not found)
65    fi
66 ])
67 AC_SUBST(XSL_DIR)
68 AC_ARG_WITH(xsl,[  --with-xsl[=DIR]        use Docbook XSL in DIR/{htmlhelp,xhtml}],
69 [
70    if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
71       XSL_DIR=$withval
72    fi
73 ],[
74    AC_MSG_CHECKING(for htmlhelp.xsl)
75    for d in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh \
76             /usr/share/sgml/docbook/xsl-stylesheets-1.* 
77    do
78      if test -f $d/htmlhelp/htmlhelp.xsl; then
79        AC_MSG_RESULT($d)
80        XSL_DIR=$d
81        break
82      fi
83    done
84    if test -z "$XSL_DIR"; then
85       AC_MSG_RESULT(Not found)
86    fi
87 ])
88 dnl 
89 dnl ----- Sockets
90 checkBoth=0
91 AC_CHECK_FUNC(connect)
92 if test "$ac_cv_func_connect" = "no"; then
93         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
94 fi
95 if test "$checkBoth" = "1"; then
96         oldLibs=$LIBS
97         LIBS="$LIBS -lsocket -lnsl"
98         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
99 fi
100 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
101 dnl
102 dnl ------ OpenSSL
103 openssl=no
104 AC_ARG_WITH(openssl, [  --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
105 AC_SUBST(SSL_CFLAGS)
106 AC_SUBST(SSL_LIBS)
107 AC_SUBST(SSL_DEFS)
108 USE_SSL=0
109 SSL_CFLAGS=""
110 SSL_LIBS=""
111 SSL_DEFS=""
112 if test "$openssl" != "no"; then
113         sslver=no
114         xLIBS="$LIBS";
115         xCFLAGS="$CFLAGS";
116         if test "$openssl" != "yes"; then
117                 if $openssl/bin/pkg-config --exists openssl; then
118                         SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
119                         SSL_LIBS=`$openssl/bin/pkg-config --libs openssl`
120                         sslver=`$openssl/bin/pkg-config --modversion openssl`
121                 else
122                         SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
123                         SSL_LIBS="-L$openssl/lib"
124                         CFLAGS="$SSL_CFLAGS $CFLAGS"
125                         LIBS="$SSL_LIBS $LIBS"
126                 fi
127         else
128                 if $pkgconfig --exists openssl; then
129                         SSL_CFLAGS=`$pkgconfig --cflags openssl`
130                         SSL_LIBS=`$pkgconfig --libs openssl`
131                         sslver=`$pkgconfig --modversion openssl`
132                 fi      
133         fi
134         if test "$sslver" = "no"; then
135                 AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
136                 LIBS="$LIBS $SSL_LIBS"
137                 AC_CHECK_LIB(ssl, SSL_new)
138                 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
139                         AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
140                 fi
141                 if test "$sslver" = "yes"; then
142                         SSL_LIBS="-lssl $SSL_LIBS"
143                 fi
144         fi
145         if test "$sslver" != "no"; then
146                 SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"
147                 USE_SSL=1
148         fi
149         AC_MSG_CHECKING([for SSL])
150         AC_MSG_RESULT($sslver)
151         LIBS="$xLIBS"
152         CFLAGS="$xCFLAGS"
153 fi
154 dnl
155 dnl ------ GNU Readline
156 READLINE_SHARED_LIBADD=""
157 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
158         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
159 )
160 READLINE_LIBS=""
161 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
162 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
163 if test "$ac_cv_lib_readline_readline" = "yes"; then
164         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
165         xLIBS=$LIBS
166         LIBS="$LIBS $READLINE_LIBS"
167         AC_TRY_LINK([
168         #include <stdio.h>
169         #include <readline/readline.h>
170         ],[
171         static void f()
172         {
173                 rl_attempted_completion_over = 0;
174         }
175         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
176         AC_TRY_LINK([
177         #include <stdio.h>
178         #include <readline/readline.h>
179         ],[
180         static void f()
181         {
182                 rl_completion_matches (0, 0);
183         }
184         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
185         LIBS=$xLIBS
186 fi
187 dnl ------ iconv
188 AC_ARG_WITH(iconv, [  --with-iconv[=PREFIX]   iconv library in PREFIX])
189 if test "$with_iconv" != "no"; then
190         AC_MSG_CHECKING(for iconv)
191         oldLIBS="$LIBS"
192         oldCPPFLAGS="${CPPFLAGS}"
193         if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
194                 LIBS="$LIBS -L${with_iconv}/lib"
195                 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
196         fi
197         AC_TRY_LINK([
198                 #include <iconv.h>
199         ],[
200                 static void f() {iconv_t t = iconv_open("", ""); }
201         ],[
202                 AC_DEFINE(HAVE_ICONV_H)
203                 AC_MSG_RESULT(yes)
204         ],[
205                 LIBS="$LIBS -liconv"
206                 AC_TRY_LINK([
207                         #include <iconv.h>
208                 ],[
209                         static void f() {iconv_t t = iconv_open("", ""); }
210                 ],[
211                         AC_DEFINE(HAVE_ICONV_H)
212                         AC_MSG_RESULT(yes)
213                 ],[
214                         LIBS="$oldLIBS"
215                         CPPFLAGS="$oldCPPFLAGS"
216                         AC_MSG_RESULT(no)
217                 ])
218         ])
219 fi
220 dnl ------ various functions
221 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
222 if test "$ac_cv_func_poll" = "yes"; then
223         AC_CHECK_HEADERS(sys/poll.h)
224 fi
225 dnl ------ socklen_t
226 dnl We check for socklen_t by making prototypes with the
227 dnl various types. First socklen_t, then size_t, finally int.
228 dnl If the prototype succeeds, we're probably safe.
229 dnl That works if accept is not preprocessor defined (such sa AIX)
230 AC_MSG_CHECKING([for socklen_t])
231 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
232         AC_TRY_COMPILE([
233 #include <sys/types.h>
234 #include <sys/socket.h>
235 #ifdef __cplusplus
236 extern "C" {
237 #endif
238 #define try 1
239 #ifdef AIX
240 #if AIX >= 51
241 #define try 0
242 #endif
243 #endif
244 #if try
245 extern int accept(int, struct sockaddr *, socklen_t *);
246 #endif
247 #ifdef __cplusplus
248 }
249 #endif
250         ],,[ac_cv_check_socklen_t=socklen_t],[
251                 AC_TRY_COMPILE([
252 #include <sys/types.h>
253 #include <sys/socket.h>
254 #ifdef __cplusplus
255 extern "C" {
256 #endif
257 #define try 1
258 #ifdef AIX
259 #if AIX >= 42
260 #define try 0
261 #endif
262 #endif
263 #if try
264 extern int accept(int, struct sockaddr *, size_t t *);
265 #endif
266 #ifdef __cplusplus
267 }
268 #endif
269                 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
270         ])
271 ])
272 AC_MSG_RESULT($ac_cv_check_socklen_t)
273 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
274 dnl
275 dnl ------ tcpd
276 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
277 if test "$enable_tcpd" != "" && test "$enable_tcpd" != "no"; then
278         oldLibs=$LIBS
279         oldCPPFLAGS=$CPPFLAGS
280         if test "$enable_tcpd" != "yes"; then
281                 LIBS="$LIBS -L$enable_tcpd/lib"
282                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
283         fi
284         AC_MSG_CHECKING(for working tcpd.h)
285         LIBS="$LIBS -lwrap -lnsl"
286         AC_TRY_LINK([#include <syslog.h>
287 #include <tcpd.h>
288         int allow_severity = LOG_INFO;
289         int deny_severity = LOG_WARNING;],
290         [struct request_info request_info; int i;
291         i = hosts_access(&request_info);],
292         tcpd_ok=1, tcpd_ok=0)
293         if test "$tcpd_ok" = "0"; then
294                 AC_MSG_RESULT(no)
295                 LIBS=$oldLibs
296                 CPPFLAGS=$oldCPPFLAGS
297         else
298                 AC_MSG_RESULT(yes)
299                 AC_DEFINE(HAVE_TCPD_H)
300         fi
301 fi
302 dnl
303 dnl ------ Headers
304 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
305 AC_STDC_HEADERS
306 if test "$ac_cv_header_stdc" = "no"; then
307         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
308 fi
309 dnl
310 AC_SUBST(LIBTHREAD)
311 AC_SUBST(CFLAGSTHREADS)
312 HAVETHREADS=0
313 CFLAGSTHREADS=""
314 LIBTHREAD=""
315 dnl
316 dnl ------ GNU threads
317 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
318 AC_SUBST(LIBPTH)
319 if test "$enable_pth" = "yes"; then
320         OLIBS=$LIBS
321         AC_CHECK_LIB(pth,main)
322         if test "$ac_cv_lib_pth_main" = "yes"; then
323                 AC_CHECK_HEADERS(pth.h)
324                 if test "$ac_cv_header_pth_h" = "yes"; then
325                         LIBTHREAD="-lpth"
326                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
327                         HAVETHREADS=1
328                 fi
329         fi      
330         LIBS=$OLIBS
331 fi
332 dnl
333 dnl ------ POSIX Threads
334 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
335 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
336         OLIBS=$LIBS
337         OCC=$CC
338         AC_CHECK_LIB(pthread,main)
339         AC_MSG_CHECKING(for working POSIX Threads)
340         AC_TRY_LINK([#include <pthread.h>
341         void *func(void *p) { return 0; }
342         ],[
343         pthread_t pthread_id;
344         pthread_create (&pthread_id, 0, func, 0);],
345                 thread_ok=yes,thread_ok=no)
346         if test "$thread_ok" = "yes"; then
347                 AC_MSG_RESULT(yes)
348                 LIBTHREAD="-lpthread"
349                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
350                 HAVETHREADS=1
351         else
352                 CC="$CC -pthread"
353                 AC_TRY_LINK([#include <pthread.h>
354                         void *func(void *p) { return 0; }
355                         ],[
356                         pthread_t pthread_id;
357                         pthread_create (&pthread_id, 0, func, 0);],
358                         thread_ok=yes,thread_ok=no)
359                 if test "$thread_ok" = "yes"; then
360                         AC_MSG_RESULT([yes,BSD])
361                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
362                         LIBTHREAD="-pthread"
363                         HAVETHREADS=1
364                 fi
365         fi
366         if test "$thread_ok" = "no"; then
367                 AC_MSG_RESULT(no)
368         fi
369         CC=$OCC
370         LIBS=$OLIBS
371 fi
372 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
373 dnl
374 dnl ----- libXML2
375 AC_SUBST(XML2_LIBS)
376 AC_SUBST(XML2_CFLAGS)
377 xml2dir=yes
378 AC_ARG_WITH(xml2, [  --with-xml2[=PREFIX]    use libxml2 in PREFIX],[xml2dir=$withval])
379 if test "$xml2dir" = "yes"; then
380         for d in /usr /usr/local; do
381                 if test -x $d/bin/xml2-config; then
382                         xml2dir=$d
383                 fi
384         done
385 fi
386 if test "$xml2dir" != "no"; then
387         AC_MSG_CHECKING(for libXML2)
388         if test -x $xml2dir/bin/xml2-config; then
389                 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
390                 LIBS="$XML2_LIBS $LIBS"
391                 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
392                 XML2_VER=`$xml2dir/bin/xml2-config --version`
393                 AC_MSG_RESULT($XML2_VER)
394                 AC_DEFINE(HAVE_XML2)
395         else
396                 AC_MSG_RESULT(Not found)
397         fi
398 fi
399 dnl
400 dnl ------ Memory debugging
401 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
402 if test "$enable_memdebug" = "yes"; then
403         AC_DEFINE(TRACE_XMALLOC,2)
404 elif test "$enable_memdebug" = "no"; then
405         AC_DEFINE(TRACE_XMALLOC,0)
406 fi
407 dnl
408 dnl ------ Using this for "in-source" yaz-config
409 AC_SUBST(YAZ_SRC_ROOT)
410 AC_SUBST(YAZ_BUILD_ROOT)
411 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
412 YAZ_BUILD_ROOT=`pwd`
413 dnl
414 dnl ------ Makefiles
415 dnl
416 AC_OUTPUT([
417 Makefile
418 yaz.spec
419 src/Makefile
420 test/Makefile
421 util/Makefile
422 include/Makefile
423 include/yaz/Makefile
424 client/Makefile
425 ztest/Makefile
426 zoom/Makefile
427 doc/Makefile
428 doc/yaz.xml
429 doc/yazhtml.dsl
430 doc/yazphp.dsl
431 doc/yazprint.dsl
432 doc/tkl.xsl
433 doc/yazhtml.xsl
434 etc/Makefile
435 yaz-config
436 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])