1dnl
2dnl
3dnl Process this file with autoconf to produce a configure script.
4dnl
5dnl Copyright (C) 2000-2017 Kern Sibbald
6dnl License: BSD 2-Clause; see file LICENSE-FOSS
7dnl
8dnl require a recent autoconf
9AC_PREREQ(2.61)
10AC_INIT([bacula], m4_esyscmd([sed -n -e 's/^#define VERSION.*"\(.*\)"$/\1/p' ../src/version.h src/version.h 2> /dev/null | tr -d '\n']))
11AC_CONFIG_SRCDIR(src/version.h)
12
13BUILD_DIR=`pwd`
14cd ..
15TOP_DIR=`pwd`
16cd ${BUILD_DIR}
17AC_SUBST(BUILD_DIR)
18AC_SUBST(TOP_DIR)
19AC_CONFIG_AUX_DIR(${BUILD_DIR}/autoconf)
20AC_CONFIG_HEADERS(src/config.h:autoconf/config.h.in)
21
22dnl minimal Win32 stuff for "make clean"
23WIN32BUILDDIR=${BUILD_DIR}/src/win32
24WIN32MAINDIR=${BUILD_DIR}
25WIN32TOPDIR=${TOP_DIR}
26AC_SUBST(WIN32BUILDDIR)
27AC_SUBST(WIN32MAINDIR)
28AC_SUBST(WIN32TOPDIR)
29
30dnl search for true and false programs.
31AC_PATH_PROGS(TRUEPRG, true, :)
32AC_PATH_PROGS(FALSEPRG, false, :)
33
34
35dnl bacula version
36post_host=
37if test "x$BACULA" != x; then
38   post_host=`echo -${BACULA} | tr 'A-Z ' 'a-z-'`
39fi
40BACULA=${BACULA:-Bacula}
41VERSION=`sed -n -e 's/^#define VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
42RELEASE=`sed -n -e 's/^#define RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
43DATE=`sed -n -e 's/^#define BDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
44LSMDATE=`sed -n -e 's/^#define LSMDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
45BDB_VERSION=`sed -n -e 's/^#define BDB_VERSION \(.*\)$/\1/p' ${srcdir}/src/cats/cats.h`
46DEPKGS_VERSION=`sed -n -e 's/^#define DEPKGS_VERSION \(.*\)$/\1/p' ${srcdir}/src/cats/cats.h`
47DEPKGS_QT_VERSION=`sed -n -e 's/^#define DEPKGS_QT_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
48BQT_VERSION=`sed -n -e 's/^#define BQT_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
49VIX_VERSION=`sed -n -e 's/^#define VIX_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
50JAVA_VERSION=`sed -n -e 's/^#define JAVA_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
51NDMP_VERSION=`sed -n -e 's/^#define NDMP_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
52LIBRSYNC_VERSION=`sed -n -e 's/^#define LIBRSYNC_VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
53AC_SUBST(VERSION)dnl
54AC_SUBST(DATE)dnl
55AC_SUBST(LSMDATE)dnl
56AC_SUBST(BACULA)dnl
57AC_SUBST(post_host)dnl
58AC_SUBST(BDB_VERSION)dnl
59AC_SUBST(DEPKGS_QT_VERSION)dnl
60AC_SUBST(DEPKGS_VERSION)dnl
61AC_SUBST(VIX_VERSION)dnl
62AC_SUBST(JAVA_VERSION)dnl
63AC_SUBST(NDMP_VERSION)dnl
64AC_SUBST(LIBRSYNC_VERSION)dnl
65
66
67dnl src/lib
68dnl can be overwritten by specific values from version.h
69LIBBAC_LT_RELEASE=`sed -n -e 's/^#.*LIBBAC_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
70LIBBACCFG_LT_RELEASE=`sed -n -e 's/^#.*LIBBACCFG_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
71LIBBACPY_LT_RELEASE=`sed -n -e 's/^#.*LIBBACPY_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
72
73LIBBAC_LT_RELEASE=${LIBBAC_LT_RELEASE:-$VERSION}
74LIBBACCFG_LT_RELEASE=${LIBBACCFG_LT_RELEASE:-$VERSION}
75
76AC_SUBST(LIBBAC_LT_RELEASE)dnl
77AC_SUBST(LIBBACCFG_LT_RELEASE)dnl
78
79dnl src/cats
80dnl can be overwritten by specific values from version.h
81LIBBACSQL_LT_RELEASE=`sed -n -e 's/^#.*LIBBACSQL_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
82LIBBACCATS_LT_RELEASE=`sed -n -e 's/^#.*LIBBACCATS_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
83
84LIBBACSQL_LT_RELEASE=${LIBBACSQL_LT_RELEASE:-$VERSION}
85LIBBACCATS_LT_RELEASE=${LIBBACCATS_LT_RELEASE:-$VERSION}
86
87AC_SUBST(LIBBACSQL_LT_RELEASE)dnl
88AC_SUBST(LIBBACCATS_LT_RELEASE)dnl
89
90dnl src/findlib
91dnl can be overwritten by specific values from version.h
92LIBBACFIND_LT_RELEASE=`sed -n -e 's/^#.*LIBBACFIND_LT_RELEASE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
93
94LIBBACFIND_LT_RELEASE=${LIBBACFIND_LT_RELEASE:-$VERSION}
95
96AC_SUBST(LIBBACFIND_LT_RELEASE)dnl
97
98dnl PFILES are platform or plugin specific files
99PFILES="platforms/Makefile"
100
101echo "configuring for ${BACULA} $VERSION ($DATE)"
102
103
104dnl -------------------------------------------------------
105dnl Check for compiler.
106dnl ------------------------------------------------------
107
108AC_PROG_CC		dnl this sets $GCC if using GNU C compiler
109AC_PROG_CXX
110AC_PROG_CC_C_O		dnl Determine if C compiler support -c -o.
111AC_PROG_GCC_TRADITIONAL dnl Determine if ioctl() need -traditional.
112
113BASECC=`basename $CC`
114have_gcc=no
115if test x"$GCC" = "xyes"; then
116   AC_DEFINE(HAVE_GCC)
117   have_gcc=yes
118fi
119AC_PATH_PROG(CXX, $CXX, $CXX)
120if test ! -e $CXX; then
121   AC_MSG_ERROR(Unable to find C++ compiler)
122fi
123
124dnl -------------------------------------------------------
125dnl Check for multiarch.
126dnl ------------------------------------------------------
127AC_MSG_CHECKING(for multiarch system)
128multiarch=`$CC $CFLAGS -print-multiarch 2>/dev/null`
129AC_MSG_RESULT($multiarch)
130
131dnl -------------------------------------------------------
132dnl Check for programs.
133dnl ------------------------------------------------------
134AC_PROG_INSTALL
135AC_PATH_PROG(MV, mv, mv)
136dnl Alert !!!
137dnl If we name the variable RM it will shadow the RM variable in the configure script and we overwrite the
138dnl value with the name of the rm command and not rm -f which is its normal content. This gives all kind
139dnl of strange output of the configure script (like things don't exist etc.).
140dnl So we name it REMOVE (more software has run into this problem)
141AC_PATH_PROG(REMOVE, rm, rm)
142AC_PATH_PROG(CP, cp, cp)
143AC_PATH_PROG(SED, sed, sed)
144AC_PATH_PROG(ECHO, echo, echo)
145AC_PATH_PROG(CMP, cmp, cmp)
146AC_PATH_PROG(TBL, tbl, tbl)
147AC_PATH_PROG(AR, ar, ar)
148AC_PATH_PROG(OPENSSL, openssl, none)
149AC_PATH_PROG(MTX, mtx, mtx)
150AC_PATH_PROG(DD, dd, dd)
151AC_PATH_PROG(MKISOFS, mkisofs, mkisofs)
152AC_PATH_PROG(PYTHON, python, python)
153AC_PATH_PROG(GROWISOFS, growisofs, growisofs)
154AC_PATH_PROG(DVDRWMEDIAINFO, dvd+rw-mediainfo, dvd+rw-mediainfo)
155AC_PATH_PROG(DVDRWFORMAT, dvd+rw-format, dvd+rw-format)
156dnl Using AC_PATH_PROG() to find pkg-config is not cross-compile safe.
157dnl The macro PKG_PROG_PKG_CONFIG avoids this problem.
158dnl AC_PATH_PROG(PKGCONFIG, pkg-config, pkg-config)
159PKG_PROG_PKG_CONFIG()
160AC_PATH_PROG(QMAKE, qmake, none)
161AC_PATH_PROG(GMAKE, gmake, none)
162AC_PATH_PROG(PIDOF, pidof, pidof)
163AC_PROG_AWK
164# Some AWK programs fail, so test it and warn the user
165if echo xfoo | $AWK 'BEGIN { prog=ARGV[1]; ARGC=1 }
166      { if ((prog == $2) || (("(" prog ")") == $2) ||
167      (("[" prog "]") == $2) ||
168      ((prog ":") == $2)) { print $1 ; exit 0 } }' xfoo>/dev/null; then :;
169else
170  AC_MSG_ERROR([!!!!!!!!! WARNING !!!!!!!!!!!!!!
171   The regex engine of $AWK is too broken to be used you
172   might want to install GNU AWK.
173   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!])
174fi
175THE_AWK=$AWK
176AC_PATH_PROG(AWK, $THE_AWK, $THE_AWK)
177
178
179test -n "$ARFLAG" || ARFLAGS="cr"
180AC_SUBST(ARFLAGS)
181
182MAKE_SHELL=/bin/sh
183AC_SUBST(MAKE_SHELL)
184
185AC_SUBST(LOCAL_LIBS)
186AC_SUBST(LOCAL_CFLAGS)
187AC_SUBST(LOCAL_LDFLAGS)
188AC_SUBST(LOCAL_DEFS)
189
190dnl --------------------------------------------------
191dnl Libtool config
192dnl --------------------------------------------------
193use_libtool=yes
194AC_ARG_ENABLE(libtool,
195   AC_HELP_STRING([--enable-libtool], [enable building using GNU libtool @<:@default=yes@:>@]),
196   [
197       if test x$enableval = xno; then
198	  use_libtool=no
199       fi
200   ]
201)
202LT_INIT([shared disable-static])
203LT_LIB_DLLOAD
204LT_LANG([C++])
205
206if test x$use_libtool != xno; then
207   DEFAULT_OBJECT_TYPE=".lo"
208   DEFAULT_ARCHIVE_TYPE=".la"
209   DEFAULT_SHARED_OBJECT_TYPE=".la"
210   LIBTOOL="\$(LIBTOOL)"
211   LIBTOOL_INSTALL_TARGET="libtool-install"
212   LIBTOOL_UNINSTALL_TARGET="libtool-uninstall"
213   LIBTOOL_CLEAN_TARGET="libtool-clean"
214   QMAKE_LIBTOOL="${BUILD_DIR}/libtool"
215   FD_PLUGIN_DIR="src/plugins/fd"
216   have_plugins=yes
217else
218   DEFAULT_OBJECT_TYPE=".o"
219   DEFAULT_ARCHIVE_TYPE=".a"
220   DEFAULT_SHARED_OBJECT_TYPE=".so"
221   LIBTOOL="# \$(LIBTOOL)"
222   LIBTOOL_INSTALL_TARGET=""
223   LIBTOOL_UNINSTALL_TARGET=""
224   LIBTOOL_CLEAN_TARGET=""
225   QMAKE_LIBTOOL="# ${BUILD_DIR}/libtool"
226   FD_PLUGIN_DIR=""
227   have_plugins=no
228fi
229
230AC_SUBST(DEFAULT_OBJECT_TYPE)
231AC_SUBST(DEFAULT_ARCHIVE_TYPE)
232AC_SUBST(DEFAULT_SHARED_OBJECT_TYPE)
233AC_SUBST(LIBTOOL)
234AC_SUBST(LIBTOOL_INSTALL_TARGET)
235AC_SUBST(LIBTOOL_UNINSTALL_TARGET)
236AC_SUBST(LIBTOOL_CLEAN_TARGET)
237AC_SUBST(QMAKE_LIBTOOL)
238
239dnl --------------------------------------------------
240dnl Include file handling
241dnl --------------------------------------------------
242AC_ARG_ENABLE(includes,
243   AC_HELP_STRING([--enable-includes], [enable installing of include files @<:@default=no@:>@]),
244   [
245       if test x$enableval = xyes; then
246	  install_includes=yes
247       fi
248   ]
249)
250
251dnl It only makes sense to install include files when you install libraries which only happens when
252dnl libtool is enabled
253
254if test x$use_libtool != xno -a x$install_includes = xyes; then
255   INCLUDE_INSTALL_TARGET="install-includes"
256   INCLUDE_UNINSTALL_TARGET="uninstall-includes"
257else
258   INCLUDE_INSTALL_TARGET=""
259   INCLUDE_UNINSTALL_TARGET=""
260fi
261AC_SUBST(INCLUDE_INSTALL_TARGET)
262AC_SUBST(INCLUDE_UNINSTALL_TARGET)
263
264dnl --------------------------------------------------
265dnl Bacula OP Sys determination (see aclocal.m4)
266dnl --------------------------------------------------
267BA_CHECK_OPSYS
268
269dnl -----------------------------------------------------------
270dnl Bacula OPSys Distribution determination (see aclocal.m4)
271dnl ----------------------------------------------------------
272BA_CHECK_OPSYS_DISTNAME
273
274dnl --------------------------------------------------
275dnl Suppport for gettext (translations)
276dnl By default, $datarootdir is ${prefix}/share
277dnl --------------------------------------------------
278AM_GNU_GETTEXT([external])
279
280dnl ------------------------------------------------------------------
281dnl If the user has not set --prefix, we set our default to nothing.
282dnl In this case, if the user has not set --sysconfdir, we set it
283dnl to the package default of /etc/bacula.  If either --prefix or
284dnl --sysconfdir is set, we leave sysconfdir alone except to eval it.
285dnl If the user has not set --libdir, we set it to the package
286dnl default of /usr/lib. If either --prefix or --libdir is set,
287dnl we leave libdir alone except to eval it. If the user has not set
288dnl --includedir, we set it to the package default of /usr/include.
289dnl If either --prefix or --includedir is set, we leave includedir
290dnl alone except to eval it
291dnl ------------------------------------------------------------------
292os_name=`uname -s 2>/dev/null`
293if test x${prefix} = xNONE ; then
294   if test `eval echo ${sysconfdir}` = NONE/etc ; then
295      sysconfdir=/etc/bacula
296   fi
297
298   if test `eval echo ${libdir}` = NONE/lib ; then
299      case ${os_name} in
300      Linux)
301	 os_processor=`uname -p 2>/dev/null`
302	 case ${os_processor} in
303	 x86_64)
304	    libdir=/usr/lib64
305	    ;;
306	 *)
307	    libdir=/usr/lib
308	    ;;
309	 esac
310	 ;;
311      *)
312	 libdir=/usr/lib
313	 ;;
314      esac
315   fi
316
317   if test `eval echo ${includedir}` = NONE/include ; then
318      includedir=/usr/include
319   fi
320
321   if test `eval echo ${datarootdir}` = NONE/share ; then
322      datarootdir=/usr/share
323   fi
324   prefix=
325fi
326
327dnl -------------------------------------------------------------------------
328dnl  If the user has not set --exec-prefix, we default to ${prefix}
329dnl -------------------------------------------------------------------------
330if test x${exec_prefix} = xNONE ; then
331   exec_prefix=${prefix}
332fi
333
334sysconfdir=`eval echo ${sysconfdir}`
335datarootdir=`eval echo ${datarootdir}`
336docdir=`eval echo ${docdir}`
337htmldir=`eval echo ${htmldir}`
338libdir=`eval echo ${libdir}`
339includedir=`eval echo ${includedir}`
340localedir=`eval echo ${datarootdir}/locale`
341AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")
342AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir")
343
344dnl ------------------------------------------------------------------
345dnl If the user has not set --sbindir, we set our default as /sbin
346dnl ------------------------------------------------------------------
347if test x$sbindir = x'${exec_prefix}/sbin' ; then
348   sbindir=${exec_prefix}/sbin
349fi
350sbindir=`eval echo ${sbindir}`
351
352dnl -------------------------------------------------------------------------
353dnl  If the user has not set --mandir, we default to /usr/share/man
354dnl -------------------------------------------------------------------------
355if test x$mandir = x'${datarootdir}/man' ; then
356   mandir=/usr/share/man
357fi
358
359dnl -------------------------------------------------------------------------
360dnl  If the user has not set --htmldir, we default to /usr/share/doc/bacula/html
361dnl -------------------------------------------------------------------------
362if test x$htmldir = x'/usr/share/doc/bacula/' ; then
363   htmldir=`eval echo ${docdir}html`
364fi
365
366dnl -------------------------------------------------------------------------
367dnl  If the user has not set --docdir, we default to /usr/share/doc/bacula
368dnl -------------------------------------------------------------------------
369if test x$docdir = x'/usr/share/doc/' ; then
370   docdir=`eval echo ${docdir}bacula`
371fi
372
373
374AC_PATH_PROGS(MSGFMT, msgfmt, no)
375if test "$MSGFMT" = "no"
376then
377   echo 'msgfmt program not found, disabling NLS !'
378   USE_NLS=no
379   USE_INCLUDED_LIBINTL=no
380#else
381   AM_GNU_GETTEXT
382fi
383
384support_smartalloc=yes
385support_readline=yes
386support_lzo=yes
387support_s3=yes
388support_conio=yes
389support_bat=no
390support_tls=no
391support_crypto=no
392support_static_tools=no
393support_static_fd=no
394support_static_sd=no
395support_static_dir=no
396support_static_cons=no
397build_client_only=no
398build_dird=yes
399build_stored=yes
400db_backends=""
401batch_insert_db_backends=""
402support_lockmgr=no
403
404dnl --------------------------------------------------------------------------
405dnl CHECKING COMMAND LINE OPTIONS
406dnl --------------------------------------------------------------------------
407
408dnl -------------------------------------------
409dnl bat (default off)
410dnl -------------------------------------------
411AC_ARG_ENABLE(bat,
412   AC_HELP_STRING([--enable-bat], [enable build of bat Qt4/5 GUI @<:@default=no@:>@]),
413   [
414       if test x$enableval = xyes; then
415	  AC_DEFINE(HAVE_BAT, 1, [Set if Bacula bat Qt4/5 GUI support enabled])
416	  support_bat=yes
417       fi
418   ]
419)
420
421BAT_DIR=
422if test x$support_bat = xyes; then
423dnl look for Qt4
424   abc=`$PKG_CONFIG QtGui`
425   pkg=$?
426   if test $pkg = 0; then
427      BAT_DIR=src/qt-console
428   else
429dnl look for Qt5
430     abc=`$PKG_CONFIG Qt5Gui`
431     pkg=$?
432     if test $pkg = 0; then
433	BAT_DIR="src/qt-console src/qt-console/tray-monitor"
434     else
435	AC_MSG_ERROR(Unable to find either Qt4 or Qt5 installation needed by bat)
436     fi
437   fi
438fi
439
440AC_SUBST(BAT_DIR)
441AC_SUBST(QWT_INC)
442AC_SUBST(QWT_LDFLAGS)
443AC_SUBST(QWT_LIB)
444AC_SUBST(QWT)
445
446dnl -------------------------------------------
447dnl smartalloc (default off)
448dnl -------------------------------------------
449AC_ARG_ENABLE(smartalloc,
450   AC_HELP_STRING([--enable-smartalloc], [enable smartalloc debugging support @<:@default=no@:>@]),
451   [
452       if test x$enableval = xno; then
453	  support_smartalloc=no
454       fi
455   ]
456)
457
458if test x$support_smartalloc = xyes; then
459   AC_DEFINE(SMARTALLOC, 1, [Set if you want Smartalloc enabled])
460fi
461
462dnl -------------------------------------------
463dnl Lock Manager (default off)
464dnl -------------------------------------------
465AC_ARG_ENABLE(lockmgr,
466   AC_HELP_STRING([--enable-lockmgr], [enable lock manager support @<:@default=no@:>@]),
467   [
468       if test x$enableval = xyes; then
469	  support_lockmgr=yes
470       fi
471   ]
472)
473
474if test x$support_lockmgr = xyes; then
475   AC_DEFINE(USE_LOCKMGR, 1, [Set if you want Lock Manager enabled])
476fi
477
478
479dnl -------------------------------------------
480dnl static-tools (default off)
481dnl -------------------------------------------
482AC_ARG_ENABLE(static-tools,
483   AC_HELP_STRING([--enable-static-tools], [enable static tape tools @<:@default=no@:>@]),
484   [
485       if test x$enableval = xyes; then
486	  if test x$use_libtool = xyes; then
487	     AC_MSG_ERROR([Libtool is enabled, not compatible with static tools,
488  please rerun configure with --disable-libtool])
489	  fi
490	  support_static_tools=yes
491       fi
492   ]
493)
494
495TTOOL_LDFLAGS=
496if test x$support_static_tools = xyes; then
497   TTOOL_LDFLAGS="-static"
498fi
499AC_SUBST(TTOOL_LDFLAGS)
500
501dnl -------------------------------------------
502dnl static-fd	 (default off)
503dnl -------------------------------------------
504AC_ARG_ENABLE(static-fd,
505   AC_HELP_STRING([--enable-static-fd], [enable static File daemon @<:@default=no@:>@]),
506   [
507       if test x$enableval = xyes; then
508	  if test x$use_libtool = xyes; then
509	     AC_MSG_ERROR([Libtool is enabled, not compatible with static tools,
510  please rerun configure with --disable-libtool])
511	  fi
512	  support_static_fd=yes
513       fi
514   ]
515)
516
517STATIC_FD=
518if test x$support_static_fd = xyes; then
519   STATIC_FD="static-bacula-fd"
520fi
521AC_SUBST(STATIC_FD)
522
523dnl -------------------------------------------
524dnl static-sd	 (default off)
525dnl -------------------------------------------
526AC_ARG_ENABLE(static-sd,
527   AC_HELP_STRING([--enable-static-sd], [enable static Storage daemon @<:@default=no@:>@]),
528   [
529       if test x$enableval = xyes; then
530	  if test x$use_libtool = xyes; then
531	     AC_MSG_ERROR([Libtool is enabled, not compatible with static tools,
532  please rerun configure with --disable-libtool])
533	  fi
534	  support_static_sd=yes
535       fi
536   ]
537)
538
539STATIC_SD=
540if test x$support_static_sd = xyes; then
541   STATIC_SD="static-bacula-sd"
542fi
543AC_SUBST(STATIC_SD)
544
545dnl -------------------------------------------
546dnl static-dir	 (default off)
547dnl -------------------------------------------
548AC_ARG_ENABLE(static-dir,
549   AC_HELP_STRING([--enable-static-dir], [enable static Director @<:@default=no@:>@]),
550   [
551       if test x$enableval = xyes; then
552	  if test x$use_libtool = xyes; then
553	     AC_MSG_ERROR([Libtool is enabled, not compatible with static tools,
554  please rerun configure with --disable-libtool])
555	  fi
556	  support_static_dir=yes
557       fi
558   ]
559)
560
561STATIC_DIR=
562if test x$support_static_dir = xyes; then
563   STATIC_DIR="static-bacula-dir"
564fi
565AC_SUBST(STATIC_DIR)
566
567dnl -------------------------------------------
568dnl static-cons  (default off)
569dnl -------------------------------------------
570AC_ARG_ENABLE(static-cons,
571   AC_HELP_STRING([--enable-static-cons], [enable static Console @<:@default=no@:>@]),
572   [
573       if test x$enableval = xyes; then
574	  if test x$use_libtool = xyes; then
575	     AC_MSG_ERROR([Libtool is enabled, not compatible with static tools,
576  please rerun configure with --disable-libtool])
577	  fi
578	  support_static_cons=yes
579       fi
580   ]
581)
582
583STATIC_CONS=
584if test x$support_static_cons = xyes; then
585   STATIC_CONS="static-bconsole"
586fi
587AC_SUBST(STATIC_CONS)
588
589dnl -------------------------------------------
590dnl client_only  (default off)
591dnl -------------------------------------------
592AC_ARG_ENABLE(client-only,
593   AC_HELP_STRING([--enable-client-only], [build client (File daemon) only @<:@default=no@:>@]),
594   [
595      if test x$enableval = xyes; then
596         build_client_only=yes
597         db_backends="None"
598         DB_BACKENDS="none"
599      fi
600   ]
601)
602if test x$build_client_only = xno; then
603   ALL_DIRS="subdirs"
604   AC_DEFINE(HAVE_CLIENT_ONLY, 1, [Set if we build only client])
605else
606   ALL_DIRS=""
607fi
608AC_SUBST(ALL_DIRS)
609
610dnl -------------------------------------------
611dnl director  (default on)
612dnl -------------------------------------------
613AC_ARG_ENABLE(build-dird,
614   AC_HELP_STRING([--enable-build-dird], [enable building of dird (Director) @<:@default=yes@:>@]),
615   [
616      if test x$enableval = xno; then
617         build_dird=no
618      fi
619   ]
620)
621
622DIRD_DIR="src/dird"
623DIR_TOOLS="DIRTOOLS"
624
625AC_SUBST(DIRD_DIR)
626AC_SUBST(DIR_TOOLS)
627
628dnl -------------------------------------------
629dnl stored  (default on)
630dnl -------------------------------------------
631AC_ARG_ENABLE(build-stored,
632   AC_HELP_STRING([--enable-build-stored], [enable building of stored (Storage daemon) @<:@default=yes@:>@]),
633   [
634      if test x$enableval = xno; then
635	 build_stored=no
636      fi
637   ]
638)
639if test x$build_stored = xyes; then
640   STORED_DIR="src/stored"
641else
642   STORED_DIR=""
643fi
644AC_SUBST(STORED_DIR)
645
646dnl ---------------------------------------------------
647dnl Check for conio (Bacula readline substitute)(
648dnl ---------------------------------------------------
649dnl this allows you to turn it completely off
650AC_ARG_ENABLE(conio,
651   AC_HELP_STRING([--disable-conio], [disable conio support @<:@default=no@:>@]),
652   [
653       if test x$enableval = xno; then
654	  support_conio=no
655       fi
656   ]
657)
658
659
660dnl ---------------------------------------------------
661dnl Check for IPv6 support
662dnl ---------------------------------------------------
663dnl this allows you to turn it completely off
664support_ipv6=yes
665AC_ARG_ENABLE(ipv6,
666   AC_HELP_STRING([--enable-ipv6], [enable ipv6 support @<:@default=yes@:>@]),
667   [
668       if test x$enableval = xno; then
669	  support_ipv6=no
670       fi
671   ]
672)
673
674if test x$support_ipv6 = xyes; then
675    AC_TRY_LINK([ #include <sys/types.h>
676#include <sys/socket.h>
677#include <netinet/in.h>], [struct in6_addr t=in6addr_any; t.s6_addr[0] = 0;],
678      [support_in6addr_any=yes], [support_in6addr_any=no])
679
680   if test x$support_in6addr_any = xno ; then
681       in6addr_any="const struct in6_addr in6addr_any"
682   else
683       in6addr_any="1"
684   fi
685
686   AC_TRY_LINK([ #include <sys/types.h>
687#include <sys/socket.h>
688#include <netinet/in.h>], [$in6addr_any; struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;],
689      [support_ipv6=yes], [support_ipv6=no])
690fi
691
692if test x$support_ipv6 = xyes; then
693   AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
694
695   if test x$support_in6addr_any = xno ; then
696      AC_DEFINE(NEED_IN6ADDR_ANY,1,[Whether to have in6addr_any support])
697   fi
698fi
699
700TERM_LIB=""
701AC_CHECK_HEADER(curses.h, [
702    AC_CHECK_LIB(tinfo, tgetent, [ TERM_LIB="-ltinfo" ], [
703      AC_CHECK_LIB(ncurses, tgetent, [ TERM_LIB="-lncurses" ], [
704	AC_CHECK_LIB(termcap, tgetent, [ TERM_LIB="-ltermcap" ])
705    ])
706  ])
707  ],
708  [  AC_CHECK_HEADERS(curses.h)
709     AC_CHECK_HEADER(term.h,
710       [ AC_CHECK_LIB(curses, tgetent,
711	 [ TERM_LIB="-lcurses" ] )
712       ])
713  ])
714
715
716got_conio="no"
717if test x$support_conio = xyes; then
718   if test x$TERM_LIB != x; then
719      CONS_LIBS=$TERM_LIB
720      CONS_OBJ="conio.o"
721      CONS_SRC="conio.c"
722      got_conio="yes"
723      support_readline=no
724      AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled])
725   else
726      echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " "
727   fi
728fi
729
730
731dnl ---------------------------------------------------
732dnl Check for readline support/directory (default off)
733dnl ---------------------------------------------------
734dnl this allows you to turn it completely off
735AC_ARG_ENABLE(readline,
736   AC_HELP_STRING([--disable-readline], [disable readline support @<:@default=yes@:>@]),
737   [
738       if test x$enableval = xno; then
739	  support_readline=no
740       fi
741   ]
742)
743
744got_readline="no"
745READLINE_SRC=
746if test x$support_readline = xyes; then
747   AC_ARG_WITH(readline,
748      AC_HELP_STRING([--with-readline@<:@=DIR@:>@], [specify readline library directory]),
749      [
750	  case "$with_readline" in
751	  no)
752	     :
753	     ;;
754	  yes|*)
755	     if test -f ${with_readline}/readline.h; then
756		CONS_INC="-I${with_readline}"
757		CONS_LDFLAGS="-L$with_readline"
758	     elif test -f ${with_readline}/include/readline/readline.h; then
759		CONS_INC="-I${with_readline}/include/readline"
760		CONS_LDFLAGS="-L${with_readline}/lib"
761		with_readline="${with_readline}/include/readline"
762	     else
763		with_readline="/usr/include/readline"
764	     fi
765
766	     AC_CHECK_HEADER(${with_readline}/readline.h,
767		[
768		    AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
769		    CONS_LIBS="-lreadline -lhistory ${TERM_LIB}"
770		    got_readline="yes"
771		], [
772		    echo " "
773		    echo "readline.h not found. readline turned off ..."
774		    echo " "
775		]
776	     )
777	     ;;
778	  esac
779      ],[
780	 dnl check for standard readline library
781	 AC_CHECK_HEADER(/usr/include/readline/readline.h,
782	    [
783		AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
784		got_readline="yes"
785		CONS_INC="-I/usr/include/readline"
786		CONS_LIBS="-lreadline ${TERM_LIB}"
787	    ], [
788		dnl Did not find standard library, so try Bacula's default
789		AC_CHECK_HEADER(${TOP_DIR}/depkgs/readline/readline.h,
790		    [
791			AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
792			got_readline="yes"
793			CONS_INC="-I${TOP_DIR}/depkgs/readline"
794			CONS_LIBS="-lreadline -lhistory ${TERM_LIB}"
795			CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
796			PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
797		    ], [
798			echo " "
799			echo "readline.h not found. readline turned off ..."
800			echo " "
801		    ]
802		)
803	    ]
804	 )
805      ]
806   )
807fi
808
809AC_SUBST(CONS_INC)
810AC_SUBST(CONS_OBJ)
811AC_SUBST(CONS_SRC)
812AC_SUBST(CONS_LIBS)
813AC_SUBST(CONS_LDFLAGS)
814AC_SUBST(READLINE_SRC)
815
816dnl Minimal stuff for readline Makefile configuration
817MAKE_SHELL=/bin/sh
818AC_SUBST(MAKE_SHELL)
819AC_HEADER_STAT
820AC_HEADER_DIRENT
821AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr)
822AC_CHECK_FUNCS(lstat lchown lchmod futimes fchmod fchown lutimes)
823AC_CHECK_FUNCS(nanosleep nl_langinfo)
824AC_CHECK_FUNCS(be64toh htobe64)
825AC_CHECK_HEADERS(varargs.h)
826
827dnl End of readline/conio stuff
828dnl -----------------------------------------------------------------------
829
830dnl
831dnl Find where sockets are (especially for Solaris)
832dnl Do this before the TCP Wrappers test since tcp wrappers
833dnl uses the socket library and some linkers are stupid.
834dnl
835AC_CHECK_FUNC(socket,
836    AC_MSG_RESULT(using libc's socket),
837    AC_CHECK_LIB(xnet,socket)
838    AC_CHECK_LIB(socket,socket)
839    AC_CHECK_LIB(inet,socket))
840
841dnl -----------------------------------------------------------
842dnl Check whether user wants TCP wrappers support (default off)
843dnl -----------------------------------------------------------
844TCPW_MSG="no"
845WRAPLIBS=""
846AC_ARG_WITH(tcp-wrappers,
847   AC_HELP_STRING([--with-tcp-wrappers@<:@=DIR@:>@], [enable tcpwrappers support]),
848   [
849       if test "x$withval" != "xno" ; then
850	  saved_LIBS="$LIBS"
851	  LIBS="$saved_LIBS -lwrap"
852	  AC_SEARCH_LIBS(nanosleep, [rt])
853	  AC_MSG_CHECKING(for libwrap)
854	  AC_TRY_LINK(
855	     [
856	       #include <sys/types.h>
857	       #include <tcpd.h>
858	       int deny_severity = 0;
859	       int allow_severity = 0;
860	       struct request_info *req;
861	     ], [
862		hosts_access(req);
863	     ], [
864		 AC_MSG_RESULT(yes)
865		 AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
866		 TCPW_MSG="yes"
867		 LIBS="$saved_LIBS"
868		 WRAPLIBS="-lwrap"
869	     ], [
870		 LIBS="$saved_LIBS -lwrap -lnsl"
871		 WRAPLIBS="$saved_LIBS -lwrap -lnsl"
872		 AC_TRY_LINK(
873		   [
874		       #include <sys/types.h>
875		       #include <tcpd.h>
876		       int deny_severity = 0;
877		       int allow_severity = 0;
878		       struct request_info *req;
879		   ], [
880		       hosts_access(req);
881		   ], [
882		      AC_MSG_RESULT(yes)
883		      AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
884		      TCPW_MSG="yes"
885		      LIBS="$saved_LIBS"
886		      WRAPLIBS="-lwrap"
887		   ], [
888		      AC_MSG_ERROR([*** libwrap missing])
889		   ]
890		)
891	     ]
892	  )
893       fi
894   ]
895)
896
897TOKYOCABINET_LIBS=
898TOKYOCABINET_INC=
899
900AC_SUBST(TOKYOCABINET_LIBS)
901AC_SUBST(TOKYOCABINET_INC)
902
903
904dnl -----------------------------------------------------------
905dnl Check whether OpenSSL is available
906dnl -----------------------------------------------------------
907AC_MSG_CHECKING([for OpenSSL])
908dnl The following uses quadrigraphs:
909dnl '@<:@' = '['
910dnl '@:>@' = ']'
911AC_ARG_WITH(openssl,
912    AC_HELP_STRING([--with-openssl@<:@=DIR@:>@], [Include OpenSSL support. DIR is the OpenSSL base]),
913    [
914	with_openssl_directory=${withval}
915    ]
916)
917
918if test "x$with_openssl_directory" != "xno"; then
919   OPENSSL_LIBS="-lssl -lcrypto"
920   OPENSSL_INC=""
921
922   if test "x$with_openssl_directory" != "xyes" && test x"${with_openssl_directory}" != "x"; then
923      #
924      # Make sure the $with_openssl_directory also makes sense
925      #
926      if test -d "$with_openssl_directory/lib" -a -d "$with_openssl_directory/include"; then
927	 OPENSSL_LIBS="-L$with_openssl_directory/lib $OPENSSL_LIBS"
928	 OPENSSL_INC="-I$with_openssl_directory/include $OPENSSL_INC"
929      fi
930   fi
931
932   saved_LIBS="${LIBS}"
933   saved_CFLAGS="${CFLAGS}"
934   LIBS="${saved_LIBS} ${OPENSSL_LIBS}"
935   CFLAGS="${saved_CFLAGS} ${OPENSSL_INC}"
936
937   AC_TRY_LINK(
938      [
939	  #include <openssl/ssl.h>
940      ], [
941	   CRYPTO_set_id_callback(NULL);
942      ], [
943	  support_tls="yes"
944	  support_crypto="yes"
945      ], [
946	  support_tls="no"
947	  support_crypto="no"
948      ]
949   )
950
951   AC_TRY_LINK(
952      [
953	  #include <openssl/evp.h>
954      ], [
955	  EVP_sha512();
956      ], [
957	  ac_cv_openssl_sha2="yes"
958      ], [
959	  ac_cv_openssl_sha2="no"
960      ]
961   )
962
963   dnl Solaris disables greater than 128+ bit encryption in their OpenSSL
964   dnl implementation, presumably for export reasons. If 192bit AES
965   dnl is available, we assume that we're running with a 'non-export'
966   dnl openssl library.
967   AC_TRY_LINK(
968      [
969	  #include <openssl/evp.h>
970      ], [
971	  EVP_aes_192_cbc();
972      ], [
973	  ac_cv_openssl_export="no"
974      ], [
975	  ac_cv_openssl_export="yes"
976      ]
977   )
978
979   AC_MSG_RESULT([$support_tls])
980   if test "$support_tls" = "yes"; then
981      AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL library is available])
982      AC_DEFINE(HAVE_TLS, 1, [Define if TLS support should be enabled])
983      AC_DEFINE(HAVE_CRYPTO, 1, [Define if encryption support should be enabled])
984   fi
985
986   if test "$ac_cv_openssl_sha2" = "yes"; then
987      AC_DEFINE(HAVE_SHA2, 1, [Define if the SHA-2 family of digest algorithms is available])
988   fi
989
990   if test "$ac_cv_openssl_export" = "yes"; then
991      AC_DEFINE(HAVE_OPENSSL_EXPORT_LIBRARY, 1, [Define if the OpenSSL library is export-contrained to 128bit ciphers])
992   fi
993
994   if test "$support_crypto" = "yes"; then
995      AC_CHECK_LIB(crypto, EVP_PKEY_encrypt_old, AC_DEFINE(HAVE_OPENSSLv1, 1, [Set if have OpenSSL version 1.x]))
996   fi
997
998   LIBS="${saved_LIBS}"
999   CFLAGS="${saved_CFLAGS}"
1000else
1001   support_tls="no"
1002   support_crypto="no"
1003   AC_MSG_RESULT([$support_tls])
1004fi
1005
1006if test "$support_tls" = "no" -o "$support_crypto" = "no"; then
1007   OPENSSL_LIBS=""
1008   OPENSSL_INC=""
1009fi
1010
1011AC_SUBST(OPENSSL_LIBS)
1012AC_SUBST(OPENSSL_INC)
1013
1014dnl -----------------------------------------------------------
1015dnl dlopen is needed for plugins
1016dnl -----------------------------------------------------------
1017AC_SEARCH_LIBS(dlopen, [dl])
1018
1019dnl -----------------------------------------------------------
1020dnl check for macOS IOKit
1021dnl -----------------------------------------------------------
1022IOKITLIBS=""
1023if test x${HAVE_DARWIN_OS_TRUE} = x; then
1024   AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLib.h,
1025      IOKITLIBS="-framework IOKit"
1026   )
1027fi
1028AC_SUBST(IOKITLIBS)
1029
1030dnl ------------------------------------------
1031dnl Where to place working dir
1032dnl ------------------------------------------
1033working_dir=`eval echo /opt/bacula/working`
1034AC_ARG_WITH(working-dir,
1035   AC_HELP_STRING([--with-working-dir=PATH], [specify path of Bacula working directory]),
1036   [
1037       if test "x$withval" != "xno" ; then
1038	 working_dir=$withval
1039       fi
1040   ]
1041)
1042
1043AC_SUBST(working_dir)
1044
1045dnl ------------------------------------------------------------------
1046dnl If the user has not set archivedir, we set our default as /tmp
1047dnl ------------------------------------------------------------------
1048archivedir=/tmp
1049AC_ARG_WITH(archivedir,
1050   AC_HELP_STRING([--with-archivedir=PATH], [specify path of SD archive directory]),
1051   [
1052       if test "x$withval" != "xno" ; then
1053	  archivedir=$withval
1054       fi
1055   ]
1056)
1057
1058AC_SUBST(archivedir)
1059
1060dnl ------------------------------------------------------------------
1061dnl Allow the user to specify the daemon resource name default hostname
1062dnl ------------------------------------------------------------------
1063basename=`hostname`
1064AC_ARG_WITH(basename,
1065   AC_HELP_STRING([--with-basename=RESNAME], [specify base resource name for daemons]),
1066   [
1067       if test "x$withval" != "xno" ; then
1068	  basename=$withval
1069       fi
1070   ]
1071)
1072
1073AC_SUBST(basename)
1074
1075dnl ------------------------------------------------------------------
1076dnl Allow the user to override the hostname (default = machine hostname)
1077dnl ------------------------------------------------------------------
1078hostname=`uname -n | cut -d '.' -f 1`
1079if test x${hostname} = x ; then
1080  hostname="localhost"
1081fi
1082dnl Make sure hostname is resolved
1083ping -c 1 $hostname 2>/dev/null 1>/dev/null
1084if test ! $? = 0; then
1085  hostname="localhost"
1086fi
1087AC_ARG_WITH(hostname,
1088   AC_HELP_STRING([--with-hostname=RESNAME], [specify host name for daemons]),
1089   [
1090       if test "x$withval" != "xno" ; then
1091	 hostname=$withval
1092       fi
1093   ]
1094)
1095
1096AC_SUBST(hostname)
1097
1098
1099dnl ------------------------------------------
1100dnl Where to place scriptdir (script files)
1101dnl ------------------------------------------
1102scriptdir=`eval echo ${sysconfdir}`
1103AC_ARG_WITH(scriptdir,
1104   AC_HELP_STRING([--with-scriptdir=PATH], [specify path of Bacula scripts directory]),
1105   [
1106       if test "x$withval" != "xno" ; then
1107	  scriptdir=$withval
1108       fi
1109   ]
1110)
1111
1112AC_SUBST(scriptdir)
1113
1114
1115dnl ------------------------------------------
1116dnl Where to place bsrdir (bsr files)
1117dnl ------------------------------------------
1118bsrdir=`eval echo /opt/bacula/bsr`
1119AC_ARG_WITH(bsrdir,
1120   AC_HELP_STRING([--with-bsrdir=PATH], [specify path of Bacula bsrs directory]),
1121   [
1122       if test "x$withval" != "xno" ; then
1123	  bsrdir=$withval
1124       fi
1125   ]
1126)
1127
1128AC_SUBST(bsrdir)
1129
1130dnl ------------------------------------------
1131dnl Where to place logdir
1132dnl ------------------------------------------
1133logdir=`eval echo /opt/bacula/log`
1134AC_ARG_WITH(logdir,
1135   AC_HELP_STRING([--with-logdir=PATH], [specify path of Bacula logs directory]),
1136   [
1137       if test "x$withval" != "xno" ; then
1138	  logdir=$withval
1139       fi
1140   ]
1141)
1142
1143AC_SUBST(logdir)
1144
1145
1146# ------------------------------------------
1147# Where to place plugindir (plugin files)
1148# ------------------------------------------
1149plugindir=`eval echo ${libdir}`
1150AC_ARG_WITH(plugindir,
1151   AC_HELP_STRING([--with-plugindir=PATH], [specify path of Bacula plugins directory]),
1152   [
1153       if test "x$withval" != "xno" ; then
1154	  plugindir=$withval
1155       fi
1156   ]
1157)
1158
1159AC_SUBST(plugindir)
1160
1161dnl ------------------------------------------
1162dnl Where to send dump email
1163dnl ------------------------------------------
1164
1165dnl ------------------------------------------
1166dnl Where to send dump email
1167dnl ------------------------------------------
1168dump_email=root@localhost
1169AC_ARG_WITH(dump-email,
1170   AC_HELP_STRING([--with-dump-email=EMAIL], [dump email address]),
1171   [
1172       if test "x$withval" != "xno" ; then
1173	  dump_email=$withval
1174       fi
1175   ]
1176)
1177
1178AC_SUBST(dump_email)
1179
1180dnl ------------------------------------------
1181dnl Where to send job email
1182dnl ------------------------------------------
1183job_email=root@localhost
1184AC_ARG_WITH(job-email,
1185   AC_HELP_STRING([--with-job-email=EMAIL], [job output email address]),
1186   [
1187       if test "x$withval" != "xno" ; then
1188	  job_email=$withval
1189       fi
1190   ]
1191)
1192
1193AC_SUBST(job_email)
1194
1195dnl ------------------------------------------
1196dnl Where to find smtp host
1197dnl ------------------------------------------
1198smtp_host=localhost
1199AC_ARG_WITH(smtp_host,
1200   AC_HELP_STRING([--with-smtp-host=HOST], [SMTP mail host address]),
1201   [
1202       if test "x$withval" != "xno" ; then
1203	  smtp_host=$withval
1204       fi
1205   ]
1206)
1207
1208AC_SUBST(smtp_host)
1209
1210dnl ------------------------------------
1211dnl Where to place pid files
1212dnl ------------------------------------
1213piddir=/var/run
1214AC_ARG_WITH(pid-dir,
1215   AC_HELP_STRING([--with-pid-dir=PATH], [specify location of Bacula pid files]),
1216   [
1217       if test "x$withval" != "xno" ; then
1218	  piddir=$withval
1219       fi
1220   ]
1221)
1222
1223AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
1224AC_SUBST(piddir)
1225
1226dnl ------------------------------------
1227dnl Where to place subsys "lock file"
1228dnl ------------------------------------
1229subsysdir=/var/run/subsys
1230if test -d /var/run/subsys; then
1231   subsysdir=/var/run/subsys
1232elif test -d /var/lock/subsys; then
1233   subsysdir=/var/lock/subsys
1234else
1235   subsysdir=/var/run/subsys
1236fi
1237AC_ARG_WITH(subsys-dir,
1238   AC_HELP_STRING([--with-subsys-dir=PATH], [specify location of Bacula subsys file]),
1239   [
1240       if test "x$withval" != "xno" ; then
1241	  subsysdir=$withval
1242       fi
1243   ]
1244)
1245
1246AC_SUBST(subsysdir)
1247
1248dnl ------------------------------------
1249dnl Where to start assigning ports
1250dnl ------------------------------------
1251baseport=9101
1252AC_ARG_WITH(baseport,
1253   AC_HELP_STRING([--with-baseport=PORT], [specify base port address for daemons]),
1254   [
1255       if test "x$withval" != "xno" ; then
1256	  baseport=$withval
1257       fi
1258   ]
1259)
1260
1261AC_SUBST(baseport)
1262dir_port=`expr $baseport`
1263fd_port=`expr $baseport + 1`
1264sd_port=`expr $fd_port + 1`
1265
1266AC_SUBST(dir_port)
1267AC_SUBST(fd_port)
1268AC_SUBST(sd_port)
1269
1270dnl ------------------------------------------
1271dnl Generate passwords
1272dnl ------------------------------------------
1273dir_password=
1274AC_ARG_WITH(dir-password,
1275   AC_HELP_STRING([--with-dir-password=PASSWORD], [specify Director's password]),
1276   [
1277       if test "x$withval" != "xno" ; then
1278	  dir_password=$withval
1279       fi
1280   ]
1281)
1282
1283if test "x$dir_password" = "x" ; then
1284   if test "x$OPENSSL" = "xnone" ; then
1285      key=`autoconf/randpass 33`
1286   else
1287      key=`openssl rand -base64 33`
1288   fi
1289   dir_password=$key
1290fi
1291
1292fd_password=
1293AC_ARG_WITH(fd-password,
1294   AC_HELP_STRING([--with-fd-password=PASSWORD], [specify Client's password]),
1295   [
1296       if test "x$withval" != "xno" ; then
1297	  fd_password=$withval
1298       fi
1299   ]
1300)
1301
1302if test "x$fd_password" = "x" ; then
1303   if test "x$OPENSSL" = "xnone" ; then
1304      key=`autoconf/randpass 37`
1305   else
1306      key=`openssl rand -base64 33`
1307   fi
1308   fd_password=$key
1309fi
1310
1311sd_password=
1312AC_ARG_WITH(sd-password,
1313   AC_HELP_STRING([--with-sd-password=PASSWORD], [specify Storage daemon's password]),
1314   [
1315       if test "x$withval" != "xno" ; then
1316	  sd_password=$withval
1317       fi
1318   ]
1319)
1320
1321if test "x$sd_password" = "x" ; then
1322   if test "x$OPENSSL" = "xnone" ; then
1323      key=`autoconf/randpass 41`
1324   else
1325      key=`openssl rand -base64 33`
1326   fi
1327   sd_password=$key
1328fi
1329
1330mon_dir_password=
1331AC_ARG_WITH(mon-dir-password,
1332   AC_HELP_STRING([--with-mon-dir-password=PASSWORD], [specify Director's password used by the monitor]),
1333   [
1334       if test "x$withval" != "xno" ; then
1335	  mon_dir_password=$withval
1336       fi
1337   ]
1338)
1339
1340if test "x$mon_dir_password" = "x" ; then
1341   if test "x$OPENSSL" = "xnone" ; then
1342      key=`autoconf/randpass 33`
1343   else
1344      key=`openssl rand -base64 33`
1345   fi
1346   mon_dir_password=$key
1347fi
1348
1349mon_fd_password=
1350AC_ARG_WITH(mon-fd-password,
1351   AC_HELP_STRING([--with-mon-fd-password=PASSWORD], [specify Client's password used by the monitor]),
1352   [
1353       if test "x$withval" != "xno" ; then
1354	  mon_fd_password=$withval
1355       fi
1356   ]
1357)
1358
1359if test "x$mon_fd_password" = "x" ; then
1360   if test "x$OPENSSL" = "xnone" ; then
1361      key=`autoconf/randpass 37`
1362   else
1363      key=`openssl rand -base64 33`
1364   fi
1365   mon_fd_password=$key
1366fi
1367
1368mon_sd_password=
1369AC_ARG_WITH(mon-sd-password,
1370   AC_HELP_STRING([--with-mon-sd-password=PASSWORD], [specify Storage daemon's password used by the monitor]),
1371   [
1372       if test "x$withval" != "xno" ; then
1373	  mon_sd_password=$withval
1374       fi
1375   ]
1376)
1377
1378if test "x$mon_sd_password" = "x" ; then
1379   if test "x$OPENSSL" = "xnone" ; then
1380      key=`autoconf/randpass 41`
1381   else
1382      key=`openssl rand -base64 33`
1383   fi
1384   mon_sd_password=$key
1385fi
1386
1387AC_SUBST(dir_password)
1388AC_SUBST(fd_password)
1389AC_SUBST(sd_password)
1390AC_SUBST(mon_dir_password)
1391AC_SUBST(mon_fd_password)
1392AC_SUBST(mon_sd_password)
1393
1394dnl
1395dnl Pickup any database name
1396dnl
1397db_name=bacula
1398AC_ARG_WITH(db_name,
1399   AC_HELP_STRING([--with-db-name=DBNAME], [specify database name @<:@default=bacula@:>@]),
1400   [
1401       if test "x$withval" != "x" ; then
1402	  db_name=$withval
1403       fi
1404   ]
1405)
1406AC_SUBST(db_name)
1407
1408db_user=bacula
1409AC_ARG_WITH(db_user,
1410   AC_HELP_STRING([--with-db-user=UNAME], [specify database user @<:@default=bacula@:>@]),
1411   [
1412       if test "x$withval" != "x" ; then
1413	  db_user=$withval
1414       fi
1415   ]
1416)
1417AC_SUBST(db_user)
1418
1419db_password=
1420AC_ARG_WITH(db_password,
1421   AC_HELP_STRING([--with-db-password=PWD], [specify database password @<:@default=*none*@:>@]),
1422   [
1423       if test "x$withval" != "x" ; then
1424	  db_password=$withval
1425       fi
1426   ]
1427)
1428AC_SUBST(db_password)
1429
1430dnl
1431dnl Pickup a database port
1432dnl
1433db_port=" "
1434AC_ARG_WITH(db_port,
1435   AC_HELP_STRING([--with-db-port=DBPORT], [specify a database port @<:@default=null@:>@]),
1436   [
1437       if test "x$withval" != "x" ; then
1438	  db_port=$withval
1439       fi
1440   ]
1441)
1442AC_SUBST(db_port)
1443
1444dnl
1445dnl Pickup MySQL SSL options for database user connection
1446dnl
1447db_ssl_options=
1448AC_ARG_WITH(db_ssl_options,
1449   AC_HELP_STRING([--with-db-ssl-options=DBSSLOPTIONS], [specify SSL options for database user connection @<:@default=null@:>@]),
1450   [
1451       if test "x$withval" != "x" ; then
1452	 db_ssl_options=$withval
1453       fi
1454   ]
1455)
1456AC_SUBST(db_ssl_options)
1457
1458#
1459# Handle users and groups for each daemon
1460#
1461dir_user=
1462AC_ARG_WITH(dir_user,
1463   AC_HELP_STRING([--with-dir-user=USER], [specify user for Director daemon]),
1464   [
1465       if test "x$withval" != "x" ; then
1466	   dir_user=$withval
1467       fi
1468   ]
1469)
1470
1471dir_group=
1472AC_ARG_WITH(dir_group,
1473   AC_HELP_STRING([--with-dir-group=GROUP], [specify group for Director daemon]),
1474   [
1475       if test "x$withval" != "x" ; then
1476	  dir_group=$withval
1477       fi
1478   ]
1479)
1480
1481sd_user=
1482AC_ARG_WITH(sd_user,
1483   AC_HELP_STRING([--with-sd-user=USER], [specify user for Storage daemon]),
1484   [
1485       if test "x$withval" != "x" ; then
1486	  sd_user=$withval
1487       fi
1488   ]
1489)
1490
1491sd_group=
1492AC_ARG_WITH(sd_group,
1493   AC_HELP_STRING([--with-sd-group=GROUP], [specify group for Storage daemon]),
1494   [
1495       if test "x$withval" != "x" ; then
1496	  sd_group=$withval
1497       fi
1498   ]
1499)
1500
1501fd_user=
1502AC_ARG_WITH(fd_user,
1503   AC_HELP_STRING([--with-fd-user=USER], [specify user for File daemon]),
1504   [
1505       if test "x$withval" != "x" ; then
1506	  fd_user=$withval
1507       fi
1508   ]
1509)
1510
1511fd_group=
1512AC_ARG_WITH(fd_group,
1513   AC_HELP_STRING([--with-fd-group=GROUP], [specify group for File daemon]),
1514   [
1515       if test "x$withval" != "x" ; then
1516	  fd_group=$withval
1517       fi
1518   ]
1519)
1520
1521AC_SUBST(dir_user)
1522AC_SUBST(dir_group)
1523AC_SUBST(sd_user)
1524AC_SUBST(sd_group)
1525AC_SUBST(fd_user)
1526AC_SUBST(fd_group)
1527
1528dnl
1529dnl allow setting default executable permissions
1530dnl
1531SBINPERM=0750
1532AC_ARG_WITH(sbin-perm,
1533   AC_HELP_STRING([--with-sbin-perm=MODE], [specify permissions for sbin binaries @<:@default=0750@:>@]),
1534   [
1535       if test "x$withval" != "x" ; then
1536	  SBINPERM=$withval
1537       fi
1538   ]
1539)
1540
1541AC_SUBST(SBINPERM)
1542
1543dnl ------------------------------------------
1544dnl Python Cython detection
1545dnl ------------------------------------------
1546CYTHON=cython
1547CYTHON_LIBS=
1548CYTHON_INC=
1549AC_ARG_WITH(cython,
1550   AC_HELP_STRING([--with-cython=cython], [Cython path]),
1551   [
1552       if test "x$withval" != "xno" ; then
1553       	  CYTHON=$withval
1554       fi
1555   ]
1556)
1557
1558$CYTHON -h > /dev/null 2> /dev/null
1559if test $? = 0; then
1560   if echo $CYTHON | grep cython3 > /dev/null; then
1561      PYTHON=python3
1562      CYTHON="$CYTHON -3"
1563   else
1564      PYTHON=python
1565      CYTHON="$CYTHON -2"
1566   fi
1567   CYTHON_LIBS=`${PYTHON}-config --libs 2>/dev/null`
1568   CYTHON_INC=`${PYTHON}-config --includes 2>/dev/null`
1569else
1570   CYTHON=
1571fi
1572
1573AC_SUBST(CYTHON)
1574AC_SUBST(CYTHON_LIBS)
1575AC_SUBST(CYTHON_INC)
1576
1577dnl -------------------------------------------
1578dnl enable batch attribute DB insert (default on)
1579dnl -------------------------------------------
1580support_batch_insert=yes
1581AC_ARG_ENABLE(batch-insert,
1582   AC_HELP_STRING([--enable-batch-insert], [enable the DB batch insert code @<:@default=yes@:>@]),
1583   [
1584       if test x$enableval = xno; then
1585	  support_batch_insert=no
1586       fi
1587   ]
1588)
1589
1590if test x$support_batch_insert = xyes; then
1591   AC_DEFINE(USE_BATCH_FILE_INSERT, 1, [Set if DB batch insert code enabled])
1592fi
1593
1594dnl ------------------------------------------------
1595dnl Bacula check for various SQL database engines
1596dnl ------------------------------------------------
1597
1598dnl
1599dnl Set uncomment_dbi by default to '#' if DBI is enabled this will get reset
1600dnl
1601uncomment_dbi="#"
1602
1603BA_CHECK_POSTGRESQL_DB
1604
1605BA_CHECK_MYSQL_DB
1606
1607BA_CHECK_SQLITE3_DB
1608
1609dnl -------------------------------------------
1610dnl If no batch insert backend are enable set
1611dnl variable to None
1612dnl -------------------------------------------
1613if test -z "${batch_insert_db_backends}"; then
1614   batch_insert_db_backends="None"
1615fi
1616
1617dnl -------------------------------------------
1618dnl Make sure at least one database backend is found
1619dnl -------------------------------------------
1620if test "x${db_backends}" = "x" ; then
1621   echo " "
1622   echo " "
1623   echo "You have not specified either --enable-client-only or one of the"
1624   echo "supported databases: MySQL, PostgreSQL, or SQLite3."
1625   echo "This is not permitted. Please reconfigure."
1626   echo " "
1627   echo "Aborting the configuration ..."
1628   echo " "
1629   echo " "
1630   exit 1
1631fi
1632
1633dnl -------------------------------------------
1634dnl See how many catalog backends are configured.
1635dnl -------------------------------------------
1636case `echo $DB_BACKENDS | wc -w | sed -e 's/^ *//'` in
1637   1)
1638      DEFAULT_DB_TYPE="${DB_BACKENDS}"
1639      if test x$use_libtool = xno; then
1640	 SHARED_CATALOG_TARGETS=""
1641      else
1642	 SHARED_CATALOG_TARGETS="libbaccats-${DEFAULT_DB_TYPE}.la"
1643      fi
1644      ;;
1645   *)
1646      dnl ------------------------------------------------
1647      dnl Set the default backend to the first backend found
1648      dnl ------------------------------------------------
1649      DEFAULT_DB_TYPE=`echo ${DB_BACKENDS} | cut -d' ' -f1`
1650
1651      dnl ------------------------------------------------
1652      dnl For multiple backend we need libtool support.
1653      dnl ------------------------------------------------
1654      if test x$use_libtool = xno; then
1655	 echo " "
1656	 echo " "
1657	 echo "You have specified two or more of the"
1658	 echo "supported databases: MySQL, PostgreSQL, or SQLite3."
1659	 echo "This is not permitted when not using libtool Please reconfigure."
1660	 echo " "
1661	 echo "Aborting the configuration ..."
1662	 echo " "
1663	 echo " "
1664	 exit 1
1665      fi
1666
1667      SHARED_CATALOG_TARGETS=""
1668      for db_type in ${DB_BACKENDS}
1669      do
1670	 if test -z "${SHARED_CATALOG_TARGETS}"; then
1671	    SHARED_CATALOG_TARGETS="libbaccats-${db_type}.la"
1672	 else
1673	    SHARED_CATALOG_TARGETS="${SHARED_CATALOG_TARGETS} libbaccats-${db_type}.la"
1674	 fi
1675      done
1676      ;;
1677esac
1678
1679dnl -------------------------------------------
1680dnl Unset DB_LIBS when using libtool as we link the
1681dnl shared library using the right database lib no need to
1682dnl set DB_LIBS which is only used for non shared versions
1683dnl of the backends.
1684dnl -------------------------------------------
1685if test x$use_libtool = xyes; then
1686   DB_LIBS=""
1687fi
1688
1689AC_SUBST(uncomment_dbi)
1690AC_SUBST(DB_BACKENDS)
1691AC_SUBST(DB_LIBS)
1692AC_SUBST(DEFAULT_DB_TYPE)
1693AC_SUBST(SHARED_CATALOG_TARGETS)
1694
1695AC_DEFINE(PROTOTYPES)
1696
1697support_bee=no
1698extra_prefix=org
1699nb=`ls src/*/bee_* 2>/dev/null| wc -l`
1700if test $nb -gt 1; then
1701   support_bee=yes
1702   extra_prefix=bee
1703fi
1704
1705AC_ARG_ENABLE(bee,
1706   AC_HELP_STRING([--disable-bee], [disable BEE support @<:@default=auto@:>@]),
1707   [
1708       if test x$enableval = xyes; then
1709         support_bee=yes
1710          extra_prefix=bee
1711       elif test x$enableval = xno; then
1712         support_bee=no
1713          extra_prefix=org
1714       fi
1715   ]
1716)
1717
1718if test $support_bee = no
1719then
1720    AC_DEFINE(COMMUNITY, 1, [Set if COMMUNITY exists])
1721fi
1722
1723dnl BEE source files
1724EXTRA_CATS_SRCS=`cd src/cats ; ls ${extra_prefix}_*.c      2> /dev/null | xargs echo`
1725EXTRA_FILED_SRCS=`cd src/filed ; ls ${extra_prefix}_*.c    2> /dev/null | xargs echo`
1726EXTRA_LIB_SRCS=`cd src/lib ; ls ${extra_prefix}_*.c        2> /dev/null | xargs echo`
1727EXTRA_DIRD_SRCS=`cd src/dird ; ls ${extra_prefix}_*.c      2> /dev/null | xargs echo`
1728EXTRA_STORED_SRCS=`cd src/stored ; ls ${extra_prefix}_stored_*.c  2> /dev/null | xargs echo`
1729EXTRA_BLS_SRCS=`cd src/stored ; ls ${extra_prefix}_bls_*.c  2> /dev/null | xargs echo`
1730EXTRA_LIBSD_SRCS=`cd src/stored ; ls ${extra_prefix}_lib*.c  2> /dev/null | xargs echo`
1731EXTRA_FINDLIB_SRCS=`cd src/findlib ; ls ${extra_prefix}_*.c  2> /dev/null | xargs echo`
1732
1733AC_SUBST(EXTRA_CATS_SRCS)
1734AC_SUBST(EXTRA_FILED_SRCS)
1735AC_SUBST(EXTRA_LIB_SRCS)
1736AC_SUBST(EXTRA_DIRD_SRCS)
1737AC_SUBST(EXTRA_STORED_SRCS)
1738AC_SUBST(EXTRA_BLS_SRCS)
1739AC_SUBST(EXTRA_FINDLIB_SRCS)
1740AC_SUBST(EXTRA_LIBSD_SRCS)
1741
1742dnl --------------------------------------------------------------------------
1743dnl Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
1744dnl
1745if test -z "$CFLAGS" -o "$CFLAGS" = "-g -O2"; then
1746   if test -z "$CCOPTS"; then
1747      CCOPTS='-g -O2 -Wall'
1748   fi
1749   CFLAGS="$CCOPTS"
1750fi
1751
1752dnl A few others
1753AC_EXEEXT
1754
1755dnl See if we can use 64 bit file addresses
1756largefile_support="no"
1757AC_BAC_LARGEFILE
1758
1759AC_PATH_XTRA
1760
1761dnl --------------------------------------------------------------------------
1762dnl CHECKING FOR HEADER FILES
1763dnl --------------------------------------------------------------------------
1764AC_CHECK_HEADERS( \
1765   assert.h \
1766   fcntl.h \
1767   grp.h \
1768   pwd.h \
1769   libc.h \
1770   limits.h \
1771   stdarg.h \
1772   stdlib.h \
1773   stdint.h \
1774   inttypes.h \
1775   string.h \
1776   strings.h \
1777   termios.h \
1778   termcap.h \
1779   term.h \
1780   unistd.h \
1781   sys/bitypes.h \
1782   sys/byteorder.h \
1783   sys/ioctl.h \
1784   sys/select.h \
1785   sys/socket.h \
1786   sys/sockio.h \
1787   sys/stat.h \
1788   sys/time.h \
1789   sys/types.h \
1790   arpa/nameser.h \
1791   mtio.h \
1792   sys/mtio.h \
1793   sys/tape.h \
1794   regex.h \
1795   attr/attributes.h \
1796   attr/xattr.h \
1797)
1798AC_HEADER_STDC
1799AC_HEADER_MAJOR
1800AC_HEADER_DIRENT
1801AC_HEADER_STAT
1802AC_HEADER_SYS_WAIT
1803AC_HEADER_TIME
1804AC_STRUCT_ST_BLKSIZE
1805AC_STRUCT_ST_BLOCKS
1806AC_STRUCT_TIMEZONE
1807
1808dnl --------------------------------------------------------------------------
1809dnl Check for utime.h structure
1810dnl --------------------------------------------------------------------------
1811AC_CACHE_CHECK(for utime.h, ba_cv_header_utime_h,
1812   [
1813       AC_TRY_COMPILE(
1814	  [
1815	      #include <sys/types.h>
1816	      #include <utime.h>
1817	  ], [
1818	      struct utimbuf foo
1819	  ], [
1820	      ba_cv_header_utime_h=yes
1821	  ], [
1822	      ba_cv_header_utime_h=no
1823	  ]
1824       )
1825   ]
1826)
1827test $ba_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H, 1, [Set if utime.h exists])
1828
1829dnl --------------------------------------------------------------------------
1830dnl Check for socklen_t
1831dnl --------------------------------------------------------------------------
1832AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
1833   [
1834       AC_TRY_COMPILE(
1835	  [
1836	      #include <sys/types.h>
1837	      #include <sys/socket.h>
1838	  ], [
1839	      socklen_t x
1840	  ], [
1841	     ba_cv_header_socklen_t=yes
1842	  ], [
1843	     ba_cv_header_socklen_t=no
1844	  ]
1845       )
1846   ]
1847)
1848test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T, 1, [Set if socklen_t exists])
1849
1850dnl --------------------------------------------------------------------------
1851dnl Check for ioctl request type
1852dnl --------------------------------------------------------------------------
1853AC_LANG(C++)
1854AC_CACHE_CHECK(for ioctl_req_t, ba_cv_header_ioctl_req_t,
1855   [
1856       AC_TRY_COMPILE(
1857	  [
1858	      #include <unistd.h>
1859	      #include <sys/types.h>
1860	      #include <sys/ioctl.h>
1861	  ], [
1862	      int (*d_ioctl)(int fd, unsigned long int request, ...);
1863	      d_ioctl = ::ioctl;
1864	  ], [
1865	     ba_cv_header_ioctl_req_t=yes
1866	  ], [
1867	     ba_cv_header_ioctl_req_t=no
1868	  ]
1869       )
1870   ]
1871)
1872test $ba_cv_header_ioctl_req_t = yes && AC_DEFINE(HAVE_IOCTL_ULINT_REQUEST, 1, [Set if ioctl request is unsigned long int])
1873
1874dnl Note: it is more correct to use AC_LANG(C++) but some of the older
1875dnl   *BSD systems still use old style C prototypes, which are wrong with
1876dnl   compiled with a C++ compiler.
1877AC_LANG(C)
1878
1879dnl --------------------------------------------------------------------------
1880dnl Check for typeof()
1881dnl --------------------------------------------------------------------------
1882AC_LANG_PUSH(C++)
1883AC_CACHE_CHECK(for typeof, ba_cv_have_typeof,
1884   [
1885       AC_TRY_RUN(
1886	  [
1887	      main(){char *a = 0; a = (typeof a)a;}
1888	  ], [
1889	      ba_cv_have_typeof=yes
1890	  ], [
1891	      ba_cv_have_typeof=no
1892	  ], [
1893	      ba_cv_have_typeof=no
1894	  ]
1895       )
1896   ]
1897)
1898test $ba_cv_have_typeof = yes && AC_DEFINE([HAVE_TYPEOF], 1, [Defind to 1 if compiler has typeof])
1899AC_LANG_POP(C++)
1900
1901AC_C_CONST
1902
1903AC_C_BIGENDIAN([AC_DEFINE([HAVE_BIG_ENDIAN], [1], [Big Endian])], [AC_DEFINE([HAVE_LITTLE_ENDIAN], [1], [Little Endian])])
1904
1905dnl --------------------------------------------------------------------------
1906dnl CHECKING FOR FILESYSTEM TYPE
1907dnl --------------------------------------------------------------------------
1908AC_MSG_CHECKING(how to get filesystem type)
1909fstype=no
1910# The order of these tests is important.
1911AC_TRY_CPP(
1912   [
1913       #include <sys/statvfs.h>
1914       #include <sys/fstyp.h>
1915   ],
1916   AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4
1917)
1918if test $fstype = no; then
1919   AC_TRY_CPP(
1920      [
1921	  #include <sys/statfs.h>
1922	  #include <sys/fstyp.h>
1923      ],
1924      AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3
1925   )
1926fi
1927if test $fstype = no; then
1928   AC_TRY_CPP(
1929      [
1930	  #include <sys/statfs.h>
1931	  #include <sys/vmount.h>
1932      ],
1933      AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX
1934   )
1935fi
1936if test $fstype = no; then
1937   AC_TRY_CPP(
1938      [
1939	  #include <mntent.h>
1940      ],
1941      AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD
1942   )
1943fi
1944if test $fstype = no; then
1945   AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
1946fi
1947if test $fstype = no; then
1948   AC_TRY_CPP(
1949      [
1950	  #include <sys/mount.h>
1951	  #include <sys/fs_types.h>
1952      ],
1953      AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix
1954   )
1955fi
1956AC_MSG_RESULT($fstype)
1957
1958AC_CHECK_HEADER(sys/statvfs.h, [ AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Defines if your system have the sys/statvfs.h header file])] , )
1959
1960AC_CHECK_DECLS([O_CLOEXEC],,[AC_DEFINE([O_CLOEXEC],[0], [Defined to 0 if not provided])],
1961[[
1962#ifdef HAVE_FCNTL_H
1963# include <fcntl.h>
1964#endif
1965]])
1966
1967AC_CHECK_DECLS([FD_CLOEXEC],,[AC_DEFINE([FD_CLOEXEC],[0], [Defined to 0 if not provided])],
1968[[
1969#ifdef HAVE_FCNTL_H
1970# include <fcntl.h>
1971#endif
1972]])
1973
1974AC_CHECK_DECLS([SOCK_CLOEXEC],,[AC_DEFINE([SOCK_CLOEXEC],[0],[Defined to 0 if not provided])],
1975[[
1976#ifdef HAVE_SYS_SOCKET_H
1977# include <sys/socket.h>
1978#endif
1979]])
1980
1981AC_CACHE_CHECK(for close on exec modifier for fopen(), ac_cv_feature_stream_cloexec_flag,
1982   [if test $ac_cv_have_decl_O_CLOEXEC = yes ; then
1983	if test $ac_cv_have_decl_SOCK_CLOEXEC = yes ; then
1984	    ac_cv_feature_stream_cloexec_flag="e"
1985	fi
1986    fi])
1987
1988if test "x$ac_cv_feature_stream_cloexec_flag" = "xe" ; then
1989   AC_DEFINE(HAVE_STREAM_CLOEXEC,[0],[Defined to 0 if not provided])
1990fi
1991
1992AC_DEFINE_UNQUOTED([STREAM_CLOEXEC], "$ac_cv_feature_stream_cloexec_flag", [fopen() modifier for setting close on exec flag])
1993
1994AC_CHECK_FUNC(accept4, [AC_DEFINE(HAVE_ACCEPT4, 1, [Define to 1 if you have the 'accept4' function.])])
1995
1996CLOUD_DRIVERS=
1997AC_SUBST(CLOUD_DRIVERS)
1998
1999CLOUD_INSTALL_TARGETS=
2000AC_SUBST(CLOUD_INSTALL_TARGETS)
2001
2002dnl ---------------------------------------------------
2003dnl Check for S3 support/directory (default on)
2004dnl ---------------------------------------------------
2005dnl this allows you to turn it completely off
2006
2007AC_ARG_ENABLE(s3,
2008   AC_HELP_STRING([--disable-s3], [disable S3 support @<:@default=yes@:>@]),
2009   [
2010       if test x$enableval = xno; then
2011	  support_s3=no
2012       fi
2013   ]
2014)
2015
2016S3_INC=
2017S3_LIBS=
2018S3_LDFLAGS=
2019have_libs3=no
2020
2021if test x$support_s3 = xyes; then
2022   AC_ARG_WITH(s3,
2023      AC_HELP_STRING([--with-s3@<:@=DIR@:>@], [specify s3 library directory]),
2024      [
2025	  case "$with_s3" in
2026	  no)
2027	     :
2028	     ;;
2029	  yes|*)
2030	     if test -f ${with_s3}/include/libs3.h; then
2031		S3_INC="-I${with_s3}/include"
2032		S3_LDFLAGS="-L${with_s3}/lib"
2033		with_s3="${with_s3}/include"
2034	     else
2035		with_s3="/usr/include"
2036	     fi
2037
2038	     AC_CHECK_HEADER(${with_s3}/libs3.h,
2039		[
2040		    AC_DEFINE(HAVE_LIBS3, 1, [Define to 1 if you have libs3])
2041		    S3_LIBS="${S3_LDFLAGS} -ls3"
2042		    have_libs3="yes"
2043                    CLOUD_DRIVERS="${CLOUD_DRIVERS} s3-driver"
2044                    CLOUD_INSTALL_TARGETS="${CLOUD_INSTALL_TARGETS} install-s3-cloud"
2045		], [
2046		    echo " "
2047		    echo "libs3.h not found. s3 turned off ..."
2048		    echo " "
2049		]
2050	     )
2051	     ;;
2052	  esac
2053      ],[
2054	 AC_CHECK_HEADER(libs3.h,
2055	 [
2056	    AC_CHECK_LIB(s3, S3_initialize,
2057	    [
2058	      S3_LIBS="-ls3"
2059	      AC_DEFINE(HAVE_LIBS3,1,[Define to 1 if you have libs3])
2060	      have_libs3=yes
2061              CLOUD_DRIVERS="${CLOUD_DRIVERS} s3-driver"
2062              CLOUD_INSTALL_TARGETS="${CLOUD_INSTALL_TARGETS} install-s3-cloud"
2063	   ])
2064	 ])
2065      ])
2066fi
2067
2068AC_SUBST(S3_INC)
2069AC_SUBST(S3_LIBS)
2070
2071AC_LANG_PUSH(C++)
2072AC_CHECK_FUNCS(backtrace)
2073AC_LANG_POP(C++)
2074
2075dnl --------------------------------------------------------------------------
2076dnl CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
2077dnl --------------------------------------------------------------------------
2078AC_TYPE_SIGNAL
2079SIGNAL_CHECK
2080AC_TYPE_MODE_T
2081AC_TYPE_UID_T
2082AC_TYPE_SIZE_T
2083AC_TYPE_PID_T
2084AC_TYPE_OFF_T
2085AC_TYPE_INTPTR_T
2086AC_TYPE_UINTPTR_T
2087AC_CHECK_TYPE(ino_t, unsigned long)
2088AC_CHECK_TYPE(dev_t, unsigned long)
2089AC_CHECK_TYPE(daddr_t, long)
2090AC_CHECK_TYPE(major_t, int)
2091AC_CHECK_TYPE(minor_t, int)
2092AC_CHECK_TYPE(ssize_t, int)
2093AC_STRUCT_ST_BLOCKS
2094AC_STRUCT_ST_RDEV
2095AC_STRUCT_TM
2096AC_C_CONST
2097AC_C_RESTRICT
2098
2099AC_CHECK_SIZEOF(char, 1)
2100AC_CHECK_SIZEOF(short int, 2)
2101AC_CHECK_SIZEOF(int, 4)
2102AC_CHECK_SIZEOF(long int, 4)
2103AC_CHECK_SIZEOF(long long int, 8)
2104AC_CHECK_SIZEOF(int *, 4)
2105
2106dnl Check for sys/types.h types
2107AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int,
2108   [
2109       AC_TRY_COMPILE(
2110	  [
2111	      #include <sys/types.h>
2112	  ], [
2113	      u_int a; a = 1;
2114	  ], [
2115	      ac_cv_have_u_int="yes"
2116	  ], [
2117	      ac_cv_have_u_int="no"
2118	  ]
2119       )
2120   ]
2121)
2122if test "x$ac_cv_have_u_int" = "xyes" ; then
2123   AC_DEFINE(HAVE_U_INT)
2124   have_u_int=1
2125fi
2126
2127AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t,
2128   [
2129       AC_TRY_COMPILE(
2130	  [
2131	      #include <sys/types.h>
2132	  ], [
2133	      intmax_t a; a = 1;
2134	  ], [
2135	      ac_cv_have_intmax_t="yes"
2136	  ], [
2137	      AC_TRY_COMPILE(
2138		 [
2139		     #include <stdint.h>
2140		 ], [
2141		     intmax_t a; a = 1;
2142		 ], [
2143		     ac_cv_have_intmax_t="yes"
2144		 ], [
2145		     ac_cv_have_intmax_t="no"
2146		 ]
2147	      )
2148	  ]
2149       )
2150   ]
2151)
2152if test "x$ac_cv_have_intmax_t" = "xyes" ; then
2153   AC_DEFINE(HAVE_INTMAX_T)
2154   have_intmax_t=1
2155fi
2156
2157AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t,
2158   [
2159       AC_TRY_COMPILE(
2160	  [
2161	      #include <sys/types.h>
2162	  ], [
2163	      u_intmax_t a; a = 1;
2164	  ], [
2165	      ac_cv_have_u_intmax_t="yes"
2166	  ], [
2167	      AC_TRY_COMPILE(
2168		 [
2169		     #include <stdint.h>
2170		 ], [
2171		    u_intmax_t a; a = 1;
2172		 ], [
2173		    ac_cv_have_u_intmax_t="yes"
2174		 ], [
2175		    ac_cv_have_u_intmax_t="no"
2176		 ]
2177	      )
2178	  ]
2179       )
2180   ]
2181)
2182if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
2183   AC_DEFINE(HAVE_U_INTMAX_T)
2184   have_u_intmax_t=1
2185fi
2186
2187AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t,
2188   [
2189       AC_TRY_COMPILE(
2190	  [
2191	      #include <sys/types.h>
2192	  ], [
2193	      int8_t a; int16_t b; int32_t c; a = b = c = 1;
2194	  ], [
2195	      ac_cv_have_intxx_t="yes"
2196	  ], [
2197	      ac_cv_have_intxx_t="no"
2198	  ]
2199       )
2200   ]
2201)
2202if test "x$ac_cv_have_intxx_t" = "xyes" ; then
2203   AC_DEFINE(HAVE_INTXX_T)
2204   have_intxx_t=1
2205fi
2206
2207AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t,
2208   [
2209       AC_TRY_COMPILE(
2210	  [
2211	      #include <sys/types.h>
2212	  ], [
2213	      int64_t a; a = 1;
2214	  ], [
2215	      ac_cv_have_int64_t="yes"
2216	  ], [
2217	      ac_cv_have_int64_t="no"
2218	  ]
2219       )
2220   ]
2221)
2222if test "x$ac_cv_have_int64_t" = "xyes" ; then
2223   AC_DEFINE(HAVE_INT64_T)
2224   have_int64_t=1
2225fi
2226
2227AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t,
2228   [
2229       AC_TRY_COMPILE(
2230	  [
2231	      #include <sys/types.h>
2232	  ], [
2233	      u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;
2234	  ], [
2235	     ac_cv_have_u_intxx_t="yes"
2236	  ], [
2237	     ac_cv_have_u_intxx_t="no"
2238	  ]
2239       )
2240   ]
2241)
2242if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
2243   AC_DEFINE(HAVE_U_INTXX_T)
2244   have_u_intxx_t=1
2245fi
2246
2247AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t,
2248   [
2249       AC_TRY_COMPILE(
2250	  [
2251	      #include <sys/types.h>
2252	  ], [
2253	      u_int64_t a; a = 1;
2254	  ], [
2255	     ac_cv_have_u_int64_t="yes"
2256	  ], [
2257	     ac_cv_have_u_int64_t="no"
2258	  ]
2259       )
2260   ]
2261)
2262if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
2263   AC_DEFINE(HAVE_U_INT64_T)
2264   have_u_int64_t=1
2265fi
2266
2267if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
2268    test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2269then
2270   AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
2271   AC_TRY_COMPILE(
2272      [
2273	  #include <sys/bitypes.h>
2274      ], [
2275	  int8_t a; int16_t b; int32_t c;
2276	  u_int8_t e; u_int16_t f; u_int32_t g;
2277	  a = b = c = e = f = g = 1;
2278      ], [
2279	  AC_DEFINE(HAVE_U_INTXX_T)
2280	  AC_DEFINE(HAVE_INTXX_T)
2281	  AC_DEFINE(HAVE_SYS_BITYPES_H)
2282	  AC_MSG_RESULT(yes)
2283      ], [
2284	  AC_MSG_RESULT(no)
2285      ]
2286   )
2287fi
2288
2289if test -z "$have_u_intxx_t" ; then
2290   AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t,
2291      [
2292	  AC_TRY_COMPILE(
2293	     [
2294		 #include <sys/types.h>
2295	     ], [
2296		 uint8_t a; uint16_t b;
2297		 uint32_t c; a = b = c = 1;
2298	     ], [
2299		ac_cv_have_uintxx_t="yes"
2300	     ], [
2301		ac_cv_have_uintxx_t="no"
2302	     ]
2303	  )
2304      ]
2305   )
2306   if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
2307      AC_DEFINE(HAVE_UINTXX_T)
2308   fi
2309fi
2310
2311if (test -z "$have_u_int64_t" || test -z "$have_int64_t" && \
2312    test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2313then
2314   AC_MSG_CHECKING([for int64_t and u_int64_t types in sys/bitypes.h])
2315   AC_TRY_COMPILE(
2316      [
2317	  #include <sys/bitypes.h>
2318      ], [
2319	  int64_t a; u_int64_t b;
2320	  a = b = 1;
2321      ], [
2322	  AC_DEFINE(HAVE_U_INT64_T)
2323	  AC_DEFINE(HAVE_INT64_T)
2324	  AC_MSG_RESULT(yes)
2325      ], [
2326	  AC_MSG_RESULT(no)
2327      ]
2328   )
2329fi
2330
2331if (test -z "$have_uintxx_t" && \
2332    test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2333then
2334   AC_MSG_CHECKING([for uintXX_t types in sys/bitypes.h])
2335   AC_TRY_COMPILE(
2336      [
2337	  #include <sys/bitypes.h>
2338      ], [
2339	  uint8_t a; uint16_t b;
2340	  uint32_t c; a = b = c = 1;
2341      ], [
2342	  AC_DEFINE(HAVE_UINTXX_T)
2343	  AC_MSG_RESULT(yes)
2344      ], [
2345	  AC_MSG_RESULT(no)
2346      ]
2347   )
2348fi
2349
2350dnl --------------------------------------------------------------------------
2351dnl CHECKING FOR REQUIRED LIBRARY FUNCTIONS
2352dnl --------------------------------------------------------------------------
2353AC_CHECK_FUNCS( \
2354   fork \
2355   getcwd \
2356   gethostname \
2357   getpid \
2358   gettimeofday \
2359   setpgid \
2360   setpgrp \
2361   setsid \
2362   signal \
2363   strerror \
2364   strncmp \
2365   strncpy \
2366   vfprintf \
2367   ,,
2368   [echo 'configure: cannot find needed function.'; exit 1]
2369)
2370
2371AC_CHECK_DECL(
2372    F_CLOSEM,
2373    AC_DEFINE(HAVE_FCNTL_F_CLOSEM, 1, [Set if you have 'F_CLOSEM' fcntl flag]),
2374    ,
2375    [#include <fcntl.h>]
2376)
2377
2378AC_CHECK_DECL(
2379    F_SETLK,
2380    AC_DEFINE(HAVE_FCNTL_LOCK, 1, [Set if fcntl supports file locking]),
2381    ,
2382    [#include <fcntl.h>]
2383)
2384
2385AC_CHECK_FUNC(closefrom, [AC_DEFINE(HAVE_CLOSEFROM, 1, [Define to 1 if you have the 'closefrom' function.])])
2386AC_CHECK_FUNCS(getpagesize, [AC_DEFINE(HAVE_GETPAGESIZE, 1, [Set if have getpagesize])])
2387AC_CHECK_FUNCS(malloc_trim, [AC_DEFINE(HAVE_MALLOC_TRIM, 1, [Set if have malloc_trim])])
2388
2389AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
2390AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)])
2391AC_CHECK_FUNCS(posix_fadvise)
2392AC_CHECK_FUNCS(posix_fallocate)
2393AC_CHECK_FUNCS(fdatasync)
2394AC_CHECK_FUNCS(realpath)
2395AC_CHECK_FUNCS(getrlimit)
2396
2397AC_CHECK_FUNCS(chflags)
2398
2399AC_TRY_LINK([
2400int f(int b) {
2401  return __builtin_bswap32(b);
2402}
2403],[int a = f(10);], [AC_DEFINE([HAVE_BSWAP32], 1, [Define to 1 if you have the '__builtin_bswap32' function ])])
2404
2405AC_CHECK_FUNCS(snprintf vsnprintf gethostid fseeko)
2406
2407AC_CACHE_CHECK(for va_copy, ba_cv_va_copy,
2408   [
2409       AC_TRY_LINK(
2410	  [
2411	      #include <stdarg.h>
2412	      void use_va_copy(va_list args){va_list args2; va_copy(args2,args); va_end(args2);}
2413	      void call_use_va_copy(int junk,...){va_list args; va_start(args,junk); use_va_copy(args); va_end(args);}
2414	  ], [
2415	      call_use_va_copy(1,2,3)
2416	  ], [
2417	      ba_cv_va_copy=yes
2418	  ], [
2419	      ba_cv_va_copy=no
2420	  ]
2421       )
2422   ]
2423)
2424test $ba_cv_va_copy = yes && AC_DEFINE(HAVE_VA_COPY, 1, [Set if va_copy exists])
2425
2426dnl --------------------------------------------------------------------------
2427dnl CHECKING FOR THREAD SAFE FUNCTIONS
2428dnl --------------------------------------------------------------------------
2429AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
2430
2431# If resolver functions are not in libc check for -lnsl or -lresolv.
2432AC_CHECK_FUNC(gethostbyname_r,
2433    AC_MSG_RESULT(using libc's resolver),
2434    AC_CHECK_LIB(nsl,gethostbyname_r)
2435    AC_CHECK_LIB(resolv,gethostbyname_r))
2436
2437AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
2438AC_CHECK_FUNCS(inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
2439AC_CHECK_FUNCS(gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2)])
2440AC_CHECK_FUNCS(getnameinfo, [AC_DEFINE(HAVE_GETNAMEINFO)])
2441
2442
2443dnl ----------------------------
2444dnl check sa_len of sockaddr
2445dnl ----------------------------
2446AC_CACHE_CHECK(for struct sockaddr has a sa_len field, ac_cv_struct_sockaddr_sa_len,
2447   [
2448       AC_TRY_COMPILE(
2449	  [
2450	      #include <sys/socket.h>
2451	  ], [
2452	      struct sockaddr s; s.sa_len;
2453	  ], [
2454	     ac_cv_struct_sockaddr_sa_len=yes
2455	  ], [ac_cv_struct_sockaddr_sa_len=no
2456	  ]
2457       )
2458   ]
2459)
2460
2461if test $ac_cv_struct_sockaddr_sa_len = yes; then
2462  AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
2463fi
2464
2465dnl
2466dnl check for working getaddrinfo()
2467dnl
2468dnl Note that if the system doesn't have gai_strerror(), we
2469dnl can't use getaddrinfo() because we can't get strings
2470dnl describing the error codes.
2471dnl
2472AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,
2473   [
2474       AC_TRY_RUN(
2475	  [
2476	      #include <netdb.h>
2477	      #include <string.h>
2478	      #include <sys/types.h>
2479	      #include <sys/socket.h>
2480
2481	      void main(void) {
2482		  struct addrinfo hints, *ai;
2483		  int error;
2484
2485		  memset(&hints, 0, sizeof(hints));
2486		  hints.ai_family = AF_UNSPEC;
2487		  hints.ai_socktype = SOCK_STREAM;
2488		  error = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
2489		  if (error) {
2490		      exit(1);
2491		  }
2492		  if (ai->ai_addr->sa_family != AF_INET) {
2493		      exit(1);
2494		  }
2495		  exit(0);
2496	      }
2497	  ],[
2498	      ac_cv_working_getaddrinfo="yes"
2499	  ],[
2500	      ac_cv_working_getaddrinfo="no"
2501	  ],[
2502	      ac_cv_working_getaddrinfo="yes"
2503	  ]
2504       )
2505   ]
2506)
2507AC_CHECK_FUNC(gai_strerror, [AC_DEFINE(HAVE_GAI_STRERROR, 1, [Define to 1 if you have the 'gai_strerror' function.])])
2508
2509if test "$ac_cv_working_getaddrinfo" = "yes"; then
2510  if test "$ac_cv_func_gai_strerror" != "yes"; then
2511    ac_cv_working_getaddrinfo="no"
2512  else
2513    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define to 1 if getaddrinfo exists and works])
2514  fi
2515fi
2516
2517AC_FUNC_STRFTIME
2518AC_FUNC_VPRINTF
2519AC_FUNC_ALLOCA
2520AC_FUNC_GETMNTENT
2521AC_CHECK_FUNCS(getmntinfo, [AC_DEFINE(HAVE_GETMNTINFO)])
2522AC_FUNC_CLOSEDIR_VOID
2523AC_FUNC_SETPGRP 	    dnl check for BSD setpgrp.
2524# AC_FUNC_FNMATCH    dnl use local version
2525
2526AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"])
2527
2528AC_CHECK_LIB(sun, getpwnam)
2529
2530AC_CHECK_HEADERS(zlib.h)
2531AC_CHECK_LIB(z, deflate, [ZLIBS="-lz"])
2532have_zlib=no
2533if test x$ZLIBS = x-lz; then
2534   AC_DEFINE(HAVE_LIBZ)
2535   have_zlib=yes
2536fi
2537AC_SUBST(ZLIBS)
2538
2539dnl
2540dnl Check if we have AFS on this system
2541dnl
2542AFS_CFLAGS=""
2543AFS_LIBS=""
2544support_afs=auto
2545AC_ARG_ENABLE(afs,
2546   AC_HELP_STRING([--disable-afs], [disable afs support @<:@default=auto@:>@]),
2547   [
2548       if test x$enableval = xyes; then
2549	  support_afs=yes
2550       elif test x$enableval = xno; then
2551	  support_afs=no
2552       fi
2553   ]
2554)
2555
2556have_afs=no
2557if test x$support_afs = xyes -o x$support_afs = xauto; then
2558   AC_ARG_WITH(afsdir,
2559      AC_HELP_STRING([--with-afsdir@<:@=DIR@:>@], [Directory holding AFS includes/libs]),
2560      with_afsdir=$withval
2561   )
2562
2563   dnl
2564   dnl Search in standard places, or --with-afsdir not specified
2565   dnl
2566   if test x$with_afsdir = x; then
2567      for root in /usr /usr/local; do
2568	 if test -d ${root}/include/afs/ ; then
2569	    with_afsdir=${root}
2570	    break
2571	 fi
2572	 if test -d ${root}/include/openafs/afs/ ; then
2573	    with_afsdir=${root}
2574	    break
2575	 fi
2576      done
2577   fi
2578
2579   if test -d ${with_afsdir}/include/afs/ ; then
2580      AFS_CFLAGS="-I${with_afsdir}/include"
2581   else
2582      if test -d ${with_afsdir}/include/openafs/afs/ ; then
2583	 AFS_CFLAGS="-I${with_afsdir}/include/openafs"
2584      fi
2585   fi
2586
2587   saved_CFLAGS="${CFLAGS}"
2588   saved_CPPFLAGS="${CPPFLAGS}"
2589   CFLAGS="${AFS_CFLAGS} ${saved_CFLAGS}"
2590   CPPFLAGS="${AFS_CFLAGS} ${saved_CPPFLAGS}"
2591
2592   AC_CHECK_HEADERS(afs/afsint.h)
2593   AC_TRY_CPP(
2594       [
2595	  #include <afs/afsint.h>
2596	  #include <afs/venus.h>
2597       ],
2598       AC_DEFINE(HAVE_AFS_VENUS_H,1,[Define to 1 if you have the <afs/venus.h> header file.])
2599   )
2600
2601   CFLAGS="${saved_CFLAGS}"
2602   CPPFLAGS="${saved_CPPFLAGS}"
2603
2604   dnl
2605   dnl See if we can find a libsys with the pioctl symbol in there
2606   dnl
2607   AC_MSG_CHECKING(for pioctl in AFS libsys)
2608   for dir in ${with_afsdir}/lib \
2609	      ${with_afsdir}/lib/afs \
2610	      ${with_afsdir}/lib/openafs \
2611	      ${with_afsdir}/lib64 \
2612	      ${with_afsdir}/lib64/afs \
2613	      ${with_afsdir}/lib64/openafs
2614   do
2615      for arch_type in .a .so
2616      do
2617	 A=`test -f ${dir}/libsys${arch_type} && nm ${dir}/libsys${arch_type} 2>/dev/null | grep pioctl`
2618	 pkg=$?
2619	 if test $pkg = 0; then
2620	    have_afs=yes
2621	    AFS_LIBS="-L${dir} -lsys -lrx -llwp ${dir}/util${arch_type}"
2622	    break
2623	 fi
2624      done
2625   done
2626
2627   if test $have_afs = yes; then
2628      AC_MSG_RESULT(yes)
2629   else
2630      AC_MSG_RESULT(no)
2631   fi
2632
2633   if test x$support_afs = xyes -a $have_afs != yes; then
2634      AC_MSG_ERROR([afs support explicitly enabled but no supported afs implementation found,
2635  please either load the afs libraries or rerun configure without --enable-afs])
2636   else
2637      if test $have_afs = yes; then
2638	 AC_DEFINE(HAVE_AFS,1,[Define to 1 if your system has AFS support])
2639	 AC_DEFINE(HAVE_AFS_ACL,1,[Andrew FileSystem ACL support])
2640      fi
2641   fi
2642fi
2643AC_SUBST(AFS_CFLAGS)
2644AC_SUBST(AFS_LIBS)
2645
2646AC_SUBST(ANDROID_QT_QMAKE)
2647AC_SUBST(ANDROID_QT_APK_MAKE)
2648AC_SUBST(ANDROID_QT_BUILD_LIBS)
2649AC_SUBST(ANDROID_API)
2650
2651dnl ---------------------------------------------------
2652dnl Check for lzo support/directory (default on)
2653dnl ---------------------------------------------------
2654dnl this allows you to turn it completely off
2655
2656AC_ARG_ENABLE(lzo,
2657   AC_HELP_STRING([--disable-lzo], [disable lzo support @<:@default=yes@:>@]),
2658   [
2659       if test x$enableval = xno; then
2660	  support_lzo=no
2661       fi
2662   ]
2663)
2664
2665LZO_INC=
2666LZO_LIBS=
2667LZO_LDFLAGS=
2668
2669have_lzo="no"
2670if test x$support_lzo = xyes; then
2671   AC_ARG_WITH(lzo,
2672      AC_HELP_STRING([--with-lzo@<:@=DIR@:>@], [specify lzo library directory]),
2673      [
2674	  case "$with_lzo" in
2675	  no)
2676	     :
2677	     ;;
2678	  yes|*)
2679	     if test -f ${with_lzo}/include/lzo/lzoconf.h; then
2680		LZO_INC="-I${with_lzo}/include"
2681		LZO_LDFLAGS="-L${with_lzo}/lib"
2682		with_lzo="${with_lzo}/include"
2683	     else
2684		with_lzo="/usr/include"
2685	     fi
2686
2687	     AC_CHECK_HEADER(${with_lzo}/lzo/lzoconf.h,
2688		[
2689		    AC_DEFINE(HAVE_LZO, 1, [Define to 1 if you have LZO compression])
2690		    LZO_LIBS="${LZO_LDFLAGS} -llzo2"
2691		    have_lzo="yes"
2692		], [
2693		    echo " "
2694		    echo "lzoconf.h not found. lzo turned off ..."
2695		    echo " "
2696		]
2697	     )
2698	     ;;
2699	  esac
2700      ],[
2701	 AC_CHECK_HEADER(lzo/lzoconf.h,
2702	 [
2703	    AC_CHECK_HEADER(lzo/lzo1x.h,
2704	    [
2705	       AC_CHECK_LIB(lzo2, lzo1x_1_compress,
2706	       [
2707		 LZO_LIBS="-llzo2"
2708		 AC_DEFINE(HAVE_LZO,1,[Define to 1 if you have LZO compression])
2709		 have_lzo=yes
2710	       ])
2711	    ])
2712	 ])
2713      ])
2714fi
2715
2716AC_SUBST(LZO_INC)
2717AC_SUBST(LZO_LIBS)
2718
2719dnl ---------------------------------------------------
2720dnl Check for ACSLS support and libraries
2721dnl ---------------------------------------------------
2722acsls_support=yes
2723have_acsls="no"
2724AC_ARG_ENABLE(acsls,
2725   AC_HELP_STRING([--disable-acsls], [disable ACSLS support @<:@default=yes@:>@]),
2726   [
2727      if test x$enableval = xno; then
2728         acsls_support=no
2729      fi
2730   ]
2731)
2732
2733ACSLS_LIBDIR=
2734ACSLS_OS_DEFINE=
2735ACSLS_BUILD_TARGET=
2736
2737AC_SUBST(ACSLS_LIBDIR)
2738AC_SUBST(ACSLS_OS_DEFINE)
2739AC_SUBST(ACSLS_BUILD_TARGET)
2740
2741
2742dnl
2743dnl Check for ACL support and libraries
2744dnl
2745support_acl=auto
2746AC_ARG_ENABLE(acl,
2747   AC_HELP_STRING([--disable-acl], [disable acl support @<:@default=auto@:>@]),
2748   [
2749       if test x$enableval = xyes; then
2750	  support_acl=yes
2751       elif test x$enableval = xno; then
2752	  support_acl=no
2753       fi
2754   ]
2755)
2756
2757have_acl=no
2758have_extended_acl=no
2759if test x$support_acl = xyes -o x$support_acl = xauto; then
2760   AC_CHECK_HEADER(sys/acl.h, [ AC_DEFINE(HAVE_SYS_ACL_H,1,[Defines if your system have the sys/acl.h header file])] , )
2761
2762   dnl
2763   dnl First check for acl_get_file in libc
2764   dnl
2765   AC_CHECK_FUNC(acl_get_file,
2766   [
2767      have_acl=yes
2768   ])
2769
2770   dnl
2771   dnl Check for acl_get_file in libacl (Linux)
2772   dnl
2773   if test $have_acl = no; then
2774      AC_CHECK_LIB(acl, acl_get_file,
2775      [
2776	have_acl=yes
2777	if test $have_afs = yes; then
2778	 dnl
2779	 dnl Because of possible naming conflict with AFS libacl make sure we use the one in /usr/lib64 or /usr/lib !!!
2780	 dnl
2781	    if test -d /usr/lib64/; then
2782	       FDLIBS="-L/usr/lib64 -lacl $FDLIBS"
2783	    else
2784	       FDLIBS="-L/usr/lib -lacl $FDLIBS"
2785	    fi
2786	 else
2787	    FDLIBS="-lacl $FDLIBS"
2788	 fi
2789      ])
2790   fi
2791
2792   dnl
2793   dnl Check for acl_get_file in libpacl (OSF1)
2794   dnl and if ACL_TYPE_DEFAULT_DIR is defined.
2795   dnl
2796   if test $have_acl = no -a x${HAVE_OSF1_OS_TRUE} = x; then
2797      AC_CHECK_LIB(pacl, acl_get_file,
2798      [
2799	 have_acl=yes
2800	 FDLIBS="-lpacl $FDLIBS"
2801      ])
2802
2803      AC_MSG_CHECKING(for ACL_TYPE_DEFAULT_DIR in acl.h include file)
2804      grep ACL_TYPE_DEFAULT_DIR /usr/include/sys/acl.h > /dev/null 2>&1
2805      if test $? = 0; then
2806	 AC_DEFINE(HAVE_ACL_TYPE_DEFAULT_DIR,1,[Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type])
2807	 AC_MSG_RESULT(yes)
2808      else
2809	 AC_MSG_RESULT(no)
2810      fi
2811   fi
2812
2813   dnl
2814   dnl On OSX check for availability of ACL_TYPE_EXTENDED
2815   dnl
2816   if test $have_acl = yes -a x${HAVE_DARWIN_OS_TRUE} = x; then
2817      AC_MSG_CHECKING(for ACL_TYPE_EXTENDED in acl.h include file)
2818      grep ACL_TYPE_EXTENDED /usr/include/sys/acl.h > /dev/null 2>&1
2819      if test $? = 0; then
2820	 AC_DEFINE(HAVE_ACL_TYPE_EXTENDED,1,[Defines if your system have the ACL_TYPE_EXTENDED acl type])
2821	 AC_MSG_RESULT(yes)
2822      else
2823	 AC_MSG_RESULT(no)
2824      fi
2825   fi
2826
2827   dnl
2828   dnl On FreeBSD check for availability of ACL_TYPE_NFS4
2829   dnl
2830   if test $have_acl = yes -a \
2831      x${HAVE_FREEBSD_OS_TRUE} = x; then
2832      AC_MSG_CHECKING(for ACL_TYPE_NFS4 in acl.h include file)
2833      grep ACL_TYPE_NFS4 /usr/include/sys/acl.h > /dev/null 2>&1
2834      if test $? = 0; then
2835    AC_DEFINE(HAVE_ACL_TYPE_NFS4,1,[Defines if your system have the ACL_TYPE_NFS4 acl type])
2836    AC_MSG_RESULT(yes)
2837      else
2838    AC_MSG_RESULT(no)
2839      fi
2840   fi
2841
2842   dnl
2843   dnl Check for acltotext and acl_totext (Solaris)
2844   dnl
2845   if test $have_acl = no -a \
2846      x${HAVE_SUN_OS_TRUE} = x; then
2847      AC_CHECK_LIB(sec, acltotext,
2848    [
2849	have_acl=yes
2850	FDLIBS="-lsec $FDLIBS"
2851
2852	AC_CHECK_LIB(sec, acl_totext,
2853      [
2854	  have_extended_acl=yes
2855      ]
2856	)
2857    ]
2858      )
2859   fi
2860
2861   dnl
2862   dnl Check for acl_get and aclx_get (AIX)
2863   dnl
2864   if test $have_acl = no -a \
2865	   x${HAVE_AIX_OS_TRUE} = x; then
2866      AC_CHECK_FUNC(acl_get,
2867	 [
2868	     have_acl=yes
2869
2870	     AC_CHECK_FUNC(aclx_get,
2871		[
2872		    have_extended_acl=yes
2873		]
2874	     )
2875	 ]
2876      )
2877   fi
2878
2879ACLOBJS=
2880   if test x$support_acl = xyes -a $have_acl != yes; then
2881      AC_MSG_ERROR([acl support explicitly enabled but no supported acl implementation found,
2882  please either load the acl libraries or rerun configure without --enable-acl])
2883   else
2884      if test $have_acl = yes; then
2885	 AC_DEFINE([HAVE_ACL],1,[Normal acl support])
2886	 dnl
2887	 dnl Prepare obj building
2888	 dnl
2889	 if test x${HAVE_LINUX_OS_TRUE} = x; then
2890	    ACLOBJS="bacl.c bacl_linux.c"
2891	 fi
2892	 if test x${HAVE_SUN_OS_TRUE} = x; then
2893	    ACLOBJS="bacl.c bacl_solaris.c"
2894	 fi
2895	 if test x${HAVE_FREEBSD_OS_TRUE} = x; then
2896	    ACLOBJS="bacl.c bacl_freebsd.c"
2897	 fi
2898	 if test x${HAVE_DARWIN_OS_TRUE} = x; then
2899	    ACLOBJS="bacl.c bacl_osx.c"
2900	 fi
2901      fi
2902      if test $have_extended_acl = yes; then
2903	 AC_DEFINE([HAVE_EXTENDED_ACL],1,[Extended acl support])
2904      fi
2905   fi
2906fi
2907AC_SUBST(ACLOBJS)
2908
2909dnl
2910dnl Check for XATTR support
2911dnl
2912support_xattr=auto
2913AC_ARG_ENABLE(xattr,
2914   AC_HELP_STRING([--disable-xattr], [disable xattr support @<:@default=auto@:>@]),
2915   [
2916       if test x$enableval = xyes; then
2917	  support_xattr=yes
2918       elif test x$enableval = xno; then
2919	  support_xattr=no
2920       fi
2921   ]
2922)
2923
2924have_xattr=no
2925if test x$support_xattr = xyes -o x$support_xattr = xauto; then
2926   dnl
2927   dnl First check for *BSD support
2928   dnl When running on a BSD variant
2929   dnl
2930   if test x${HAVE_FREEBSD_OS_TRUE} = x -o \
2931	   x${HAVE_NETBSD_OS_TRUE} = x -o \
2932	   x${HAVE_OPENBSD_OS_TRUE} = x; then
2933      AC_CHECK_HEADER(sys/extattr.h, [ AC_DEFINE(HAVE_SYS_EXTATTR_H,1,[Defines if your system have the sys/extattr.h header file])] , )
2934      AC_CHECK_HEADER(libutil.h, [ AC_DEFINE(HAVE_LIBUTIL_H,1,[Defines if your system have the libutil.h header file])] , )
2935      AC_CHECK_FUNCS(extattr_get_link extattr_set_link extattr_list_link,
2936	 [
2937	     have_xattr=yes
2938	     AC_DEFINE([HAVE_EXTATTR_GET_LINK],1,[Define to 1 if you have the 'extattr_get_link' function.])
2939	     AC_DEFINE([HAVE_EXTATTR_SET_LINK],1,[Define to 1 if you have the 'extattr_set_link' function.])
2940	     AC_DEFINE([HAVE_EXTATTR_LIST_LINK],1,[Define to 1 if you have the 'extattr_list_link' function.])
2941	 ]
2942      )
2943
2944      if test $have_xattr = no; then
2945	 AC_CHECK_FUNCS(extattr_get_file extattr_set_file extattr_list_file,
2946	    [
2947		have_xattr=yes
2948		AC_DEFINE([HAVE_EXTATTR_GET_FILE],1,[Define to 1 if you have the 'extattr_get_file' function.])
2949		AC_DEFINE([HAVE_EXTATTR_SET_FILE],1,[Define to 1 if you have the 'extattr_set_file' function.])
2950		AC_DEFINE([HAVE_EXTATTR_LIST_FILE],1,[Define to 1 if you have the 'extattr_list_file' function.])
2951	    ]
2952	 )
2953      fi
2954
2955      if test $have_xattr = yes; then
2956	 have_extattr_string_in_libc=no
2957	 AC_CHECK_FUNCS(extattr_namespace_to_string extattr_string_to_namespace,
2958	    [
2959		have_extattr_string_in_libc=yes
2960		AC_DEFINE([HAVE_EXTATTR_NAMESPACE_TO_STRING],1,[Define to 1 if you have the 'extattr_namespace_to_string' function.])
2961		AC_DEFINE([HAVE_EXTATTR_STRING_TO_NAMESPACE],1,[Define to 1 if you have the 'extattr_string_to_namespace' function.])
2962	    ]
2963	 )
2964
2965	 dnl
2966	 dnl If extattr_namespace_to_string and extattr_string_to_namespace are not in libc see if they are in libutil
2967	 dnl
2968	 if test $have_extattr_string_in_libc = no; then
2969	    AC_CHECK_LIB(util, extattr_namespace_to_string extattr_string_to_namespace,
2970	       [
2971		   AC_DEFINE([HAVE_EXTATTR_NAMESPACE_TO_STRING],1,[Define to 1 if you have the 'extattr_namespace_to_string' function.])
2972		   AC_DEFINE([HAVE_EXTATTR_STRING_TO_NAMESPACE],1,[Define to 1 if you have the 'extattr_string_to_namespace' function.])
2973		   FDLIBS="-lutil $FDLIBS"
2974	       ]
2975	    )
2976	 fi
2977      fi
2978   fi
2979
2980   dnl
2981   dnl If we failed to find *BSD support try the AIX implementation of extented attributes (EA)
2982   dnl When running on AIX
2983   dnl
2984   if test $have_xattr = no -a \
2985	   x${HAVE_AIX_OS_TRUE} = x; then
2986      AC_CHECK_HEADER(sys/ea.h, [ AC_DEFINE(HAVE_SYS_EA_H,1,[Defines if your system have the sys/ea.h header file])] , )
2987      AC_CHECK_FUNCS(llistea lgetea lsetea,
2988	 [
2989	     have_xattr=yes
2990	     AC_DEFINE([HAVE_LLISTEA],1,[Define to 1 if you have the 'llistea' function.])
2991	     AC_DEFINE([HAVE_LGETEA],1,[Define to 1 if you have the 'lgetea' function.])
2992	     AC_DEFINE([HAVE_LSETEA],1,[Define to 1 if you have the 'lsetea' function.])
2993	 ]
2994      )
2995
2996      if test $have_xattr = no; then
2997	 AC_CHECK_FUNCS(listea getea setea,
2998	    [
2999		have_xattr=yes
3000		AC_DEFINE([HAVE_LISTEA],1,[Define to 1 if you have the 'listea' function.])
3001		AC_DEFINE([HAVE_GETEA],1,[Define to 1 if you have the 'getea' function.])
3002		AC_DEFINE([HAVE_SETEA],1,[Define to 1 if you have the 'setea' function.])
3003	    ]
3004	 )
3005      fi
3006   fi
3007
3008   dnl
3009   dnl If we failed to find AIX support try the TRU64 implementation of extented attributes
3010   dnl when running on a TRU64 OS.
3011   dnl
3012   if test $have_xattr = no -a \
3013	   x${HAVE_OSF1_OS_TRUE} = x; then
3014      AC_CHECK_HEADER(sys/proplist.h, [ AC_DEFINE(HAVE_SYS_PROPLIST_H,1,[Defines if your system have the sys/proplist.h header file])] , )
3015      AC_CHECK_FUNCS(getproplist get_proplist_entry sizeof_proplist_entry add_proplist_entry setproplist,
3016	 [
3017	     have_xattr=yes
3018	     AC_DEFINE([HAVE_GETPROPLIST],1,[Define to 1 if you have the 'getproplist' function.])
3019	     AC_DEFINE([HAVE_GET_PROPLIST_ENTRY],1,[Define to 1 if you have the 'get_proplist_entry' function.])
3020	     AC_DEFINE([HAVE_SIZEOF_PROPLIST_ENTRY],1,[Define to 1 if you have the 'sizeof_proplist_entry' function.])
3021	     AC_DEFINE([HAVE_ADD_PROPLIST_ENTRY],1,[Define to 1 if you have the 'add_proplist_entry' function.])
3022	     AC_DEFINE([HAVE_SETPROPLIST],1,[Define to 1 if you have the 'setproplist' function.])
3023	 ]
3024      )
3025   fi
3026
3027   dnl
3028   dnl If we failed to find TRU64 support try the SOLARIS implementation of extented and extensible attributes
3029   dnl when running on a Solaris.
3030   dnl
3031   if test $have_xattr = no -a \
3032      x${HAVE_SUN_OS_TRUE} = x; then
3033      AC_CHECK_HEADER(sys/attr.h, [ AC_DEFINE(HAVE_SYS_ATTR_H,1,[Defines if your system have the sys/attr.h header file])] , )
3034      AC_CHECK_HEADER(sys/nvpair.h, [ AC_DEFINE(HAVE_SYS_NVPAIR_H,1,[Defines if your system have the sys/nvpair.h header file])] , )
3035      AC_CHECK_HEADER(attr.h, [ AC_DEFINE(HAVE_ATTR_H,1,[Defines if your system have the attr.h header file])] , )
3036
3037      AC_CHECK_FUNCS(openat attropen unlinkat fchownat futimesat linkat,
3038	 [
3039	    have_xattr=yes
3040	    AC_DEFINE([HAVE_OPENAT],1,[Define to 1 if you have the 'openat' function.])
3041	    AC_DEFINE([HAVE_ATTROPEN],1,[Define to 1 if you have the 'attropen' function.])
3042	    AC_DEFINE([HAVE_UNLINKAT],1,[Define to 1 if you have the 'unlinkat' function.])
3043	    AC_DEFINE([HAVE_FCHOWNAT],1,[Define to 1 if you have the 'fchownat' function.])
3044	    AC_DEFINE([HAVE_FUTIMESAT],1,[Define to 1 if you have the 'futimesat' function.])
3045	    AC_DEFINE([HAVE_LINKAT],1,[Define to 1 if you have the 'linkat' function.])
3046	 ]
3047      )
3048
3049      if test $have_xattr = yes; then
3050	 AC_CHECK_LIB(nvpair, nvlist_next_nvpair,
3051	    [
3052	       AC_DEFINE([HAVE_NVLIST_NEXT_NVPAIR],1,[Define to 1 if you have the 'nvlist_next_nvpair' function.])
3053	       FDLIBS="-lnvpair $FDLIBS"
3054	    ]
3055	 )
3056      fi
3057   fi
3058
3059   dnl
3060   dnl If we failed to find Solaris support try the generic xattr support code
3061   dnl
3062   if test $have_xattr = no; then
3063      AC_CHECK_HEADER(sys/xattr.h, [ AC_DEFINE(HAVE_SYS_XATTR_H,1,[Defines if your system have the sys/xattr.h header file])] , )
3064      AC_CHECK_FUNCS(llistxattr lgetxattr lsetxattr,
3065	 [
3066	     have_xattr=yes
3067	     AC_DEFINE([HAVE_LLISTXATTR],1,[Define to 1 if you have the 'llistxattr' function.])
3068	     AC_DEFINE([HAVE_LGETXATTR],1,[Define to 1 if you have the 'lgetxattr' function.])
3069	     AC_DEFINE([HAVE_LSETXATTR],1,[Define to 1 if you have the 'lsetxattr' function.])
3070	 ]
3071      )
3072
3073      if test $have_xattr = no; then
3074	 AC_CHECK_FUNCS(listxattr getxattr setxattr,
3075	    [
3076		have_xattr=yes
3077		AC_DEFINE([HAVE_LISTXATTR],1,[Define to 1 if you have the 'listxattr' function.])
3078		AC_DEFINE([HAVE_GETXATTR],1,[Define to 1 if you have the 'getxattr' function.])
3079		AC_DEFINE([HAVE_SETXATTR],1,[Define to 1 if you have the 'setxattr' function.])
3080	    ]
3081	 )
3082      fi
3083   fi
3084
3085XATTROBJS=
3086   if test x$support_xattr = xyes -a $have_xattr != yes; then
3087      AC_MSG_ERROR([xattr support explicitly enabled but no supported xattr implementation found,
3088  please either load the xattr libraries or rerun configure without --enable-xattr])
3089   else
3090      if test $have_xattr = yes; then
3091	 AC_DEFINE([HAVE_XATTR],1,[Extended Attributes support])
3092	 dnl
3093	 dnl Prepare obj building
3094	 dnl
3095	 if test x${HAVE_LINUX_OS_TRUE} = x; then
3096	    XATTROBJS="bxattr.c bxattr_linux.c"
3097	 fi
3098	 if test x${HAVE_SUN_OS_TRUE} = x; then
3099	    XATTROBJS="bxattr.c bxattr_solaris.c"
3100	 fi
3101	 if test x${HAVE_FREEBSD_OS_TRUE} = x; then
3102	    XATTROBJS="bxattr.c bxattr_freebsd.c"
3103	 fi
3104	 if test x${HAVE_DARWIN_OS_TRUE} = x; then
3105	    XATTROBJS="bxattr.c bxattr_osx.c"
3106	 fi
3107      fi
3108   fi
3109fi
3110AC_SUBST(XATTROBJS)
3111
3112dnl
3113dnl Check if we have AFS on this system
3114dnl
3115AFS_CFLAGS=""
3116AFS_LIBS=""
3117support_afs=auto
3118AC_ARG_ENABLE(afs,
3119   AC_HELP_STRING([--disable-afs], [disable afs support @<:@default=auto@:>@]),
3120   [
3121       if test x$enableval = xyes; then
3122     support_afs=yes
3123       elif test x$enableval = xno; then
3124     support_afs=no
3125       fi
3126   ]
3127)
3128
3129dnl
3130dnl Check if we have GPFS on this system
3131dnl
3132GPFS_CFLAGS=""
3133GPFS_LDFLAGS=""
3134support_gpfs=auto
3135AC_ARG_ENABLE(gpfs,
3136   AC_HELP_STRING([--disable-gpfs], [disable gpfs support @<:@default=auto@:>@]),
3137   [
3138      if test x$enableval = xyes; then
3139         support_gpfs=yes
3140      elif test x$enableval = xno; then
3141         support_gpfs=no
3142      fi
3143   ]
3144)
3145
3146dnl
3147dnl Check if ACL engine enabled
3148dnl
3149have_gpfs=no
3150have_gpfslib=no
3151GPFSLIB=""
3152if test x$have_acl = xno -a x$have_xattr = xno; then
3153   if test x$support_gpfs = xyes; then
3154      AC_MSG_WARN(ACL and XATTR engine disabled - disable dependent GPFS support.)
3155   fi
3156else
3157   if test x$support_gpfs = xyes -o x$support_gpfs = xauto; then
3158      AC_ARG_WITH(gpfsdir,
3159         AC_HELP_STRING([--with-gpfsdir@<:@=DIR@:>@], [Directory holding GPFS includes/libs]),
3160         with_gpfsdir=$withval
3161      )
3162
3163      saved_CFLAGS="${CFLAGS}"
3164      saved_CPPFLAGS="${CPPFLAGS}"
3165      saved_LDFLAGS="${LDFLAGS}"
3166
3167      if test x$with_gpfsdir != x; then
3168         GPFS_CFLAGS="-I${with_gpfsdir}/include"
3169         CFLAGS="${GPFS_CFLAGS} ${saved_CFLAGS}"
3170         CPPFLAGS="${GPFS_CFLAGS} ${saved_CPPFLAGS}"
3171         LDFLAGS="-L${with_gpfsdir}/lib  ${saved_LDFLAGS}"
3172      fi
3173
3174      AC_CHECK_HEADER(gpfs.h,
3175      [
3176        have_gpfs=yes
3177      ])
3178
3179      AC_CHECK_LIB(gpfs, gpfs_getacl,
3180      [
3181        have_gpfslib=yes
3182      ])
3183
3184      if test x$with_gpfsdir != x; then
3185         CFLAGS="${saved_CFLAGS}"
3186         CPPFLAGS="${saved_CPPFLAGS}"
3187         LDFLAGS="${saved_LDFLAGS}"
3188      fi
3189      if test x$have_gpfslib = xyes; then
3190         if test -f ${with_gpfsdir}/lib/libgpfs.so; then
3191            GPFSLIB=`realpath ${with_gpfsdir}/lib/libgpfs.so`
3192            AC_DEFINE_UNQUOTED(GPFSLIB_CUSTOM_PATH, ["${GPFSLIB}"], [GPFSLIB custom path])
3193         fi
3194      fi
3195      if test x$have_gpfs = xyes; then
3196            AC_DEFINE(HAVE_GPFS, 1, [Define to 1 if your system has GPFS support])
3197            AC_DEFINE(HAVE_GPFS_ACL, 1, [GPFS ACL support])
3198            AC_DEFINE(HAVE_GPFS_XATTR, 1, [GPFS XATTR support])
3199      fi
3200   fi
3201   AC_SUBST(GPFS_CFLAGS)
3202fi
3203
3204
3205
3206dnl
3207dnl Check for pthread libraries
3208dnl
3209PTHREAD_LIB=""
3210AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
3211   [
3212       AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
3213	  [
3214	      AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
3215		 [
3216		     AC_CHECK_FUNC(pthread_create)
3217		 ]
3218	      )
3219	  ]
3220       )
3221   ]
3222)
3223
3224dnl
3225dnl Enable/Disable plugin support
3226dnl
3227
3228PLUGCONFILES=""
3229
3230dnl Docker Plugin
3231support_docker=auto
3232AC_ARG_ENABLE(docker-plugin,
3233   AC_HELP_STRING([--disable-docker-plugin], [disable Docker plugin support @<:@default=auto@:>@]),
3234   [
3235      if test x$enableval = xyes; then
3236         support_docker=yes
3237      elif test x$enableval = xno; then
3238         support_docker=disabled
3239      fi
3240   ]
3241)
3242if test x$support_docker = xyes -o x$support_docker = xauto; then
3243   AC_CHECK_PROG(docker_bin, docker, yes, no, "/usr/bin/")
3244   if test x$docker_bin = xyes; then
3245      support_docker=yes
3246      FD_PLUGIN_DIR="$FD_PLUGIN_DIR src/plugins/fd/docker"
3247      PLUGCONFILES="${PLUGCONFILES} src/plugins/fd/docker/Makefile"
3248   else
3249      if test x$support_docker = xyes; then
3250         echo " "
3251         echo "You enabled a Docker Plugin build but 'docker' command not found."
3252         echo " "
3253         exit 1
3254      fi
3255      support_docker=no
3256   fi
3257fi
3258
3259AC_SUBST(FD_PLUGIN_DIR)
3260
3261dnl
3262dnl Check for headers, functions and libraries required to support
3263dnl keeping readall capabilities
3264dnl
3265AC_CHECK_HEADERS(sys/prctl.h sys/capability.h)
3266AC_CHECK_FUNCS(prctl setreuid)
3267AC_CHECK_LIB([cap], [cap_set_proc], [CAP_LIBS="-lcap"], [CAP_LIBS=])
3268if test x$CAP_LIBS = x-lcap; then
3269   AC_DEFINE(HAVE_LIBCAP, 1, [Define if you have libcap])
3270fi
3271AC_SUBST(CAP_LIBS)
3272
3273AC_SUBST(FDLIBS)
3274AC_DEFINE(FDLIBS)
3275
3276CFLAGS=${CFLAGS--O}
3277
3278if test x$have_gcc = xyes ; then
3279   CPPFLAGS="$CPPFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
3280   CFLAGS="$CFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
3281fi
3282LDFLAGS=${LDFLAGS--O}
3283CPPFLAGS="$CPPFLAGS"
3284CFLAGS="$CFLAGS"
3285AC_SUBST(DEBUG)
3286AC_SUBST(DINCLUDE)
3287AC_SUBST(CFLAGS)
3288AC_SUBST(CPPFLAGS)
3289AC_SUBST(LDFLAGS)
3290AC_SUBST(X_CFLAGS)
3291AC_SUBST(DEFS)
3292AC_SUBST(LIBS)
3293AC_SUBST(DLIB)
3294AC_SUBST(X_LIBS)
3295AC_SUBST(X_EXTRA_LIBS)
3296AC_SUBST(WCFLAGS)
3297AC_SUBST(WLDFLAGS)
3298AC_SUBST(WRAPLIBS)
3299
3300dnl extra configurable objects
3301OBJLIST=
3302AC_SUBST(OBJLIST)
3303
3304lld="lld"
3305llu="llu"
3306
3307WCFLAGS=
3308WLDFLAGS=
3309
3310dnl
3311dnl Finally we set appropriate distribution specific
3312dnl  variables and defaults
3313dnl
3314PSCMD="ps -e"
3315WIN32=
3316MACOSX=
3317COMPRESS_MANPAGES=yes
3318
3319case "$DISTNAME" in
3320aix)
3321   DISTVER=`uname -r`
3322   PSCMD="ps -e -o pid,comm"
3323   PFILES="${PFILES} platforms/aix/Makefile"
3324   TAPEDRIVE="/dev/rmt0.1"
3325  ;;
3326alpha)
3327   DISTVER=`uname -r`
3328   PTHREAD_LIB="-lpthread -lexc"
3329   if test "${CC}" = "gcc" ; then
3330      lld="lld"
3331      llu="llu"
3332   else
3333      lld="ld"
3334      llu="lu"
3335   fi
3336   TAPEDRIVE="/dev/nrmt0"
3337  ;;
3338bsdi)
3339   DISTVER=`uname -a |awk '{print $3}'`
3340   TAPEDRIVE="/dev/nrmt0"
3341   PTHREAD_LIB="-pthread"
3342   CFLAGS="${CFLAGS} -pthread"
3343   PSCMD="ps -ax -o pid,command"
3344   lld="qd"
3345   llu="qu"
3346   PFILES="${PFILES} \
3347       platforms/bsdi/Makefile \
3348       platforms/bsdi/bacula-fd \
3349       platforms/bsdi/bacula-sd \
3350       platforms/bsdi/bacula-dir"
3351   largefile_support="yes"
3352  ;;
3353cygwin)
3354   DISTVER=`uname -a |awk '{print $3}'`
3355   TAPEDRIVE="/dev/nrst0"
3356   WIN32=win32
3357   WCFLAGS="-mwindows"
3358   WLDFLAGS="-mwindows"
3359  ;;
3360darwin)
3361   DISTVER=`uname -r`
3362   TAPEDRIVE="/dev/nst0"
3363   PSCMD="ps -e -o pid,command"
3364   MACOSX=macosx
3365   PFILES="${PFILES} \
3366      platforms/darwin/Makefile"
3367  ;;
3368osx)
3369   DISTVER=`uname -r`
3370   TAPEDRIVE="/dev/nst0"
3371   PSCMD="ps -e -o pid,command"
3372   MACOSX=macosx
3373   PFILES="${PFILES} \
3374      platforms/osx/Makefile"
3375  ;;
3376debian)
3377   if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then
3378      DISTNAME="ubuntu"
3379   fi
3380   DISTVER=`cat /etc/debian_version`
3381   if test -f /etc/lsb-release ; then
3382      . /etc/lsb-release
3383      if test "x$DISTRIB_ID" != "x" ; then
3384	 DISTNAME=$DISTRIB_ID
3385      fi
3386      if test "x$DISTRIB_RELEASE" != "x" ; then
3387	 DISTVER=$DISTRIB_RELEASE
3388      fi
3389   fi
3390   if test "$DISTNAME" = "Ubuntu" ; then
3391      DISTNAME="ubuntu"
3392   fi
3393   TAPEDRIVE="/dev/nst0"
3394   PSCMD="ps -e -o pid,command"
3395   if test "$DISTNAME" = "ubuntu" ; then
3396      PFILES="${PFILES} \
3397	 platforms/ubuntu/Makefile \
3398	 platforms/ubuntu/bacula-fd \
3399	 platforms/ubuntu/bacula-sd \
3400	 platforms/ubuntu/bacula-dir"
3401   else
3402      PFILES="${PFILES} \
3403	 platforms/debian/Makefile \
3404	 platforms/debian/bacula-fd \
3405	 platforms/debian/bacula-sd \
3406	 platforms/debian/bacula-dir"
3407   fi
3408  ;;
3409freebsd)
3410   DISTVER=`uname -a |awk '{print $3}'`
3411   VER=`echo $DISTVER | cut -c 1`
3412   if test x$VER = x4 ; then
3413      PTHREAD_LIB="${PTHREAD_LIBS:--pthread}"
3414      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS:--pthread}"
3415   fi
3416   lld="qd"
3417   llu="qu"
3418   TAPEDRIVE="/dev/nrsa0"
3419   PSCMD="ps -ax -o pid,command"
3420   PFILES="${PFILES} \
3421       platforms/freebsd/Makefile \
3422       platforms/freebsd/bacula-fd \
3423       platforms/freebsd/bacula-sd \
3424       platforms/freebsd/bacula-dir"
3425   largefile_support="yes"
3426  ;;
3427hurd)
3428   DISTVER=`uname -r`
3429   TAPEDRIVE="/dev/nst0"
3430   PSCMD="ps -e -o pid,command"
3431   PFILES="${PFILES} \
3432       platforms/hurd/Makefile \
3433       platforms/hurd/bacula-fd \
3434       platforms/hurd/bacula-sd \
3435       platforms/hurd/bacula-dir"
3436  ;;
3437hpux)
3438   PSCMD="UNIX95=1; ps -e -o pid,comm"
3439   CFLAGS="${CFLAGS} -D_XOPEN_SOURCE_EXTENDED=1"
3440   DISTVER=`uname -r`
3441   TAPEDRIVE="/dev/rmt/0hnb"
3442   PTHREAD_LIB="-lpthread"
3443   AC_DEFINE([_INCLUDE_LONGLONG])
3444  ;;
3445irix)
3446   DISTVER=`uname -r`
3447   TAPEDRIVE="/dev/rmt/0cbn"
3448   PSCMD="ps -e -o pid,comm"
3449   PFILES="${PFILES} \
3450       platforms/irix/Makefile \
3451       platforms/irix/bacula-fd \
3452       platforms/irix/bacula-sd \
3453       platforms/irix/bacula-dir"
3454  ;;
3455netbsd)
3456   DISTVER=`uname -a |awk '{print $3}'`
3457   lld="qd"
3458   llu="qu"
3459   TAPEDRIVE="/dev/nrst0"
3460   PSCMD="ps -ax -o pid,command"
3461   PTHREAD_LIB="-pthread"
3462   CFLAGS="${CFLAGS} -pthread"
3463  ;;
3464openbsd)
3465   DISTVER=`uname -a |awk '{print $3}'`
3466   lld="qd"
3467   llu="qu"
3468   TAPEDRIVE="/dev/nrst0"
3469   PSCMD="ps -ax -o pid,command"
3470   PTHREAD_LIB="-pthread"
3471   CFLAGS="${CFLAGS} -pthread"
3472   PFILES="${PFILES} \
3473       platforms/openbsd/Makefile \
3474       platforms/openbsd/bacula-fd \
3475       platforms/openbsd/bacula-sd \
3476       platforms/openbsd/bacula-dir"
3477  ;;
3478redhat)
3479   if test -f /etc/whitebox-release ; then
3480      f=/etc/whitebox-release
3481   else
3482      f=/etc/redhat-release
3483   fi
3484   if test `cat $f | grep release |\
3485	 cut -f 3 -d ' '`x = "Enterprise"x ; then
3486      DISTVER="Enterprise "`cat $f | grep release |\
3487	  cut -f 6 -d ' '`
3488   else
3489       DISTVER=`cat /etc/redhat-release | grep release |\
3490	   cut -f 5 -d ' '`
3491   fi
3492   TAPEDRIVE="/dev/nst0"
3493   PSCMD="ps -e -o pid,command"
3494   PFILES="${PFILES} \
3495       platforms/redhat/Makefile \
3496       platforms/redhat/bacula-fd \
3497       platforms/redhat/bacula-sd \
3498       platforms/redhat/bacula-dir
3499       "
3500  ;;
3501mandrake)
3502   DISTVER=`cat /etc/mandrake-release | grep release |\
3503      cut -f 5 -d ' '`
3504   TAPEDRIVE="/dev/nst0"
3505   PSCMD="ps -e -o pid,command"
3506   PFILES="${PFILES} \
3507       platforms/mandrake/Makefile \
3508       platforms/mandrake/bacula-fd \
3509       platforms/mandrake/bacula-sd \
3510       platforms/mandrake/bacula-dir \
3511       "
3512  ;;
3513gentoo)
3514   DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
3515   TAPEDRIVE="/dev/nst0"
3516   PSCMD="ps -e -o pid,command"
3517   PFILES="${PFILES} \
3518       platforms/gentoo/Makefile \
3519    platforms/gentoo/bacula-init \
3520       platforms/gentoo/bacula-fd \
3521       platforms/gentoo/bacula-sd \
3522       platforms/gentoo/bacula-dir"
3523  ;;
3524slackware)
3525   DISTVER=`cat /etc/slackware-version`
3526   TAPEDRIVE="/dev/nst0"
3527   PSCMD="ps -e -o pid,command"
3528   PFILES="${PFILES} \
3529       platforms/slackware/Makefile \
3530       platforms/slackware/rc.bacula-fd \
3531       platforms/slackware/rc.bacula-sd \
3532       platforms/slackware/rc.bacula-dir\
3533       platforms/slackware/functions.bacula"
3534  ;;
3535solaris)
3536   DISTVER=`uname -r`
3537   TAPEDRIVE="/dev/rmt/0cbn"
3538   PSCMD="ps -e -o pid,comm"
3539   PFILES="${PFILES} \
3540       platforms/solaris/Makefile \
3541       platforms/solaris/bacula-fd \
3542       platforms/solaris/bacula-sd \
3543       platforms/solaris/bacula-dir"
3544   COMPRESS_MANPAGES=
3545   case ${DISTVER} in
3546   5.5|5.6)
3547      AC_DEFINE(HAVE_OLD_SOCKOPT)
3548      AC_DEFINE(USE_THR_SETCONCURRENCY)
3549      ;;
3550   5.7|5.8)
3551      AC_DEFINE(USE_THR_SETCONCURRENCY)
3552      ;;
3553   5.10)
3554      AC_DEFINE(HAVE_SOLARIS10, 1, [Set if building on Solaris 10])
3555      ;;
3556   *)
3557      ;;
3558   esac
3559   LIBS="$LIBS -lresolv -lrt"
3560  ;;
3561suse)
3562   DISTVER=`cat /etc/SuSE-release |grep VERSION|\
3563       cut -f 3 -d ' '`
3564   TAPEDRIVE="/dev/nst0"
3565   PSCMD="ps -e -o pid,command"
3566   PFILES="${PFILES} \
3567       platforms/suse/Makefile \
3568       platforms/suse/bacula-fd \
3569       platforms/suse/bacula-sd \
3570       platforms/suse/bacula-dir \
3571       platforms/suse/bacula"
3572  ;;
3573suse5)
3574   DISTNAME=suse
3575   DISTVER=5.x
3576   TAPEDRIVE="/dev/nst0"
3577   PSCMD="ps -e -o pid,command"
3578   PFILES="${PFILES} \
3579       platforms/suse/Makefile \
3580       platforms/suse/bacula-fd \
3581       platforms/suse/bacula-sd \
3582       platforms/suse/bacula-dir"
3583  ;;
3584unknown)
3585   DISTVER=unknown
3586   TAPEDRIVE="/dev/nst0"
3587  ;;
3588*)
3589  echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
3590  ;;
3591esac
3592
3593dnl -------------------------------------------
3594dnl systemd (default off)
3595dnl -------------------------------------------
3596AC_MSG_CHECKING(for systemd support)
3597AC_ARG_WITH(systemd,
3598   AC_HELP_STRING([--with-systemd@<:@=UNITDIR@:>@], [Include systemd support. UNITDIR is where systemd system .service files are located, default is to ask systemctl.]),
3599   [
3600       if test "$withval" != "no"; then
3601	   if test "$withval" = "yes"; then
3602	       SYSTEMD_UNITDIR="/lib/systemd/system"
3603	   else
3604	       dnl Use user supplied path
3605	       SYSTEMD_UNITDIR="${withval}"
3606	   fi
3607
3608	   PFILES="${PFILES} \
3609		   platforms/systemd/Makefile \
3610		   platforms/systemd/bacula.conf \
3611		   platforms/systemd/bacula-dir.service \
3612		   platforms/systemd/bacula-fd.service \
3613		   platforms/systemd/bacula-sd.service"
3614	   AC_DEFINE(HAVE_SYSTEMD, 1, [Define to 1 if systemd support should be enabled])
3615	   AC_MSG_RESULT(yes)
3616	   support_systemd="yes"
3617       else
3618	   AC_MSG_RESULT(no)
3619	   support_systemd="no"
3620       fi
3621   ],[
3622       support_systemd="no"
3623       AC_MSG_RESULT(no)
3624   ]
3625)
3626AC_SUBST(SYSTEMD_UNITDIR)
3627
3628AC_SUBST(hostname)
3629
3630LIBS="$PTHREAD_LIB $LIBS"
3631
3632AC_DEFINE_UNQUOTED(lld, "$lld")
3633AC_DEFINE_UNQUOTED(llu, "$llu")
3634AC_SUBST(TAPEDRIVE)
3635AC_SUBST(PSCMD)
3636AC_SUBST(WIN32)
3637AC_SUBST(MACOSX)
3638AC_SUBST(DISTNAME)
3639AC_SUBST(DISTVER)
3640AC_SUBST(COMPRESS_MANPAGES)
3641
3642dnl common parts of the Makefile
3643MCOMMON=./autoconf/Make.common
3644AC_SUBST_FILE(MCOMMON)
3645
3646dnl Insanity check
3647if test "x${subsysdir}" = "x${sbindir}" ; then
3648   echo " "
3649   echo " "
3650   echo "You have set both --sbindir and --with-subsys-dir"
3651   echo "  equal to: ${subsysdir} "
3652   echo "This is not permitted. Please reconfigure."
3653   echo " "
3654   echo "Aborting configuration ..."
3655   echo " "
3656   echo " "
3657   exit 1
3658fi
3659
3660AC_CONFIG_FILES([
3661   autoconf/Make.common \
3662   Makefile \
3663   manpages/Makefile \
3664   scripts/btraceback \
3665   scripts/bconsole \
3666   scripts/baculabackupreport \
3667   scripts/bacula \
3668   scripts/bacula-ctl-dir \
3669   scripts/bacula-ctl-fd \
3670   scripts/bacula-ctl-sd \
3671   scripts/devel_bacula \
3672   scripts/Makefile \
3673   scripts/logrotate \
3674   scripts/mtx-changer \
3675   scripts/disk-changer \
3676   scripts/logwatch/Makefile \
3677   scripts/logwatch/logfile.bacula.conf \
3678   scripts/bat.desktop \
3679   scripts/bat.desktop.xsu \
3680   scripts/bat.desktop.consolehelper \
3681   scripts/bat.console_apps \
3682   scripts/bacula-tray-monitor.desktop \
3683   src/Makefile \
3684   src/host.h \
3685   src/console/Makefile \
3686   src/console/bconsole.conf \
3687   src/qt-console/bat.conf \
3688   src/qt-console/bat.pro \
3689   src/qt-console/bat.pro.mingw32 \
3690   src/qt-console/bat.pro.mingw64 \
3691   src/qt-console/install_conf_file \
3692   src/qt-console/tray-monitor/tray-monitor.conf \
3693   src/qt-console/tray-monitor/bacula-tray-monitor.conf \
3694   src/qt-console/tray-monitor/tray-monitor.pro \
3695   src/qt-console/tray-monitor/tray-monitor.pro.mingw32 \
3696   src/qt-console/tray-monitor/tray-monitor.pro.mingw64 \
3697   src/qt-console/tray-monitor/install_conf_file \
3698   src/dird/Makefile \
3699   src/dird/bacula-dir.conf \
3700   src/lib/Makefile \
3701   src/stored/Makefile \
3702   src/stored/bacula-sd.conf \
3703   src/filed/Makefile \
3704   src/filed/bacula-fd.conf \
3705   src/cats/Makefile \
3706   src/cats/make_catalog_backup.pl \
3707   src/cats/make_catalog_backup \
3708   src/cats/delete_catalog_backup \
3709   src/cats/create_postgresql_database \
3710   src/cats/update_postgresql_tables \
3711   src/cats/make_postgresql_tables \
3712   src/cats/grant_postgresql_privileges \
3713   src/cats/drop_postgresql_tables \
3714   src/cats/drop_postgresql_database \
3715   src/cats/create_mysql_database \
3716   src/cats/update_mysql_tables \
3717   src/cats/make_mysql_tables \
3718   src/cats/grant_mysql_privileges \
3719   src/cats/drop_mysql_tables \
3720   src/cats/drop_mysql_database \
3721   src/cats/create_sqlite3_database \
3722   src/cats/update_sqlite3_tables \
3723   src/cats/make_sqlite3_tables \
3724   src/cats/grant_sqlite3_privileges \
3725   src/cats/drop_sqlite3_tables \
3726   src/cats/drop_sqlite3_database \
3727   src/cats/sqlite \
3728   src/cats/mysql \
3729   src/cats/create_bacula_database \
3730   src/cats/update_bacula_tables \
3731   src/cats/grant_bacula_privileges \
3732   src/cats/make_bacula_tables \
3733   src/cats/drop_bacula_tables \
3734   src/cats/drop_bacula_database \
3735   src/cats/install-default-backend \
3736   src/findlib/Makefile \
3737   src/tools/Makefile \
3738   src/tools/cdp-client/Makefile \
3739   src/plugins/fd/Makefile \
3740   src/plugins/sd/Makefile \
3741   src/plugins/dir/Makefile \
3742   po/Makefile.in \
3743   updatedb/update_mysql_tables \
3744   updatedb/update_sqlite3_tables \
3745   updatedb/update_postgresql_tables \
3746   updatedb/update_mysql_tables_9_to_10 \
3747   updatedb/update_sqlite3_tables_9_to_10 \
3748   updatedb/update_postgresql_tables_9_to_10 \
3749   updatedb/update_mysql_tables_10_to_11 \
3750   updatedb/update_sqlite3_tables_10_to_11 \
3751   updatedb/update_postgresql_tables_10_to_11 \
3752   updatedb/update_mysql_tables_11_to_12 \
3753   updatedb/update_sqlite3_tables_11_to_12 \
3754   updatedb/update_postgresql_tables_11_to_12 \
3755   examples/nagios/check_bacula/Makefile \
3756   platforms/rpms/redhat/bacula.spec \
3757   platforms/rpms/redhat/bacula-bat.spec \
3758   platforms/rpms/redhat/bacula-docs.spec \
3759   platforms/rpms/redhat/bacula-mtx.spec \
3760   platforms/rpms/suse/bacula.spec \
3761   platforms/rpms/suse/bacula-bat.spec \
3762   platforms/rpms/suse/bacula-docs.spec \
3763   platforms/rpms/suse/bacula-mtx.spec \
3764   $PLUGCONFILES \
3765   $PFILES
3766])
3767AC_OUTPUT
3768
3769if test "${support_bat}" = "yes" ; then
3770   if test "x$QMAKE" = "xnone"; then
3771      AC_MSG_ERROR([Could not find qmake $PATH. Check your Qt installation])
3772   fi
3773
3774   cd src/qt-console
3775   echo "Creating bat Makefile"
3776   touch bat
3777   chmod 755 bat
3778   rm -f Makefile
3779   rm -rf moc32 obj32 moc64 obj64 ui32 ui64
3780   $QMAKE
3781   ${MAKE:-make} clean
3782
3783   cd tray-monitor
3784   echo "Creating tray-monitor Makefile"
3785   rm -f Makefile
3786   rm -rf moc32 obj32 moc64 obj64 ui32 ui64
3787   $QMAKE
3788   ${MAKE:-make} clean
3789   $QMAKE
3790   ${MAKE:-make} clean
3791   cd ${BUILD_DIR}
3792fi
3793
3794dnl
3795dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
3796dnl requires gcc).  If it's not, don't rebuild dependencies
3797dnl
3798if test X"$GCC" = "Xyes" ; then
3799  echo "Doing make of dependencies"
3800  ${MAKE:-make} depend
3801fi
3802
3803cd src/qt-console
3804chmod 755 install_conf_file build-depkgs-qt-console
3805cd tray-monitor
3806chmod 755 install_conf_file
3807cd ${BUILD_DIR}
3808
3809cd scripts
3810chmod 755 bacula btraceback mtx-changer
3811chmod 755 bconsole disk-changer devel_bacula logrotate
3812cd ..
3813
3814c=updatedb
3815chmod 755 $c/update_mysql_tables_10_to_11   $c/update_sqlite3_tables_10_to_11
3816chmod 755 $c/update_postgresql_tables_10_to_11
3817chmod 755 $c/update_mysql_tables_11_to_12   $c/update_sqlite3_tables_11_to_12
3818chmod 755 $c/update_postgresql_tables_11_to_12
3819
3820
3821c=src/cats
3822
3823chmod 755 $c/create_bacula_database   $c/update_bacula_tables  $c/make_bacula_tables
3824chmod 755 $c/grant_bacula_privileges  $c/drop_bacula_tables    $c/drop_bacula_database
3825
3826chmod 755 $c/create_mysql_database    $c/update_mysql_tables   $c/make_mysql_tables
3827chmod 755 $c/grant_mysql_privileges   $c/drop_mysql_tables     $c/drop_mysql_database
3828
3829chmod 755 $c/create_sqlite3_database   $c/update_sqlite3_tables  $c/make_sqlite3_tables
3830chmod 755 $c/grant_sqlite3_privileges  $c/drop_sqlite3_tables	 $c/drop_sqlite3_database
3831
3832chmod 755 $c/create_postgresql_database  $c/update_postgresql_tables $c/make_postgresql_tables
3833chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables   $c/drop_postgresql_database
3834
3835chmod 755 $c/make_catalog_backup $c/delete_catalog_backup  $c/make_catalog_backup.pl
3836chmod 755 $c/sqlite
3837chmod 755 $c/mysql
3838
3839chmod 755 $c/install-default-backend
3840
3841chmod 755 src/win32/build-depkgs-mingw32 src/win32/build-depkgs-mingw-w64
3842
3843if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
3844   largefile_support="yes"
3845fi
3846
3847dnl Only try to find out the version number of the compiler when we know its some kind of GCC compiler
3848if test X"$GCC" = "Xyes" ; then
3849   dnl
3850   dnl A whole lot of hand springs to get the compiler version.
3851   dnl	This is because gcc changed the output in version 3.0
3852   dnl
3853   CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 3 -d ' '`
3854   if test "x${CCVERSION}" = "x" ; then
3855      CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 1 -d ' '`
3856   fi
3857   CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
3858   if test x"${CXXVERSION}" = x ; then
3859      CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
3860   fi
3861fi
3862
3863# clean up any old junk
3864echo " "
3865echo "Cleaning up"
3866echo " "
3867${MAKE:-make} clean
3868
3869echo "
3870Configuration on `date`:
3871
3872   Host:                      ${host}${post_host} -- ${DISTNAME} ${DISTVER}
3873   Bacula version:            ${BACULA} ${VERSION} (${DATE})
3874   Source code location:      ${srcdir}
3875   Install binaries:          ${sbindir}
3876   Install libraries:         ${libdir}
3877   Install config files:      ${sysconfdir}
3878   Scripts directory:         ${scriptdir}
3879   Archive directory:         ${archivedir}
3880   Working directory:         ${working_dir}
3881   PID directory:             ${piddir}
3882   Subsys directory:          ${subsysdir}
3883   Man directory:             ${mandir}
3884   Data directory:            ${datarootdir}
3885   Plugin directory:          ${plugindir}
3886   C Compiler:                ${CC} ${CCVERSION}
3887   C++ Compiler:              ${CXX} ${CXXVERSION}
3888   Compiler flags:            ${WCFLAGS} ${CFLAGS}
3889   Linker flags:              ${WLDFLAGS} ${LDFLAGS}
3890   Libraries:                 ${LIBS}
3891   Statically Linked Tools:   ${support_static_tools}
3892   Statically Linked FD:      ${support_static_fd}
3893   Statically Linked SD:      ${support_static_sd}
3894   Statically Linked DIR:     ${support_static_dir}
3895   Statically Linked CONS:    ${support_static_cons}
3896   Database backends:         ${db_backends}
3897   Database port:             ${db_port}
3898   Database name:             ${db_name}
3899   Database user:             ${db_user}
3900   Database SSL options:      ${db_ssl_options}
3901
3902   Job Output Email:          ${job_email}
3903   Traceback Email:           ${dump_email}
3904   SMTP Host Address:         ${smtp_host}
3905
3906   Director Port:             ${dir_port}
3907   File daemon Port:          ${fd_port}
3908   Storage daemon Port:       ${sd_port}
3909
3910   Director User:             ${dir_user}
3911   Director Group:            ${dir_group}
3912   Storage Daemon User:       ${sd_user}
3913   Storage DaemonGroup:       ${sd_group}
3914   File Daemon User:          ${fd_user}
3915   File Daemon Group:         ${fd_group}
3916
3917   Large file support:        $largefile_support
3918   Bacula conio support:      ${got_conio} ${CONS_LIBS}
3919   readline support:          ${got_readline} ${PRTREADLINE_SRC}
3920   TCP Wrappers support:      ${TCPW_MSG} ${WRAPLIBS}
3921   TLS support:               ${support_tls}
3922   Encryption support:        ${support_crypto}
3923   ZLIB support:              ${have_zlib}
3924   LZO support:               ${have_lzo}
3925   S3 support:                ${have_libs3}
3926   enable-smartalloc:         ${support_smartalloc}
3927   enable-lockmgr:            ${support_lockmgr}
3928   bat support:               ${support_bat}
3929   client-only:               ${build_client_only}
3930   build-dird:                ${build_dird}
3931   build-stored:              ${build_stored}
3932   Plugin support:            ${have_plugins}
3933   AFS support:               ${have_afs}
3934   ACL support:               ${have_acl}
3935   XATTR support:             ${have_xattr}
3936   GPFS support:              ${have_gpfs} ${GPFSLIB}
3937   systemd support:           ${support_systemd} ${SYSTEMD_UNITDIR}
3938   Batch insert enabled:      ${batch_insert_db_backends}
3939
3940   Plugins:
3941   - Docker:                  ${support_docker}
3942
3943  " > config.out
3944
3945# create a small shell script useful for support with
3946# configure options and config.out info
3947cat > scripts/bacula_config << EOF
3948#!/bin/sh
3949cat << __EOC__
3950$ $0 $ac_configure_args
3951EOF
3952cat config.out >> scripts/bacula_config
3953echo __EOC__ >> scripts/bacula_config
3954chmod 755 scripts/bacula_config
3955
3956cat config.out
3957