Work on yaz-config creation. Added yaz.m4.
[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.37 2000-10-11 10:40:56 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 ------ GNU Readline
59 READLINE_LIBS=""
60 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline"])
61 if test "$ac_cv_lib_readline_readline" = "no"; then
62         AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline -ltermcap"])
63 fi
64 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
65 if test "$ac_cv_lib_readline_readline" = "yes"; then
66         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
67 fi
68 dnl ------ snprintf
69 AC_CHECK_FUNCS(vsnprintf gettimeofday)
70 dnl
71 dnl ------ tcpd
72 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
73 if test "$enable_tcpd" != ""; then
74         oldLibs=$LIBS
75         oldCPPFLAGS=$CPPFLAGS
76         if test "$enable_tcpd" != "yes"; then
77                 LIBS="$LIBS -L$enable_tcpd/lib"
78                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
79         fi
80         AC_MSG_CHECKING(for working tcpd.h)
81         LIBS="$LIBS -lwrap -lnsl"
82         AC_TRY_LINK([#include <syslog.h>
83 #include <tcpd.h>
84         int allow_severity = LOG_INFO;
85         int deny_severity = LOG_WARNING;],
86         [struct request_info request_info; int i;
87         i = hosts_access(&request_info);],
88         tcpd_ok=1, tcpd_ok=0)
89         if test "$tcpd_ok" = "0"; then
90                 AC_MSG_RESULT(no)
91                 LIBS=$oldLibs
92                 CPPFLAGS=$oldCPPFLAGS
93         else
94                 AC_MSG_RESULT(yes)
95                 AC_DEFINE(HAVE_TCPD_H)
96         fi
97 fi
98 dnl
99 dnl ------ Headers
100 AC_STDC_HEADERS
101 if test "$ac_cv_header_stdc" = "no"; then
102         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
103 fi
104 dnl
105 dnl ------ Threads
106 AC_ARG_ENABLE(threads, [  --enable-threads        enable POSIX threads],[enable_threads=$enableval],[enable_threads=no])
107 if test "$enable_threads" = "yes"; then
108         AC_CHECK_LIB(pthread,main)
109         AC_MSG_CHECKING(for working POSIX Threads)
110         AC_TRY_LINK([#include <pthread.h>
111         int func(void *p) { return 0; }
112         ],[
113         pthread_t pthread_id;
114         int r = pthread_create (&pthread_id, 0, func, 0);],
115                 thread_ok=yes,thread_ok=no)
116         if test "$thread_ok" = "yes"; then
117                 AC_MSG_RESULT(yes)
118                 AC_DEFINE(HAVE_PTHREAD_H)
119                 AC_DEFINE(_REENTRANT)
120         else
121                 AC_MSG_RESULT(no)
122         fi
123 fi
124 dnl ------ Using this for "in-source" yaz-config
125 AC_SUBST(YAZ_SRC_ROOT)
126 YAZ_SRC_ROOT=`pwd`
127 dnl
128 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
129 AC_SUBST(SUBDIRS_VAR)
130 if test -f lib/yaz-config.in; then
131         rm lib/yaz-config.in
132 fi
133 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config.in >lib/yaz-config.in
134 dnl
135 dnl ------ Makefiles
136 dnl
137 AC_OUTPUT([
138 Makefile
139 util/Makefile
140 odr/Makefile
141 z39.50/Makefile
142 asn/Makefile
143 ill/Makefile
144 zutil/Makefile
145 comstack/Makefile
146 ccl/Makefile
147 tab/Makefile
148 retrieval/Makefile
149 server/Makefile
150 include/Makefile
151 include/yaz/Makefile
152 lib/Makefile
153 client/Makefile
154 ztest/Makefile
155 doc/Makefile
156 yaz-config
157 lib/yaz-config
158 ],[chmod +x yaz-config lib/yaz-config])