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