source: yaz/trunk/fuentes/configure.ac @ 265

Last change on this file since 265 was 265, checked in by mabarracus, 4 years ago

Add new source code 5.15.2

File size: 13.0 KB
Line 
1dnl This file is part of the YAZ toolkit.
2dnl Copyright (C) Index Data
3dnl See the file LICENSE for details.
4AC_PREREQ([2.60])
5AC_INIT([yaz],
6m4_esyscmd([. ./IDMETA; echo $VERSION|tr -d '\n']),
7[yaz-help@indexdata.dk])
8AC_CONFIG_HEADERS(include/config.h)
9AC_CONFIG_SRCDIR([configure.ac])
10AC_CONFIG_AUX_DIR([config])
11AM_INIT_AUTOMAKE([1.9 subdir-objects])
12dnl
13AC_SUBST([READLINE_LIBS])
14AC_SUBST([YAZ_CONF_CFLAGS])
15dnl ------ Checking programs
16AC_PROG_CC
17AC_PROG_CPP
18AC_CHECK_PROGS([YACC], 'bison -y')
19test -z "$YACC" -a ! -f src/cql.c && AC_MSG_ERROR([GNU Bison not found])
20test -z "$YACC" && AC_MSG_WARN([GNU Bison not found])
21AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
22AC_PROG_INSTALL
23AM_PROG_LIBTOOL
24AM_PROG_CC_C_O
25AC_PATH_PROG([pkgconfigpath],[pkg-config],[NONE])
26dnl
27YAZ_DOC
28dnl
29dnl
30AC_C_BIGENDIAN
31AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h sys/prctl.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h execinfo.h],[],[],[])
32AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
33 #if HAVE_SYS_TYPES_H
34 #include <sys/types.h>
35 #endif
36 #if HAVE_SYS_SOCKET_H
37 #include <sys/socket.h>
38 #endif
39 #if HAVE_NET_IF_H
40 #include <net/if.h>
41 #endif
42 #if HAVE_NETINET_IN_H
43 #include <netinet/in.h>
44 #endif
45])
46AC_HEADER_STDC
47if test "$ac_cv_header_stdc" = "no"; then
48    AC_MSG_WARN([Your system doesn not seem to support ANSI C])
49fi
50dnl ----- Types
51AC_CHECK_TYPES([long long])
52dnl
53dnl ----- Sockets
54checkBoth=0
55AC_CHECK_FUNC([connect])
56if test "$ac_cv_func_connect" = "no"; then
57    AC_CHECK_LIB([socket],[main], LIBS="$LIBS -lsocket", checkBoth=1)
58fi
59if test "$checkBoth" = "1"; then
60    oldLibs=$LIBS
61    LIBS="$LIBS -lsocket -lnsl"
62    AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
63fi
64AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
65dnl
66dnl ------ redis
67hiredis=default
68AC_SUBST([HIREDIS_LIBS])
69AC_ARG_WITH([redis], [  --with-redis            hiredis library], [hiredis=$withval])
70if test "$hiredis" != "no" -a "$pkgconfigpath" != "NONE"; then
71    AC_CHECK_LIB([hiredis],[redisCommandArgv],[HIREDIS_LIBS=-lhiredis])
72    AC_MSG_CHECKING([for redis])
73    if $pkgconfigpath --cflags hiredis >/dev/null 2>&1 ; then
74        if $pkgconfigpath --atleast-version 0.10 hiredis; then
75            AC_MSG_RESULT([yes])
76            CFLAGS="$CFLAGS `$pkgconfigpath --cflags hiredis`"
77            HIREDIS_LIBS="`$pkgconfigpath --libs hiredis`"
78            AC_DEFINE([HAVE_HIREDIS],[1],[Define to 1 if hiredis is enabled])
79        else
80            AC_MSG_RESULT([no. Version 0.10 required])
81            if test "$hiredis" != "default"; then
82                AC_MSG_ERROR([hiredis libraries missing])
83            fi
84        fi
85    else
86        if test "$ac_cv_lib_hiredis_redisCommandArgv" = "yes"; then
87            AC_DEFINE([HAVE_HIREDIS],[1])
88            AC_MSG_RESULT([yes])
89        else
90            AC_MSG_RESULT([no])
91            if test "$hiredis" != "default"; then
92                AC_MSG_ERROR([hiredis libraries missing])
93            fi
94        fi
95    fi
96fi
97dnl ------ memcached
98memcached=default
99AC_SUBST([MEMCACHED_LIBS])
100AC_ARG_WITH([memcached], [  --with-memcached        Memcached library], [memcached=$withval])
101if test "$memcached" != "no" -a "$pkgconfigpath" != "NONE"; then
102    AC_MSG_CHECKING([for libmemcached])
103    if $pkgconfigpath --cflags libmemcached >/dev/null 2>&1 ; then
104        if $pkgconfigpath --atleast-version 0.40 libmemcached; then
105            AC_MSG_RESULT([yes])
106            CFLAGS="$CFLAGS `$pkgconfigpath --cflags libmemcached`"
107            MEMCACHED_LIBS="`$pkgconfigpath --libs libmemcached`"
108            AC_DEFINE([HAVE_LIBMEMCACHED],[1],[Define to 1 if memcached is enabled])
109        else
110            AC_MSG_RESULT([no. Version 0.40 required])
111            if test "$memcached" != "default"; then
112                AC_MSG_ERROR([libmemcached libraries missing])
113            fi
114        fi
115    else
116        AC_MSG_RESULT([no])
117        if test "$memcached" != "default"; then
118            AC_MSG_ERROR([libmemcached libraries missing])
119        fi
120    fi
121fi
122dnl
123dnl
124dnl
125dnl ------ GNU TLS
126AC_SUBST([SSL_CFLAGS])
127AC_SUBST([SSL_LIBS])
128gnutls=default
129AC_ARG_WITH([gnutls], [  --with-gnutls[=PREFIX]    GNU TLS library in PREFIX], [gnutls=$withval])
130if test "$gnutls" != "no"; then
131    gnutlsver=no
132    if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
133        if test -x $gnutls/bin/pkg-config; then
134            if $gnutls/bin/pkg-config --exists gnutls; then
135                SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
136                SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls`"
137                gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
138            fi
139        fi
140    else
141        if test "$pkgconfigpath" != "NONE"; then
142            if $pkgconfigpath --exists gnutls; then
143                SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
144                SSL_LIBS="`$pkgconfigpath --libs gnutls`"
145                gnutlsver=`$pkgconfigpath --modversion gnutls`
146            fi
147        fi
148    fi
149    AC_MSG_CHECKING([for GNU TLS])
150    if test "$gnutlsver" != "no"; then
151        AC_DEFINE([HAVE_GNUTLS_H],[1],[Define to 1 if GNUTLS is present])
152        AC_MSG_RESULT([$gnutlsver])
153    else
154        SSL_CFLAGS=""
155        AC_MSG_RESULT([None])
156        if test "$gnutls" != "default"; then
157            AC_MSG_ERROR([GNU TLS development libraries missing])
158        fi
159    fi
160fi
161dnl
162dnl ------ GNU Readline
163READLINE_SHARED_LIBADD=""
164AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
165    AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
166)
167READLINE_LIBS=""
168AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
169AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
170if test "$ac_cv_lib_readline_readline" = "yes"; then
171    AC_CHECK_HEADERS([readline/readline.h readline/history.h])
172    xLIBS=$LIBS
173    LIBS="$LIBS $READLINE_LIBS"
174    AC_TRY_LINK([
175        #include <stdio.h>
176        #include <readline/readline.h>
177            ],[
178            rl_attempted_completion_over = 0;
179            ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER],1,[Define to 1 if rl_attempted_completion_over is defined]))
180    AC_TRY_LINK([
181        #include <stdio.h>
182        #include <readline/readline.h>
183            ],[
184            rl_completion_matches (0, 0);
185            ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES],1,[Define to 1 if rl_completion_matches is defined])])
186    LIBS=$xLIBS
187fi
188dnl ------ iconv
189AC_ARG_WITH([iconv],[  --with-iconv[=PREFIX]     iconv library in PREFIX])
190if test "$with_iconv" != "no"; then
191    AC_MSG_CHECKING([for iconv])
192    oldLIBS="$LIBS"
193    oldCPPFLAGS="${CPPFLAGS}"
194    if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
195        LIBS="$LIBS -L${with_iconv}/lib"
196        CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
197    fi
198    AC_TRY_LINK([
199                #include <iconv.h>
200            ],[
201            iconv_t t = iconv_open("", "");
202            ],[
203            AC_DEFINE([HAVE_ICONV_H],1,[Define to 1 if iconv.h is present])
204            AC_MSG_RESULT([yes])
205            ],[
206            LIBS="$LIBS -liconv"
207            AC_TRY_LINK([
208                        #include <iconv.h>
209                    ],[
210            iconv_t t = iconv_open("", "");
211                    ],[
212            AC_DEFINE([HAVE_ICONV_H],1)
213            AC_MSG_RESULT([yes])
214                    ],[
215            LIBS="$oldLIBS"
216            CPPFLAGS="$oldCPPFLAGS"
217            AC_MSG_RESULT([no])
218            ])
219    ])
220fi
221dnl ------ various functions
222AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
223case $host in
224    *-*-darwin*)
225        trypoll="no";
226        ;;
227    *)
228        trypoll="yes";
229        ;;
230esac
231
232if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
233    AC_CHECK_HEADERS([sys/poll.h])
234fi
235dnl ------ socklen_t
236dnl We check for socklen_t by making prototypes with the
237dnl various types. First socklen_t, then size_t, finally int.
238dnl If the prototype succeeds, we are probably safe.
239dnl That works if accept is not preprocessor defined (such sa AIX)
240AC_MSG_CHECKING([for socklen_t])
241AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
242        AC_TRY_COMPILE([
243#include <sys/types.h>
244#include <sys/socket.h>
245#ifdef __cplusplus
246extern "C" {
247#endif
248#define try 1
249#ifdef AIX
250#if AIX >= 51
251#define try 0
252#endif
253#endif
254#if try
255extern int accept(int, struct sockaddr *, socklen_t *);
256#endif
257#ifdef __cplusplus
258}
259#endif
260        ],,[ac_cv_check_socklen_t=socklen_t],[
261                AC_TRY_COMPILE([
262#include <sys/types.h>
263#include <sys/socket.h>
264#ifdef __cplusplus
265extern "C" {
266#endif
267#define try 1
268#ifdef AIX
269#if AIX >= 42
270#define try 0
271#endif
272#endif
273#if try
274extern int accept(int, struct sockaddr *, size_t t *);
275#endif
276#ifdef __cplusplus
277}
278#endif
279],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
280                ])
281        ])
282AC_MSG_RESULT([$ac_cv_check_socklen_t])
283AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t],[socklen_t type])
284dnl
285dnl ------ tcpd
286AC_ARG_ENABLE([tcpd],[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
287if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
288    oldLibs=$LIBS
289    oldCPPFLAGS=$CPPFLAGS
290    if test "$enable_tcpd" != "yes"; then
291        LIBS="$LIBS -L$enable_tcpd/lib"
292        CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
293    fi
294    AC_MSG_CHECKING([for working tcpd.h])
295    LIBS="$LIBS -lwrap"
296    AC_TRY_LINK([#include <syslog.h>
297#include <tcpd.h>
298            int allow_severity = LOG_INFO;
299            int deny_severity = LOG_WARNING;],
300        [struct request_info request_info; int i;
301            i = hosts_access(&request_info);],
302        tcpd_ok=1, tcpd_ok=0)
303    LIBS=$oldLibs
304    if test "$tcpd_ok" = "0"; then
305        AC_MSG_RESULT([no])
306        AC_MSG_ERROR([tcpd development libraries missing])
307        CPPFLAGS=$oldCPPFLAGS
308    else
309        TCPD_LIBS="-lwrap"
310        AC_MSG_RESULT([yes])
311        AC_DEFINE([HAVE_TCPD_H],1,[Define to 1 if tcp wrap library is present])
312    fi
313fi
314AC_SUBST([TCPD_LIBS])
315dnl
316AC_SUBST([YAZ_CONFIG_CFLAGS])
317dnl
318dnl ------ POSIX Threads
319HAVETHREADS=0
320AC_ARG_ENABLE([threads],[  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
321if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
322    ACX_PTHREAD([
323            OCFLAGS=$CFLAGS
324            CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
325            dnl unfortunately empty thread lib spec is problematic because
326            dnl 'yaz-config --cflags' is not always passed to linker in
327            dnl applications using YAZ (such as Zebra).
328            if test "x$PTHREAD_LIBS" = "x"; then
329                OLIBS=$LIBS
330                for lib in -lpthread -lpthreads -lc_r; do
331                    LIBS="$lib $OLIBS"
332                    AC_TRY_LINK([ #include <pthread.h> ],
333                            [ pthread_t id; pthread_join(id, 0); ],
334                            [ PTHREAD_LIBS=$lib; break ]
335                        )
336                done
337                LIBS=$OLIBS
338            fi
339            LIBS="$LIBS $PTHREAD_LIBS"
340            AC_DEFINE(YAZ_POSIX_THREADS,1,[Define to 1 if POSIX threads is present])
341            YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_POSIX_THREADS=1"
342            ])
343fi
344
345dnl ----- libXSLT/libEXLT/libXML2
346AC_SUBST([XML2_CFLAGS])
347
348xml_enabled=false
349YAZ_LIBXML2([
350        AC_DEFINE(YAZ_HAVE_XML2,1,[Define to 1 if Libxml2 is present])
351        YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
352        xml_enabled=true
353    ])
354
355if test "$xml_enabled" = "true"; then
356    YAZ_LIBXSLT([
357            AC_DEFINE(YAZ_HAVE_XSLT,1,[Define to 1 if Libxslt is present])
358            YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
359        ])
360    YAZ_LIBEXSLT([
361            AC_DEFINE(YAZ_HAVE_EXSLT,1,[Define to 1 if EXSLT is present])
362            YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
363        ])
364
365fi
366YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
367
368if test "$XML2_LIBS"; then
369    LIBS="$XML2_LIBS $LIBS"
370fi
371
372dnl
373dnl
374AC_CHECK_ICU([3.4],[
375        if test "$xml_enabled" = "true"; then
376            ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
377        else
378            ICU_CPPFLAGS=""
379            AC_MSG_WARN([ICU support disabled because XML support is unavailable])
380        fi
381])
382dnl ------ versioning
383dnl
384WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
385AC_SUBST([WIN_FILEVERSION])
386VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
387AC_SUBST([VERSION_HEX])
388if test -d ${srcdir}/.git; then
389    VERSION_SHA1=`git show --pretty=format:%H|head -1`
390else
391    VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
392fi
393AC_SUBST([VERSION_SHA1])
394dnl
395dnl ------ Makefiles
396dnl
397AC_OUTPUT([
398Makefile
399src/Makefile
400test/Makefile
401util/Makefile
402include/Makefile
403include/yaz/Makefile
404client/Makefile
405ztest/Makefile
406zoom/Makefile
407doc/Makefile
408doc/local0.ent
409doc/common/Makefile
410doc/common/print.dsl
411etc/Makefile
412yaz-config
413yaz.pc
414Doxyfile
415win/version.nsi
416include/yaz/yaz-version.h
417],[
418        sed s%echo_source=yes%echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
419        diff doc/local.ent doc/local0.ent >/dev/null 2>/dev/null \
420                || cp doc/local0.ent doc/local.ent
421    ]
422)
423
424
425echo \
426"------------------------------------------------------------------------
427Configuration:
428
429  YAZ Package:                ${PACKAGE}
430  YAZ Version:                ${VERSION}
431  Bugreport:                  ${PACKAGE_BUGREPORT}
432  Source code location:       ${srcdir}
433  C Preprocessor:             ${CPP}
434  C Preprocessor flags:       ${CPPFLAGS}
435  C Compiler:                 ${CC}
436  C Compiler flags:           ${CFLAGS}
437  Linker flags:               ${LDFLAGS}
438  Linked libs:                ${LIBS}
439  Host System Type:           ${host}
440  Install path:               ${prefix}
441  Automake:                   ${AUTOMAKE}
442  Archiver:                   ${AR}
443  Ranlib:                     ${RANLIB}
444
445------------------------------------------------------------------------"
446dnl Local Variables:
447dnl mode:shell-script
448dnl sh-indentation: 2
449dnl sh-basic-offset: 4
450dnl End:
Note: See TracBrowser for help on using the repository browser.