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