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