Fixed problem with element level in reading of abstract syntax.
[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.39 2000-11-29 14:22:47 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=${srcdir}/include/yaz/z-proto.h
26 else
27         ILLMODULE=""
28         ASNMODULE=asn
29         ILLLIB=""
30         ASN_MAKEFILES="asn/Makefile"
31         HFILE=${srcdir}/asn/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 $HFILE ${yaz_include}/proto.h; then
36         AC_MSG_RESULT(no)
37 else
38         AC_MSG_RESULT(yes)
39         cp -f $HFILE ${yaz_include}/proto.h
40         if test "$enable_comp" != "yes"; then
41                 cp ${srcdir}/asn/*.h ${yaz_include}
42         fi
43 fi
44 dnl
45 dnl ----- Sockets
46 checkBoth=0
47 AC_CHECK_FUNC(connect)
48 if test "$ac_cv_func_connect" = "no"; then
49         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
50 fi
51 if test "$checkBoth" = "1"; then
52         oldLibs=$LIBS
53         LIBS="$LIBS -lsocket -lnsl"
54         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
55 fi
56 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
57 dnl
58 dnl ------ Open SSL
59 openssl=no
60 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    OpenSSL library in DIR], [openssl=$withval])
61 if test "$openssl" = "yes"; then
62         AC_CHECK_LIB(crypto, main)
63         AC_CHECK_LIB(ssl, SSL_new)
64         if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
65                 AC_CHECK_HEADERS(openssl/ssl.h)
66         fi
67 fi
68 dnl ------ GNU Readline
69 READLINE_LIBS=""
70 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline"])
71 if test "$ac_cv_lib_readline_readline" = "no"; then
72         AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline -ltermcap"])
73 fi
74 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
75 if test "$ac_cv_lib_readline_readline" = "yes"; then
76         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
77 fi
78 dnl ------ snprintf
79 AC_CHECK_FUNCS(vsnprintf gettimeofday)
80 dnl
81 dnl ------ tcpd
82 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
83 if test "$enable_tcpd" != ""; then
84         oldLibs=$LIBS
85         oldCPPFLAGS=$CPPFLAGS
86         if test "$enable_tcpd" != "yes"; then
87                 LIBS="$LIBS -L$enable_tcpd/lib"
88                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
89         fi
90         AC_MSG_CHECKING(for working tcpd.h)
91         LIBS="$LIBS -lwrap -lnsl"
92         AC_TRY_LINK([#include <syslog.h>
93 #include <tcpd.h>
94         int allow_severity = LOG_INFO;
95         int deny_severity = LOG_WARNING;],
96         [struct request_info request_info; int i;
97         i = hosts_access(&request_info);],
98         tcpd_ok=1, tcpd_ok=0)
99         if test "$tcpd_ok" = "0"; then
100                 AC_MSG_RESULT(no)
101                 LIBS=$oldLibs
102                 CPPFLAGS=$oldCPPFLAGS
103         else
104                 AC_MSG_RESULT(yes)
105                 AC_DEFINE(HAVE_TCPD_H)
106         fi
107 fi
108 dnl
109 dnl ------ Headers
110 AC_STDC_HEADERS
111 if test "$ac_cv_header_stdc" = "no"; then
112         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
113 fi
114 dnl
115 dnl ------ Threads
116 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
117 AC_SUBST(LIBTHREAD)
118 if test "$enable_threads" = "yes"; then
119         OLIBS=$LIBS
120         AC_CHECK_LIB(pthread,main)
121         AC_MSG_CHECKING(for working POSIX Threads)
122         AC_TRY_LINK([#include <pthread.h>
123         void *func(void *p) { return 0; }
124         ],[
125         pthread_t pthread_id;
126         pthread_create (&pthread_id, 0, func, 0);],
127                 thread_ok=yes,thread_ok=no)
128         if test "$thread_ok" = "yes"; then
129                 LIBTHREAD=-lpthread
130                 AC_MSG_RESULT(yes)
131                 HAVETHREADS=1
132         else
133                 LIBTHREAD=""
134                 AC_MSG_RESULT(no)
135                 HAVETHREADS=0
136         fi
137         LIBS=$OLIBS
138 fi
139 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
140 dnl ------ Using this for "in-source" yaz-config
141 AC_SUBST(YAZ_SRC_ROOT)
142 YAZ_SRC_ROOT=`pwd`
143 dnl
144 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
145 AC_SUBST(SUBDIRS_VAR)
146 if test -f lib/yaz-config.in; then
147         rm lib/yaz-config.in
148 fi
149 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config.in >lib/yaz-config.in
150 dnl
151 dnl ------ Makefiles
152 dnl
153 AC_OUTPUT([
154 Makefile
155 util/Makefile
156 odr/Makefile
157 z39.50/Makefile
158 asn/Makefile
159 ill/Makefile
160 zutil/Makefile
161 comstack/Makefile
162 ccl/Makefile
163 tab/Makefile
164 retrieval/Makefile
165 server/Makefile
166 include/Makefile
167 include/yaz/Makefile
168 lib/Makefile
169 client/Makefile
170 ztest/Makefile
171 doc/Makefile
172 yaz-config
173 lib/yaz-config
174 ],[chmod +x yaz-config lib/yaz-config])