Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
[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.16 2000-02-28 11:20:05 adam Exp $
5 AC_INIT(include/yaz/yaz-version.h)
6 AM_INIT_AUTOMAKE(yaz, 1.6)
7 AM_CONFIG_HEADER(include/yaz/config.h)
8 dnl
9 dnl ------ Checking programs
10 AC_PROG_CC
11 AC_PROG_CPP
12 AC_PROG_INSTALL
13 AC_PROG_RANLIB
14 dnl 
15 dnl ----- YC: The Yaz Compiler
16 AC_SUBST(ASNMODULE)
17 AC_SUBST(ILLMODULE)
18 AC_SUBST(ILLLIB)
19 AC_ARG_ENABLE(yc,[  --enable-yc             compile using YAZ' ASN.1 Compiler], , enable_yc=yes)
20 if test "$enable_yc" = "yes"; then
21         ASNMODULE="z39.50"
22         ILLMODULE="ill"
23         ILLLIB=../ill/libill.a
24         ASN_MAKEFILES="z39.50/Makefile ill/Makefile"
25         cp -f include/yaz/z-proto.h include/yaz/proto.h
26 else
27         ILLMODULE=""
28         ASNMODULE=asn
29         ILLLIB=""
30         ASN_MAKEFILES="asn/Makefile"
31         cp -f include/yaz/prt-proto.h include/yaz/proto.h
32 fi
33 dnl
34 dnl ----- Sockets
35 checkBoth=0
36 AC_CHECK_FUNC(connect)
37 if test "$ac_cv_func_connect" = "no"; then
38         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
39 fi
40 if test "$checkBoth" = "1"; then
41         oldLibs=$LIBS
42         LIBS="$LIBS -lsocket -lnsl"
43         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
44 fi
45 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
46 dnl
47 dnl ------ GNU Readline
48 AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline"])
49 if test "$ac_cv_lib_readline_readline" = "no"; then
50         AC_CHECK_LIB(readline, readline, [LIBS="$LIBS -lreadline -ltermcap"])
51 fi
52 AC_CHECK_LIB(history, add_history, [LIBS="$LIBS -lhistory"])
53 if test "$ac_cv_lib_readline_readline" = "yes"; then
54         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
55 fi
56 dnl
57 dnl ------ tcpd
58 AC_ARG_ENABLE(tcpd,[  --enable-tcpd           enable TCP wrapper for server if available])
59 if test "$enable_tcpd" = "yes"; then
60         AC_MSG_CHECKING(for working tcpd.h)
61         oldLibs=$LIBS
62         LIBS="$LIBS -lwrap -lnsl"
63         AC_TRY_LINK([#include <syslog.h>
64         #include <tcpd.h>
65         int allow_severity = LOG_INFO;
66         int deny_severity = LOG_WARNING;],
67         [struct request_info request_info; int i;
68         i = hosts_access(&request_info);],tcpd_ok=1, tcpd_ok=0)
69         if test "$tcpd_ok" = "0"; then
70                 AC_MSG_RESULT(no)
71                 LIBS=$oldLibs
72         else
73                 AC_MSG_RESULT(yes)
74                 AC_DEFINE(HAVE_TCPD_H)
75         fi
76 fi
77 dnl
78 dnl ------ Headers
79 AC_STDC_HEADERS
80 if test "$ac_cv_header_stdc" = "no"; then
81         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
82 fi
83 dnl
84 dnl ------ Threads
85 AC_ARG_ENABLE(threads, [  --enable-threads        enable threads if available])
86 if test "$enable_threads" = "yes"; then
87         AC_CHECK_HEADERS(pthread.h threads.h)
88         AC_CHECK_FUNC(pthread_mutex_lock)
89         if test "$ac_cv_func_pthread_mutex_lock" = "no"; then
90                 AC_CHECK_LIB(pthread, main)
91         fi
92         AC_DEFINE(_REENTRANT)
93 fi
94 dnl
95 SUBDIRS_VAR="util odr $ASNMODULE $ILLMODULE zutil comstack ccl tab retrieval server include lib client ztest"
96 AC_SUBST(SUBDIRS_VAR)
97 dnl
98 dnl ------ Makefiles
99 dnl
100 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)