Fixed linux specific test.
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit
2 dnl (c) Index Data 1994-2000
3 dnl See the file LICENSE for details.
4 dnl $Id: configure.in,v 1.26 2000-04-11 21:22:28 adam Exp $
5 AC_INIT(include/yaz/yaz-version.h)
6 AM_INIT_AUTOMAKE(yaz, 1.7)
7 dnl
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 AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline"])
57 if test "$ac_cv_lib_readline_readline" = "no"; then
58         AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline -ltermcap"])
59 fi
60 AC_CHECK_LIB(history, add_history, [LIBS="$LIBS -lhistory"])
61 if test "$ac_cv_lib_readline_readline" = "yes"; then
62         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
63 fi
64 dnl ------ snprintf
65 AC_CHECK_FUNCS(vsnprintf)
66 dnl
67 dnl ------ tcpd
68 AC_ARG_ENABLE(tcpd,[  --enable-tcpd           enable TCP wrapper for server if available])
69 if test "$enable_tcpd" = "yes"; then
70         AC_MSG_CHECKING(for working tcpd.h)
71         oldLibs=$LIBS
72         LIBS="$LIBS -lwrap -lnsl"
73         AC_TRY_LINK([#include <syslog.h>
74         #include <tcpd.h>
75         int allow_severity = LOG_INFO;
76         int deny_severity = LOG_WARNING;],
77         [struct request_info request_info; int i;
78         i = hosts_access(&request_info);],tcpd_ok=1, tcpd_ok=0)
79         if test "$tcpd_ok" = "0"; then
80                 AC_MSG_RESULT(no)
81                 LIBS=$oldLibs
82         else
83                 AC_MSG_RESULT(yes)
84                 AC_DEFINE(HAVE_TCPD_H)
85         fi
86 fi
87 dnl
88 dnl ------ Headers
89 AC_STDC_HEADERS
90 if test "$ac_cv_header_stdc" = "no"; then
91         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
92 fi
93 dnl
94 dnl ------ Threads
95 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
96 if test "$enable_threads" = "yes"; then
97         AC_CHECK_LIB(pthread,main)
98         AC_MSG_CHECKING(for working POSIX Threads)
99         AC_TRY_LINK([#include <pthread.h>
100         int func(void *p) { return 0; }
101         ],[
102         pthread_t pthread_id;
103         int r = pthread_create (&pthread_id, 0, func, 0);],
104                 thread_ok=yes,thread_ok=no)
105         if test "$thread_ok" = "yes"; then
106                 AC_MSG_RESULT(yes)
107                 AC_DEFINE(HAVE_PTHREAD_H)
108                 AC_DEFINE(_REENTRANT)
109         else
110                 AC_MSG_RESULT(no)
111         fi
112 fi
113 dnl
114 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
115 AC_SUBST(SUBDIRS_VAR)
116 dnl
117 dnl ------ Makefiles
118 dnl
119 AC_OUTPUT(Makefile util/Makefile odr/Makefile z39.50/Makefile asn/Makefile ill/Makefile zutil/Makefile comstack/Makefile ccl/Makefile tab/Makefile retrieval/Makefile server/Makefile include/Makefile include/yaz/Makefile lib/Makefile client/Makefile ztest/Makefile doc/Makefile)