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