Fixed TCP wrapper setting so that it is only enabled when the set to.
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit, Index Data 1994-2000
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.31 2000-09-09 08:05:57 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 1.7)
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(ASNMODULE)
17 AC_SUBST(ILLMODULE)
18 AC_SUBST(ILLLIB)
19 AC_ARG_ENABLE(comp,[  --disable-comp          use old encoders, i.e. disable the YAZ ASN.1 Compiler], , enable_comp=yes)
20 if test "$enable_comp" = "yes"; then
21         ASNMODULE="z39.50"
22         ILLMODULE="ill"
23         ILLLIB=../ill/libill.la
24         ASN_MAKEFILES="z39.50/Makefile ill/Makefile"
25         HFILE=z-proto.h
26 else
27         ILLMODULE=""
28         ASNMODULE=asn
29         ILLLIB=""
30         ASN_MAKEFILES="asn/Makefile"
31         HFILE=prt-proto.h
32 fi
33 AC_MSG_CHECKING(whether proto.h needs to be generated)
34 yaz_include=${srcdir}/include/yaz
35 if test -r ${yaz_include}/proto.h && cmp -s ${yaz_include}/$HFILE ${yaz_include}/proto.h; then
36         AC_MSG_RESULT(no)
37 else
38         AC_MSG_RESULT(yes)
39         cp -f ${yaz_include}/$HFILE ${yaz_include}/proto.h
40 fi
41 dnl
42 dnl ----- Sockets
43 checkBoth=0
44 AC_CHECK_FUNC(connect)
45 if test "$ac_cv_func_connect" = "no"; then
46         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
47 fi
48 if test "$checkBoth" = "1"; then
49         oldLibs=$LIBS
50         LIBS="$LIBS -lsocket -lnsl"
51         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
52 fi
53 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
54 dnl
55 dnl ------ GNU Readline
56 READLINE_LIBS=""
57 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline"])
58 if test "$ac_cv_lib_readline_readline" = "no"; then
59         AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline -ltermcap"])
60 fi
61 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
62 if test "$ac_cv_lib_readline_readline" = "yes"; then
63         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
64 fi
65 dnl ------ snprintf
66 AC_CHECK_FUNCS(vsnprintf gettimeofday)
67 dnl
68 dnl ------ tcpd
69 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
70 if test "$enable_tcpd" != ""; then
71         oldLibs=$LIBS
72         oldCPPFLAGS=$CPPFLAGS
73         if test "$enable_tcpd" != "yes"; then
74                 LIBS="$LIBS -L$enable_tcpd/lib"
75                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
76         fi
77         AC_MSG_CHECKING(for working tcpd.h)
78         LIBS="$LIBS -lwrap -lnsl"
79         AC_TRY_LINK([#include <syslog.h>
80 #include <tcpd.h>
81         int allow_severity = LOG_INFO;
82         int deny_severity = LOG_WARNING;],
83         [struct request_info request_info; int i;
84         i = hosts_access(&request_info);],
85         tcpd_ok=1, tcpd_ok=0)
86         if test "$tcpd_ok" = "0"; then
87                 AC_MSG_RESULT(no)
88                 LIBS=$oldLibs
89                 CPPFLAGS=$oldCPPFLAGS
90         else
91                 AC_MSG_RESULT(yes)
92                 AC_DEFINE(HAVE_TCPD_H)
93         fi
94 fi
95 dnl
96 dnl ------ Headers
97 AC_STDC_HEADERS
98 if test "$ac_cv_header_stdc" = "no"; then
99         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
100 fi
101 dnl
102 dnl ------ Threads
103 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
104 if test "$enable_threads" = "yes"; then
105         AC_CHECK_LIB(pthread,main)
106         AC_MSG_CHECKING(for working POSIX Threads)
107         AC_TRY_LINK([#include <pthread.h>
108         int func(void *p) { return 0; }
109         ],[
110         pthread_t pthread_id;
111         int r = pthread_create (&pthread_id, 0, func, 0);],
112                 thread_ok=yes,thread_ok=no)
113         if test "$thread_ok" = "yes"; then
114                 AC_MSG_RESULT(yes)
115                 AC_DEFINE(HAVE_PTHREAD_H)
116                 AC_DEFINE(_REENTRANT)
117         else
118                 AC_MSG_RESULT(no)
119         fi
120 fi
121 dnl
122 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
123 AC_SUBST(SUBDIRS_VAR)
124 dnl
125 dnl ------ Makefiles
126 dnl
127 AC_OUTPUT([
128 Makefile
129 util/Makefile
130 odr/Makefile
131 z39.50/Makefile
132 asn/Makefile
133 ill/Makefile
134 zutil/Makefile
135 comstack/Makefile
136 ccl/Makefile
137 tab/Makefile
138 retrieval/Makefile
139 server/Makefile
140 include/Makefile
141 include/yaz/Makefile
142 lib/Makefile
143 client/Makefile
144 ztest/Makefile
145 doc/Makefile
146 lib/yaz-config],[chmod +x lib/yaz-config])