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