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