cb53580283168b4cd7aa5b4ef43b57e42fac7af8
[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.42 2001-03-21 12:43:36 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_SHARED_LIBADD=""
70 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
71         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
72 )
73 READLINE_LIBS=""
74 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
75 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
76 if test "$ac_cv_lib_readline_readline" = "yes"; then
77         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
78 fi
79 dnl ------ snprintf
80 AC_CHECK_FUNCS(vsnprintf gettimeofday)
81 dnl
82 dnl ------ tcpd
83 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
84 if test "$enable_tcpd" != ""; then
85         oldLibs=$LIBS
86         oldCPPFLAGS=$CPPFLAGS
87         if test "$enable_tcpd" != "yes"; then
88                 LIBS="$LIBS -L$enable_tcpd/lib"
89                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
90         fi
91         AC_MSG_CHECKING(for working tcpd.h)
92         LIBS="$LIBS -lwrap -lnsl"
93         AC_TRY_LINK([#include <syslog.h>
94 #include <tcpd.h>
95         int allow_severity = LOG_INFO;
96         int deny_severity = LOG_WARNING;],
97         [struct request_info request_info; int i;
98         i = hosts_access(&request_info);],
99         tcpd_ok=1, tcpd_ok=0)
100         if test "$tcpd_ok" = "0"; then
101                 AC_MSG_RESULT(no)
102                 LIBS=$oldLibs
103                 CPPFLAGS=$oldCPPFLAGS
104         else
105                 AC_MSG_RESULT(yes)
106                 AC_DEFINE(HAVE_TCPD_H)
107         fi
108 fi
109 dnl
110 dnl ------ Headers
111 AC_STDC_HEADERS
112 if test "$ac_cv_header_stdc" = "no"; then
113         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
114 fi
115 dnl
116 dnl ------ Threads
117 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
118 AC_SUBST(LIBTHREAD)
119 if test "$enable_threads" = "yes"; then
120         OLIBS=$LIBS
121         AC_CHECK_LIB(pthread,main)
122         AC_MSG_CHECKING(for working POSIX Threads)
123         AC_TRY_LINK([#include <pthread.h>
124         void *func(void *p) { return 0; }
125         ],[
126         pthread_t pthread_id;
127         pthread_create (&pthread_id, 0, func, 0);],
128                 thread_ok=yes,thread_ok=no)
129         if test "$thread_ok" = "yes"; then
130                 LIBTHREAD=-lpthread
131                 AC_MSG_RESULT(yes)
132                 HAVETHREADS=1
133         else
134                 LIBTHREAD=""
135                 AC_MSG_RESULT(no)
136                 HAVETHREADS=0
137         fi
138         LIBS=$OLIBS
139 fi
140 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
141 dnl ------ Using this for "in-source" yaz-config
142 AC_SUBST(YAZ_SRC_ROOT)
143 AC_SUBST(YAZ_BUILD_ROOT)
144 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
145 YAZ_BUILD_ROOT=`pwd`
146 dnl
147 if test -f ${srcdir}/lib/yaz-config.in; then
148         rm ${srcdir}/lib/yaz-config.in
149 fi
150 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < ${srcdir}/yaz-config.in >${srcdir}/lib/yaz-config.in
151 dnl
152 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
153 AC_SUBST(SUBDIRS_VAR)
154 dnl ------ Makefiles
155 dnl
156 AC_OUTPUT([
157 Makefile
158 util/Makefile
159 odr/Makefile
160 z39.50/Makefile
161 asn/Makefile
162 ill/Makefile
163 zutil/Makefile
164 comstack/Makefile
165 ccl/Makefile
166 tab/Makefile
167 retrieval/Makefile
168 server/Makefile
169 include/Makefile
170 include/yaz/Makefile
171 lib/Makefile
172 client/Makefile
173 ztest/Makefile
174 doc/Makefile
175 yaz-config
176 lib/yaz-config
177 ],[chmod +x yaz-config lib/yaz-config])