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