Added POSIX threads support for frontend server.
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit
2 dnl (c) Index Data 1994-2000
3 dnl See the file LICENSE for details.
4 dnl $Id: configure.in,v 1.24 2000-03-14 09:06:11 adam Exp $
5 AC_INIT(include/yaz/yaz-version.h)
6 AM_INIT_AUTOMAKE(yaz, 1.6)
7 dnl
8 dnl ------ Checking programs
9 AC_PROG_CC
10 AC_PROG_CPP
11 AC_PROG_INSTALL
12 AC_PROG_RANLIB
13 dnl 
14 dnl ----- yaz-comp: The Yaz Compiler
15 AC_SUBST(ASNMODULE)
16 AC_SUBST(ILLMODULE)
17 AC_SUBST(ILLLIB)
18 AC_ARG_ENABLE(comp,[  --disable-comp          use old encoders, i.e. disable the YAZ ASN.1 Compiler], , enable_comp=yes)
19 if test "$enable_comp" = "yes"; then
20         ASNMODULE="z39.50"
21         ILLMODULE="ill"
22         ILLLIB=../ill/libill.a
23         ASN_MAKEFILES="z39.50/Makefile ill/Makefile"
24         cp -f include/yaz/z-proto.h include/yaz/proto.h
25 else
26         ILLMODULE=""
27         ASNMODULE=asn
28         ILLLIB=""
29         ASN_MAKEFILES="asn/Makefile"
30         cp -f include/yaz/prt-proto.h include/yaz/proto.h
31 fi
32 dnl
33 dnl ----- Sockets
34 checkBoth=0
35 AC_CHECK_FUNC(connect)
36 if test "$ac_cv_func_connect" = "no"; then
37         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
38 fi
39 if test "$checkBoth" = "1"; then
40         oldLibs=$LIBS
41         LIBS="$LIBS -lsocket -lnsl"
42         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
43 fi
44 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
45 dnl
46 dnl ------ GNU Readline
47 AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline"])
48 if test "$ac_cv_lib_readline_readline" = "no"; then
49         AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline -ltermcap"])
50 fi
51 AC_CHECK_LIB(history, add_history, [LIBS="$LIBS -lhistory"])
52 if test "$ac_cv_lib_readline_readline" = "yes"; then
53         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
54 fi
55 dnl ------ snprintf
56 AC_CHECK_FUNCS(vsnprintf)
57 dnl
58 dnl ------ tcpd
59 AC_ARG_ENABLE(tcpd,[  --enable-tcpd           enable TCP wrapper for server if available])
60 if test "$enable_tcpd" = "yes"; then
61         AC_MSG_CHECKING(for working tcpd.h)
62         oldLibs=$LIBS
63         LIBS="$LIBS -lwrap -lnsl"
64         AC_TRY_LINK([#include <syslog.h>
65         #include <tcpd.h>
66         int allow_severity = LOG_INFO;
67         int deny_severity = LOG_WARNING;],
68         [struct request_info request_info; int i;
69         i = hosts_access(&request_info);],tcpd_ok=1, tcpd_ok=0)
70         if test "$tcpd_ok" = "0"; then
71                 AC_MSG_RESULT(no)
72                 LIBS=$oldLibs
73         else
74                 AC_MSG_RESULT(yes)
75                 AC_DEFINE(HAVE_TCPD_H)
76         fi
77 fi
78 dnl
79 dnl ------ Headers
80 AC_STDC_HEADERS
81 if test "$ac_cv_header_stdc" = "no"; then
82         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
83 fi
84 dnl
85 dnl ------ Threads
86 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
87 if test "$enable_threads" = "yes"; then
88         AC_CHECK_LIB(pthread,main)
89         AC_MSG_CHECKING(for working POSIX Threads)
90         AC_TRY_LINK([#include <pthread.h>
91         int func(void *p) { return 0; }
92         ],[
93         pthread_t pthread_id;
94         int r = pthread_create (&pthread_id, 0, func, 0);],
95                 thread_ok=yes,thread_ok=no)
96         if test "$thread_ok" = "yes"; then
97                 AC_MSG_RESULT(yes)
98                 AC_DEFINE(HAVE_PTHREAD_H)
99                 AC_DEFINE(_REENTRANT)
100         else
101                 AC_MSG_RESULT(no)
102         fi
103 fi
104 dnl
105 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
106 AC_SUBST(SUBDIRS_VAR)
107 dnl
108 dnl ------ Makefiles
109 dnl
110 AC_OUTPUT(Makefile util/Makefile odr/Makefile z39.50/Makefile asn/Makefile ill/Makefile zutil/Makefile comstack/Makefile ccl/Makefile tab/Makefile retrieval/Makefile server/Makefile include/Makefile include/yaz/Makefile lib/Makefile client/Makefile ztest/Makefile doc/Makefile)