]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/configure.in
Add attempt to recover in catastrophe
[bacula/bacula] / bacula / autoconf / configure.in
1 lal
2 dnl
3 dnl Process this file with autoconf to produce a configure script.
4 dnl
5 AC_INIT(src/version.h)
6 BUILD_DIR=`pwd`
7 cd ..
8 TOP_DIR=`pwd`
9 cd ${BUILD_DIR}
10 AC_SUBST(BUILD_DIR)
11 AC_SUBST(TOP_DIR)
12 AC_CONFIG_AUX_DIR(${BUILD_DIR}/autoconf)
13 AC_CONFIG_HEADER(src/config.h:autoconf/config.h.in)
14
15 dnl require a recent autoconf
16 AC_PREREQ(2.61)
17
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/^.*VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
31 DATE=`sed -n -e 's/^.*[ \t]*BDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
32 LSMDATE=`sed -n -e 's/^.*LSMDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
33 AC_SUBST(VERSION)dnl 
34 AC_SUBST(DATE)dnl 
35 AC_SUBST(LSMDATE)dnl 
36 AC_SUBST(BACULA)dnl
37 AC_SUBST(post_host)dnl
38 echo "configuring for ${BACULA} $VERSION ($DATE)"
39
40 dnl -------------------------------------------------------
41 dnl Check for compiler.
42 dnl ------------------------------------------------------
43
44 AC_PROG_CC
45 AC_PROG_CXX
46 AC_PROG_CC_C_O         dnl Determine if C compiler support -c -o.
47 AC_PROG_GCC_TRADITIONAL    dnl Determine if ioctl() need -traditional.
48
49 BASECC=`basename $CC`
50 have_gcc=no
51 if test "x$BASECC" = xgcc; then
52    AC_DEFINE(HAVE_GCC)
53    have_gcc=yes
54 fi
55 AC_PATH_PROG(CXX, $CXX, $CXX)
56 if test ! -e $CXX; then
57    AC_MSG_ERROR(Unable to find C++ compiler)
58 fi
59
60 dnl -------------------------------------------------------
61 dnl Check for programs.
62 dnl ------------------------------------------------------
63 AC_PROG_INSTALL
64 AC_PATH_PROG(MV, mv, mv)
65 dnl Alert !!!
66 dnl If we name the variable RM it will shadow the RM variable in the configure script and we overwrite the
67 dnl value with the name of the rm command and not rm -f which is its normal content. This gives all kind
68 dnl of strange output of the configure script (like things don't exist etc.).
69 dnl So we name it REMOVE (more software has run into this problem)
70 AC_PATH_PROG(REMOVE, rm, rm)
71 AC_PATH_PROG(CP, cp, cp)
72 AC_PATH_PROG(SED, sed, sed)
73 AC_PATH_PROG(ECHO, echo, echo)
74 AC_PATH_PROG(CMP, cmp, cmp)
75 AC_PATH_PROG(TBL, tbl, tbl)
76 AC_PATH_PROG(AR, ar, ar)
77 AC_PATH_PROG(OPENSSL, openssl, none)
78 AC_PATH_PROG(MTX, mtx, mtx)
79 AC_PATH_PROG(DD, dd, dd)
80 AC_PATH_PROG(MKISOFS, mkisofs, mkisofs)
81 AC_PATH_PROG(PYTHON, python, python)
82 AC_PATH_PROG(GROWISOFS, growisofs, growisofs)
83 AC_PATH_PROG(DVDRWMEDIAINFO, dvd+rw-mediainfo, dvd+rw-mediainfo)
84 AC_PATH_PROG(DVDRWFORMAT, dvd+rw-format, dvd+rw-format)
85 AC_PATH_PROG(PKGCONFIG, pkg-config, pkg-config)
86 AC_PATH_PROG(QMAKE, qmake, none)
87 AC_PATH_PROG(QMAKEQT4, qmake-qt4, none)
88 AC_ARG_VAR(WXCONFIG, [wx-config command. On some systems, you must set it to wx-config-2.6 to use wxWidgets 2.6.])
89 if test "x$WXCONFIG" = x; then
90    WXCONFIG=wx-config
91 fi
92 AC_PATH_PROG(WXCONFIG, ${WXCONFIG}, ${WXCONFIG})
93 AC_ARG_VAR(WXFLAGS, [Parameters to pass to wx-config (e.g. --unicode=no).])
94 AC_PATH_PROG(CDRECORD, cdrecord, cdrecord)
95 AC_PATH_PROG(PIDOF, pidof, pidof)
96 AC_PROG_AWK
97 # Some AWK programs fail, so test it and warn the user
98 if echo xfoo | $AWK 'BEGIN { prog=ARGV[1]; ARGC=1 } 
99       { if ((prog == $2) || (("(" prog ")") == $2) ||
100       (("[" prog "]") == $2) ||
101       ((prog ":") == $2)) { print $1 ; exit 0 } }' xfoo>/dev/null; then :;
102 else
103   AC_MSG_ERROR([!!!!!!!!! WARNING !!!!!!!!!!!!!!
104    The regex engine of $AWK is too broken to be used you 
105    might want to install GNU AWK.
106    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!])
107 fi
108 THE_AWK=$AWK
109 AC_PATH_PROG(AWK, $THE_AWK, $THE_AWK)
110
111
112 test -n "$ARFLAG" || ARFLAGS="cr"
113 AC_SUBST(ARFLAGS)
114
115 MAKE_SHELL=/bin/sh
116 AC_SUBST(MAKE_SHELL)
117
118 AC_SUBST(LOCAL_LIBS)
119 AC_SUBST(LOCAL_CFLAGS)
120 AC_SUBST(LOCAL_LDFLAGS)
121 AC_SUBST(LOCAL_DEFS)
122
123 dnl --------------------------------------------------
124 dnl Libtool config
125 dnl --------------------------------------------------
126 LT_INIT([shared disable-static])
127 LT_LANG([C++])
128 AC_ARG_ENABLE(libtool,
129    AC_HELP_STRING([--enable-libtool], [enable building using GNU libtool @<:@default=yes@:>@]),
130    [
131        if test x$enableval = xno; then
132           use_libtool=no
133        fi
134    ]
135 )
136
137 if test x$use_libtool != xno; then
138    DEFAULT_OBJECT_TYPE=".lo"
139    DEFAULT_ARCHIVE_TYPE=".la"
140    DEFAULT_SHARED_OBJECT_TYPE=".la"
141    LIBTOOL="\$(LIBTOOL)"
142    LIBTOOL_INSTALL_TARGET="libtool-install"
143    LIBTOOL_UNINSTALL_TARGET="libtool-uninstall"
144    LIBTOOL_CLEAN_TARGET="libtool-clean"
145    QMAKE_LIBTOOL="${BUILD_DIR}/libtool"
146 else
147    DEFAULT_OBJECT_TYPE=".o"
148    DEFAULT_ARCHIVE_TYPE=".a"
149    DEFAULT_SHARED_OBJECT_TYPE=".so"
150    LIBTOOL="# \$(LIBTOOL)"
151    LIBTOOL_INSTALL_TARGET=""
152    LIBTOOL_UNINSTALL_TARGET=""
153    LIBTOOL_CLEAN_TARGET=""
154    QMAKE_LIBTOOL="# ${BUILD_DIR}/libtool"
155 fi
156
157 INCLUDE_INSTALL_TARGET=""
158 INCLUDE_UNINSTALL_TARGET=""
159
160 AC_SUBST(DEFAULT_OBJECT_TYPE)
161 AC_SUBST(DEFAULT_ARCHIVE_TYPE)
162 AC_SUBST(DEFAULT_SHARED_OBJECT_TYPE)
163 AC_SUBST(LIBTOOL)
164 AC_SUBST(LIBTOOL_INSTALL_TARGET)
165 AC_SUBST(LIBTOOL_UNINSTALL_TARGET)
166 AC_SUBST(LIBTOOL_CLEAN_TARGET)
167 AC_SUBST(INCLUDE_INSTALL_TARGET)
168 AC_SUBST(INCLUDE_UNINSTALL_TARGET)
169 AC_SUBST(QMAKE_LIBTOOL)
170
171 dnl --------------------------------------------------
172 dnl Bacula OP Sys determination (see aclocal.m4)
173 dnl --------------------------------------------------
174 BA_CHECK_OPSYS
175
176 dnl -----------------------------------------------------------
177 dnl Bacula OPSys Distribution determination (see aclocal.m4)
178 dnl ----------------------------------------------------------
179 BA_CHECK_OPSYS_DISTNAME
180
181 dnl --------------------------------------------------
182 dnl Suppport for gettext (translations)
183 dnl By default, $datarootdir is ${prefix}/share
184 dnl --------------------------------------------------
185 AM_GNU_GETTEXT([external])
186 if test x${prefix} = xNONE ; then
187    if test `eval echo ${datarootdir}` = NONE/share ; then
188       datarootdir=/usr/share
189    fi
190 fi
191
192 dnl ------------------------------------------------------------------
193 dnl If the user has not set --prefix, we set our default to nothing.
194 dnl In this case, if the user has not set --sysconfdir, we set it
195 dnl to the package default of /etc/bacula.  If either --prefix or
196 dnl --sysconfdir is set, we leave sysconfdir alone except to eval it.
197 dnl ------------------------------------------------------------------
198 if test x${prefix} = xNONE ; then
199    if test `eval echo ${sysconfdir}` = NONE/etc ; then
200       sysconfdir=/etc/bacula
201    fi
202    prefix=
203 fi
204 sysconfdir=`eval echo ${sysconfdir}`
205 datarootdir=`eval echo ${datarootdir}`
206 localedir=`eval echo ${datarootdir}/locale`
207 AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")
208 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir") 
209
210 dnl -------------------------------------------------------------------------
211 dnl  If the user has not set --exec-prefix, we default to ${prefix}
212 dnl -------------------------------------------------------------------------
213 if test x${exec_prefix} = xNONE ; then
214    exec_prefix=${prefix}
215 fi
216
217 dnl ------------------------------------------------------------------
218 dnl If the user has not set --sbindir, we set our default as /sbin
219 dnl ------------------------------------------------------------------
220 if test x$sbindir = x'${exec_prefix}/sbin' ; then
221    sbindir=${exec_prefix}/sbin
222 fi
223 sbindir=`eval echo ${sbindir}`
224
225 dnl ------------------------------------------------------------------
226 dnl If the user has not set --libdir, we set our default as /lib
227 dnl ------------------------------------------------------------------
228 if test x$libdir = x'${exec_prefix}/lib' ; then
229    libdir=${exec_prefix}/lib
230 fi
231 libdir=`eval echo ${libdir}`
232
233 dnl ------------------------------------------------------------------
234 dnl If the user has not set --includedir, we set our default as /include
235 dnl ------------------------------------------------------------------
236 if test x$includedir = x'${exec_prefix}/include' ; then
237    includedir=${exec_prefix}/include
238 fi
239 includedir=`eval echo ${includedir}`
240
241 dnl -------------------------------------------------------------------------
242 dnl  If the user has not set --mandir, we default to /usr/share/man
243 dnl -------------------------------------------------------------------------
244 if test x$mandir = x'${prefix}/man' ; then
245    mandir=/usr/share/man
246 fi
247             
248 AC_PATH_PROGS(MSGFMT, msgfmt, no)
249 if test "$MSGFMT" = "no"
250 then
251    echo 'msgfmt program not found, disabling NLS !'
252    USE_NLS=no
253    USE_INCLUDED_LIBINTL=no
254 #else
255    AM_GNU_GETTEXT
256 fi
257
258 support_mysql=no
259 support_sqlite=no
260 support_sqlite3=no
261 support_postgresql=no
262 support_dbi=no
263 support_smartalloc=yes
264 support_readline=yes
265 support_conio=yes
266 support_gnome=no
267 support_bat=no
268 support_wx_console=no
269 support_tls=no
270 support_crypto=no
271 gnome_version=
272 wx_version=
273 support_static_tools=no
274 support_static_fd=no
275 support_static_sd=no
276 support_static_dir=no
277 support_static_cons=no
278 support_python=no
279 build_client_only=no
280 build_dird=yes
281 build_stored=yes
282 cats=
283 db_type=Internal
284 DB_TYPE=bdb
285
286 dnl --------------------------------------------------------------------------
287 dnl CHECKING COMMAND LINE OPTIONS
288 dnl --------------------------------------------------------------------------
289
290 dnl -------------------------------------------
291 dnl gnome (default off)
292 dnl -------------------------------------------
293 AC_ARG_ENABLE(gnome,
294    AC_HELP_STRING([--enable-gnome], [enable build of bgnome-console GUI @<:@default=no@:>@]),
295    [
296        if test x$enableval = xyes; then
297           support_gnome=yes
298        fi
299    ]
300 )
301
302 GNOME_DIR=
303 if test x$support_gnome = xyes; then
304    abc=`$PKGCONFIG --exists libgnomeui-2.0`
305    pkg=$?
306    if test $pkg = 0; then
307       GNOME_INCLUDEDIR=`$PKGCONFIG --cflags-only-I libgnomeui-2.0`
308       GNOMEUI_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
309       GNOME_LIBDIR=`$PKGCONFIG --libs libgnomeui-2.0`
310       GNOME_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
311       AC_SUBST(GNOME_INCLUDEDIR)
312       AC_SUBST(GNOMEUI_LIBS)
313       AC_SUBST(GNOME_LIBDIR)
314       AC_SUBST(GNOME_LIBS)
315       GNOME_DIR=src/gnome2-console
316       gnome_version="Version 2.x"
317    else
318       AC_MSG_ERROR(Unable to find Gnome 2 installation)
319    fi
320 fi
321 AC_SUBST(GNOME_DIR)
322
323 dnl -------------------------------------------
324 dnl bat (default off)
325 dnl -------------------------------------------
326 AC_ARG_ENABLE(bat,
327    AC_HELP_STRING([--enable-bat], [enable build of bat Qt4 GUI @<:@default=no@:>@]),
328    [
329        if test x$enableval = xyes; then
330           AC_DEFINE(HAVE_BAT, 1, [Set if Bacula bat Qt4 GUI support enabled]) 
331           support_bat=yes
332        fi
333    ]
334 )
335
336 BAT_DIR=
337 if test x$support_bat = xyes; then
338    abc=`$PKGCONFIG --atleast-version=4.2 QtGui`
339    pkg=$?
340    if test $pkg = 0; then
341       BAT_DIR=src/qt-console
342    else
343       AC_MSG_ERROR(Unable to find Qt4 installation needed by bat)
344    fi
345 fi
346
347 dnl 
348 dnl  If bat is enabled, we need the qwt library
349 dnl 
350 got_qwt=no
351 QWT_INC=
352 QWT_LDFLAGS=
353 QWT_LIB=
354 QWT=
355 no_qwt=no
356 if test x$support_bat = xyes; then
357    AC_MSG_CHECKING(for qwt support)
358    AC_ARG_WITH(qwt,
359       AC_HELP_STRING([--with-qwt@<:@=DIR@:>@], [specify qwt library directory]),
360       [
361           case "$with_qwt" in
362           no)
363              no_qwt=yes
364              ;;
365           yes|*)
366              if test -f ${with_qwt}/include/qwt.h; then
367                 QWT_INC="${with_qwt}/include"
368                 QWT_LDFLAGS="-L${with_qwt}/lib"
369                 QWT_LIB="-lqwt"
370                 QWT="qwt"
371              fi
372              ;;
373           esac
374       ]    
375    )
376
377    dnl
378    dnl Search in standard places, or --with-qwt not specified
379    dnl
380    if test $no_qwt = no; then 
381       if test x$QWT_INC = x; then
382          for root in /usr /usr/local; do
383             for ver in qwt qwt5 qwt-qt4; do
384                if test -f ${root}/include/${ver}/qwt.h; then
385                   QWT_INC="${root}/include/${ver}"
386                   if test -d ${root}/lib64/; then
387                      QWT_LDFLAGS="-L${root}/lib64"
388                   elif test -d ${root}/lib/64/; then
389                      QWT_LDFLAGS="-L${root}/64"
390                   else
391                      QWT_LDFLAGS="-L${root}/lib"
392                   fi
393                   QWT_LIB="-lqwt"
394                   QWT="qwt"
395                   got_qwt=yes
396                   break;
397                fi
398             done
399          done
400       fi
401    fi
402    if test x$QWT_INC = x; then
403       AC_MSG_RESULT(no)
404    else
405       AC_DEFINE(HAVE_QWT, 1, [Set if bat QWT library found])
406       AC_MSG_RESULT(yes)
407    fi
408 fi
409
410 AC_SUBST(BAT_DIR)
411 AC_SUBST(QWT_INC)
412 AC_SUBST(QWT_LDFLAGS)
413 AC_SUBST(QWT_LIB)
414 AC_SUBST(QWT)
415
416 dnl -------------------------------------------
417 dnl bwx-console (default off)
418 dnl -------------------------------------------
419 AC_ARG_ENABLE(bwx-console,
420    AC_HELP_STRING([--enable-bwx-console], [enable build of wxWidgets console @<:@default=no@:>@]),
421    [
422        if test x$enableval = xyes; then
423           support_wx_console=yes
424        fi
425    ]
426 )
427
428 WX_DIR=
429 if test x$support_wx_console = xyes; then
430    abc=`$WXCONFIG $WXFLAGS --cppflags`
431    pkg=$?
432    if test $pkg = 0; then
433       wx_version="wxWidgets `$WXCONFIG $WXFLAGS --release`"
434       WXCONS_CPPFLAGS=`$WXCONFIG $WXFLAGS --cppflags`
435       WXCONS_LDFLAGS=`$WXCONFIG $WXFLAGS --libs`
436
437       AC_SUBST(WXCONS_CPPFLAGS)
438       AC_SUBST(WXCONS_LDFLAGS)
439       WX_DIR=src/wx-console
440    else
441       echo " "
442       echo "wx-config program not found. bwx-console disabled."
443       echo " "
444       support_wx_console=no
445    fi
446 fi
447 AC_SUBST(WX_DIR)
448
449 dnl -------------------------------------------
450 dnl tray-monitor (default off)
451 dnl -------------------------------------------
452 AC_ARG_ENABLE(tray-monitor,
453    AC_HELP_STRING([--enable-tray-monitor], [enable build of Gnome tray monitor (compatible with KDE @<:@default=no@:>@]),
454    [
455        if test x$enableval = xyes; then
456           support_tray_monitor=yes
457        fi
458    ]
459 )
460
461 TRAY_MONITOR_DIR=
462 if test x$support_tray_monitor = xyes; then
463    abc=`$PKGCONFIG --exists gtk+-2.0`
464    pkg=$?
465    if test $pkg = 0; then
466       TRAY_MONITOR_CPPFLAGS=`$PKGCONFIG --cflags gtk+-2.0`
467       TRAY_MONITOR_LDFLAGS=`$PKGCONFIG --libs gtk+-2.0`
468       AC_SUBST(TRAY_MONITOR_CPPFLAGS)
469       AC_SUBST(TRAY_MONITOR_LDFLAGS)
470       TRAY_MONITOR_DIR=src/tray-monitor
471       abc=`$PKGCONFIG --atleast-version=2.4 gtk+-2.0`
472       pkg=$?
473       if test $pkg = 0; then
474          AC_DEFINE(HAVE_GTK_2_4, 1, [Set if you have GTK 4.2 or greater loaded])
475       fi
476    fi
477 fi
478 AC_SUBST(TRAY_MONITOR_DIR)
479
480 dnl -------------------------------------------
481 dnl smartalloc (default off)
482 dnl -------------------------------------------
483 AC_ARG_ENABLE(smartalloc,
484    AC_HELP_STRING([--enable-smartalloc], [enable smartalloc debugging support @<:@default=no@:>@]),
485    [
486        if test x$enableval = xno; then
487           support_smartalloc=no
488        fi
489    ]
490 )
491
492 if test x$support_smartalloc = xyes; then
493    AC_DEFINE(SMARTALLOC, 1, [Set if you want Smartalloc enabled])
494 fi
495
496 dnl -------------------------------------------
497 dnl static-tools (default off)
498 dnl -------------------------------------------
499 AC_ARG_ENABLE(static-tools,
500    AC_HELP_STRING([--enable-static-tools], [enable static tape tools @<:@default=no@:>@]),
501    [
502        if test x$enableval = xyes; then
503           support_static_tools=yes
504        fi
505    ]
506 )
507
508 TTOOL_LDFLAGS=
509 if test x$support_static_tools = xyes; then
510    TTOOL_LDFLAGS="-static"
511 fi
512 AC_SUBST(TTOOL_LDFLAGS)
513
514 dnl -------------------------------------------
515 dnl static-fd    (default off)
516 dnl -------------------------------------------
517 AC_ARG_ENABLE(static-fd,
518    AC_HELP_STRING([--enable-static-fd], [enable static File daemon @<:@default=no@:>@]),
519    [
520        if test x$enableval = xyes; then
521           support_static_fd=yes
522        fi
523    ]
524 )
525
526 STATIC_FD=
527 if test x$support_static_fd = xyes; then
528    STATIC_FD="static-bacula-fd"
529 fi
530 AC_SUBST(STATIC_FD)
531
532 dnl -------------------------------------------
533 dnl static-sd    (default off)
534 dnl -------------------------------------------
535 AC_ARG_ENABLE(static-sd,
536    AC_HELP_STRING([--enable-static-sd], [enable static Storage daemon @<:@default=no@:>@]),
537    [
538        if test x$enableval = xyes; then
539           support_static_sd=yes
540        fi
541    ]
542 )
543
544 STATIC_SD=
545 if test x$support_static_sd = xyes; then
546    STATIC_SD="static-bacula-sd"
547 fi
548 AC_SUBST(STATIC_SD)
549
550 dnl -------------------------------------------
551 dnl static-dir   (default off)
552 dnl -------------------------------------------
553 AC_ARG_ENABLE(static-dir,
554    AC_HELP_STRING([--enable-static-dir], [enable static Director @<:@default=no@:>@]),
555    [
556        if test x$enableval = xyes; then
557           support_static_dir=yes
558        fi
559    ]
560 )
561
562 STATIC_DIR=
563 if test x$support_static_dir = xyes; then
564    STATIC_DIR="static-bacula-dir"
565 fi
566 AC_SUBST(STATIC_DIR)
567
568 dnl -------------------------------------------
569 dnl static-cons  (default off)
570 dnl -------------------------------------------
571 AC_ARG_ENABLE(static-cons,
572    AC_HELP_STRING([--enable-static-cons], [enable static Console @<:@default=no@:>@]),
573    [
574        if test x$enableval = xyes; then
575           support_static_cons=yes
576        fi
577    ]
578 )
579
580 STATIC_CONS=
581 STATIC_GNOME_CONS=
582 STATIC_WX_CONS=
583 if test x$support_static_cons = xyes; then
584    STATIC_CONS="static-bconsole"
585    STATIC_GNOME_CONS="static-bgnome-console"
586    STATIC_WX_CONS="static-bwx-console"
587 fi
588 AC_SUBST(STATIC_CONS)
589 AC_SUBST(STATIC_GNOME_CONS)
590 AC_SUBST(STATIC_WX_CONS)
591
592 dnl -------------------------------------------
593 dnl client_only  (default off)
594 dnl -------------------------------------------
595 AC_ARG_ENABLE(client-only,
596    AC_HELP_STRING([--enable-client-only], [build client (File daemon) only @<:@default=no@:>@]),
597    [
598        if test x$enableval = xyes; then
599           build_client_only=yes
600           db_type=None
601           DB_TYPE=none
602        fi
603    ]
604 )
605 if test x$build_client_only = xno; then
606    ALL_DIRS="subdirs"
607 else
608    ALL_DIRS=""
609 fi
610 AC_SUBST(ALL_DIRS)
611
612 dnl -------------------------------------------
613 dnl director  (default on)
614 dnl -------------------------------------------
615 AC_ARG_ENABLE(build-dird,
616    AC_HELP_STRING([--enable-build-dird], [enable building of dird (Director) @<:@default=yes@:>@]),
617    [
618        if test x$enableval = xno; then
619           build_dird=no
620        fi
621    ]
622 )
623 if test x$build_dird = xyes; then
624    DIRD_DIR="src/dird"
625    DIR_TOOLS="DIRTOOLS"
626 else
627    DIRD_DIR=""
628    DIR_TOOLS="NODIRTOOLS"
629 fi
630 AC_SUBST(DIRD_DIR)
631 AC_SUBST(DIR_TOOLS)
632
633 dnl -------------------------------------------
634 dnl stored  (default on)
635 dnl -------------------------------------------
636 AC_ARG_ENABLE(build-stored,
637    AC_HELP_STRING([--enable-build-stored], [enable building of stored (Storage daemon) @<:@default=yes@:>@]),
638    [
639       if test x$enableval = xno; then
640          build_stored=no
641       fi
642    ]
643 )
644 if test x$build_stored = xyes; then
645    STORED_DIR="src/stored"
646 else
647    STORED_DIR=""
648 fi
649 AC_SUBST(STORED_DIR)
650
651 dnl ---------------------------------------------------
652 dnl Check for conio (Bacula readline substitute)(
653 dnl ---------------------------------------------------
654 dnl this allows you to turn it completely off
655 AC_ARG_ENABLE(conio,
656    AC_HELP_STRING([--disable-conio], [disable conio support @<:@default=no@:>@]),
657    [
658        if test x$enableval = xno; then
659           support_conio=no
660        fi
661    ]
662 )
663   
664
665 dnl ---------------------------------------------------
666 dnl Check for IPv6 support
667 dnl ---------------------------------------------------
668 dnl this allows you to turn it completely off
669 support_ipv6=yes
670 AC_ARG_ENABLE(ipv6,   
671    AC_HELP_STRING([--enable-ipv6], [enable ipv6 support @<:@default=yes@:>@]),
672    [
673        if test x$enableval = xno; then
674           support_ipv6=no  
675        fi
676    ]
677 )
678
679 if test x$support_ipv6 = xyes; then
680     AC_TRY_LINK([ #include <sys/types.h>
681 #include <sys/socket.h>
682 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;],
683       [support_ipv6=yes], [support_ipv6=no])
684 fi
685
686 if test x$support_ipv6 = xyes; then
687    AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
688 fi
689
690 got_conio="no"
691 if test x$support_conio = xyes; then
692    AC_CHECK_HEADER(termcap.h, 
693      [ AC_CHECK_LIB(termcap, tgetent, 
694        [ CONS_LIBS="-ltermcap"
695     CONS_OBJ="conio.o"
696     CONS_SRC="conio.c"
697     got_conio="yes"
698     support_readline=no
699     AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
700        ],   
701        [ AC_CHECK_LIB(ncurses, tgetent,
702     [ CONS_LIBS="-lncurses"
703       CONS_OBJ="conio.o"
704       CONS_SRC="conio.c"
705       got_conio="yes"
706       support_readline=no
707       AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
708     ])
709        ])
710      ],
711      [
712     AC_CHECK_HEADERS(curses.h)
713     AC_CHECK_HEADER(term.h,
714           [ AC_CHECK_LIB(curses, tgetent, 
715        [ CONS_LIBS="-lcurses"
716          CONS_OBJ="conio.o"
717          CONS_SRC="conio.c"
718          got_conio="yes"
719          support_readline=no
720          AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
721        ])
722           ],
723           [ echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " "],
724 [#if HAVE_CURSES_H
725 #include <curses.h>
726 #endif
727 ])
728      ])
729 fi
730
731
732 dnl ---------------------------------------------------
733 dnl Check for readline support/directory (default off)
734 dnl ---------------------------------------------------
735 dnl this allows you to turn it completely off
736 AC_ARG_ENABLE(readline,
737    AC_HELP_STRING([--disable-readline], [disable readline support @<:@default=yes@:>@]),
738    [
739        if test x$enableval = xno; then
740           support_readline=no
741        fi
742    ]
743 )
744
745 got_readline="no"
746 READLINE_SRC=
747 if test x$support_readline = xyes; then
748    AC_ARG_WITH(readline,
749       AC_HELP_STRING([--with-readline@<:@=DIR@:>@], [specify readline library directory]),
750       [
751           case "$with_readline" in
752           no)
753              :
754              ;;
755           yes|*)
756              if test -f ${with_readline}/readline.h; then
757                 CONS_INC="-I${with_readline}"
758                 CONS_LDFLAGS="-L$with_readline"
759              elif test -f ${with_readline}/include/readline/readline.h; then
760                 CONS_INC="-I${with_readline}/include/readline"
761                 CONS_LDFLAGS="-L${with_readline}/lib"
762                 with_readline="${with_readline}/include/readline"
763              else
764                 with_readline="/usr/include/readline" 
765              fi
766
767              AC_CHECK_HEADER(${with_readline}/readline.h, 
768                 [
769                     AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
770                     CONS_LIBS="-lreadline -lhistory -ltermcap"
771                     got_readline="yes"   
772                 ], [
773                     echo " "
774                     echo "readline.h not found. readline turned off ..."
775                     echo " "
776                 ]
777              )
778              ;;
779           esac
780       ],[
781          dnl check for standard readline library
782          AC_CHECK_HEADER(/usr/include/readline/readline.h, 
783             [
784                 AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
785                 got_readline="yes"
786                 CONS_INC="-I/usr/include/readline"
787                 CONS_LIBS="-lreadline -ltermcap"
788             ], [
789                 dnl Did not find standard library, so try Bacula's default
790                 AC_CHECK_HEADER(${TOP_DIR}/depkgs/readline/readline.h, 
791                     [
792                         AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
793                         got_readline="yes"   
794                         CONS_INC="-I${TOP_DIR}/depkgs/readline"
795                         CONS_LIBS="-lreadline -lhistory -ltermcap"
796                         CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
797                         PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
798                     ], [
799                         echo " "
800                         echo "readline.h not found. readline turned off ..."
801                         echo " "
802                     ]
803                 )
804             ]
805          )
806       ]    
807    )
808 fi
809
810 AC_SUBST(CONS_INC)
811 AC_SUBST(CONS_OBJ)
812 AC_SUBST(CONS_SRC)
813 AC_SUBST(CONS_LIBS)
814 AC_SUBST(CONS_LDFLAGS)
815 AC_SUBST(READLINE_SRC)
816
817 dnl Minimal stuff for readline Makefile configuration
818 MAKE_SHELL=/bin/sh
819 AC_SUBST(MAKE_SHELL)
820 AC_HEADER_STAT
821 AC_HEADER_DIRENT
822 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr lstat lchown)
823 AC_CHECK_FUNCS(nanosleep nl_langinfo)
824 AC_CHECK_HEADERS(varargs.h)
825
826 dnl End of readline/conio stuff
827 dnl -----------------------------------------------------------------------
828
829 dnl -----------------------------------------------------------------------
830 dnl  Check for Python support
831 dnl
832 AC_MSG_CHECKING(for Python support)
833 AC_ARG_WITH(python,
834    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.]),
835    [
836        PYTHON_INCDIR= 
837        PYTHON_LIBS=
838        if test "$withval" != "no"; then
839           if test "$withval" = "yes"; then
840              for python_root in /usr /usr/local /usr/sfw; do
841                 for ver in python2.2 python2.3 python2.4 python2.5; do
842                    if test -f $python_root/include/${ver}/Python.h; then
843                       PYTHON_INCDIR=-I$python_root/include/${ver}
844                       if test -d $python_root/lib64/${ver}/config; then
845                          PYTHON_LIBS="-L$python_root/lib64/${ver}/config -l${ver}"
846                       else
847                          PYTHON_LIBS="-L$python_root/lib/${ver}/config -l${ver}"
848                       fi
849                       break 
850                    fi
851                 done
852              done
853
854              if test x$PYTHON_INCDIR = x; then
855                 if test -f $prefix/include/Python.h; then
856                    PYTHON_INCDIR=-I$prefix/include
857                    if test -d $prefix/lib64/config; then
858                       PYTHON_LIBS="-L$prefix/lib64/config -lpython"
859                    else
860                       PYTHON_LIBS="-L$prefix/lib/config -lpython"
861                    fi
862                 else
863                    AC_MSG_RESULT(no)
864                    AC_MSG_ERROR(Unable to find Python.h in standard locations)
865                 fi
866              fi
867           else
868              if test -f $withval/Python.h; then
869                 PYTHON_INCDIR=-I$withval
870                 PYTHON_LIBS="-L$withval/config -lpython"
871              elif test -f $withval/include/Python.h; then
872                 PYTHON_INCDIR=-I$withval/include
873                 if test -d $withval/lib64/config; then
874                    PYTHON_LIBS="-L$withval/lib64/config -lpython"
875                 else
876                    PYTHON_LIBS="-L$withval/lib/config -lpython"
877                 fi
878              elif test -f $withval/include/python/Python.h; then
879                 PYTHON_INCDIR=-I$withval/include/python
880                 if test -d $withval/lib64/python/config; then
881                    PYTHON_LIBS="-L$withval/lib64/python/config -lpython"
882                 else
883                    PYTHON_LIBS="-L$withval/lib/python/config -lpython"
884                 fi
885              else
886                 AC_MSG_RESULT(no)
887                 AC_MSG_ERROR(Invalid Python directory $withval - unable to find Python.h under $withval)
888              fi
889           fi
890
891           AC_DEFINE([HAVE_PYTHON], 1)
892           AC_MSG_RESULT(yes)
893           support_python=yes
894           AC_MSG_NOTICE(checking for more Python libs)
895           saved_LIBS="$LIBS"; LIBS=
896           AC_SEARCH_LIBS(shm_open, [rt])
897           AC_CHECK_LIB(util, openpty)
898           PYTHON_LIBS="$PYTHON_LIBS $LIBS"
899           LIBS="$saved_LIBS"
900        else
901           AC_MSG_RESULT(no)
902        fi
903    ],[
904        AC_MSG_RESULT(no)
905    ]
906 )
907 AC_SUBST(PYTHON_LIBS)
908 AC_SUBST(PYTHON_INCDIR)
909
910 dnl
911 dnl Find where sockets are (especially for Solaris)
912 dnl Do this before the TCP Wrappers test since tcp wrappers
913 dnl uses the socket library and some linkers are stupid.
914 dnl
915 AC_CHECK_FUNC(socket,
916     AC_MSG_RESULT(using libc's socket),
917     AC_CHECK_LIB(xnet,socket)
918     AC_CHECK_LIB(socket,socket)
919     AC_CHECK_LIB(inet,socket))
920
921 dnl -----------------------------------------------------------
922 dnl Check whether user wants TCP wrappers support (default off)
923 dnl -----------------------------------------------------------
924 TCPW_MSG="no" 
925 WRAPLIBS=""
926 AC_ARG_WITH(tcp-wrappers,
927    AC_HELP_STRING([--with-tcp-wrappers@<:@=DIR@:>@], [enable tcpwrappers support]),
928    [
929        if test "x$withval" != "xno" ; then
930           saved_LIBS="$LIBS"
931           LIBS="$saved_LIBS -lwrap"
932           AC_MSG_CHECKING(for libwrap)
933           AC_SEARCH_LIBS(nanosleep, [rt])
934           AC_TRY_LINK(
935              [ 
936                #include <sys/types.h>
937                #include <tcpd.h>
938                int deny_severity = 0;
939                int allow_severity = 0;
940                struct request_info *req;
941              ], [
942                 hosts_access(req);
943              ], [
944                  AC_MSG_RESULT(yes)
945                  AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
946                  TCPW_MSG="yes" 
947                  LIBS="$saved_LIBS"
948                  WRAPLIBS="-lwrap"
949              ], [
950                  LIBS="$saved_LIBS -lwrap -lnsl"
951                  WRAPLIBS="$saved_LIBS -lwrap -lnsl"
952                  AC_TRY_LINK(
953                    [
954                        #include <sys/types.h>
955                        #include <tcpd.h>
956                        int deny_severity = 0;
957                        int allow_severity = 0;
958                        struct request_info *req;
959                    ], [
960                        hosts_access(req);
961                    ], [
962                       AC_MSG_RESULT(yes)
963                       AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
964                       TCPW_MSG="yes" 
965                       LIBS="$saved_LIBS"
966                       WRAPLIBS="-lwrap"
967                    ], [
968                       AC_MSG_ERROR([*** libwrap missing])
969                    ]
970                 )
971              ]
972           )
973        fi
974    ]
975 )
976
977 dnl -----------------------------------------------------------
978 dnl Check whether OpenSSL is available
979 dnl -----------------------------------------------------------
980 AC_MSG_CHECKING([for OpenSSL])
981 dnl The following uses quadrigraphs:
982 dnl '@<:@' = '['
983 dnl '@:>@' = ']'
984 AC_ARG_WITH(openssl,
985     AC_HELP_STRING([--with-openssl@<:@=DIR@:>@], [Include OpenSSL support. DIR is the OpenSSL base]),
986     [
987         with_openssl_directory=${withval}
988     ]
989 )
990
991 if test "x$with_openssl_directory" != "xno"; then
992    OPENSSL_LIBS="-lssl -lcrypto"
993    OPENSSL_INC=""
994
995    if test "x$with_openssl_directory" != "xyes" && test x"${with_openssl_directory}" != "x"; then
996       #
997       # Make sure the $with_openssl_directory also makes sense
998       #
999       if test -d "$with_openssl_directory/lib" -a -d "$with_openssl_directory/include"; then
1000          OPENSSL_LIBS="-L$with_openssl_directory/lib $OPENSSL_LIBS"
1001          OPENSSL_INC="-I$with_openssl_directory/include $OPENSSL_INC"
1002       fi
1003    fi
1004
1005    saved_LIBS="${LIBS}"
1006    saved_CFLAGS="${CFLAGS}"
1007    LIBS="${saved_LIBS} ${OPENSSL_LIBS}"
1008    CFLAGS="${saved_CFLAGS} ${OPENSSL_INC}"
1009
1010    AC_TRY_LINK(
1011       [
1012           #include <openssl/ssl.h>
1013       ], [
1014            CRYPTO_set_id_callback(NULL);
1015       ], [
1016           support_tls="yes"
1017           support_crypto="yes"
1018       ], [
1019           support_tls="no"
1020       ]
1021    )
1022
1023    AC_TRY_LINK(
1024       [
1025           #include <openssl/evp.h>
1026       ], [
1027           EVP_sha512();
1028       ], [
1029           ac_cv_openssl_sha2="yes"
1030       ], [
1031           ac_cv_openssl_sha2="no"
1032       ]
1033    )
1034
1035    dnl Solaris disables greater than 128+ bit encryption in their OpenSSL
1036    dnl implementation, presumably for export reasons. If 192bit AES
1037    dnl is available, we assume that we're running with a 'non-export'
1038    dnl openssl library.
1039    AC_TRY_LINK(
1040       [
1041           #include <openssl/evp.h>
1042       ], [
1043           EVP_aes_192_cbc();
1044       ], [
1045           ac_cv_openssl_export="no"
1046       ], [
1047           ac_cv_openssl_export="yes"
1048       ]
1049    )
1050
1051    LIBS="${saved_LIBS}"
1052    CFLAGS="${saved_CFLAGS}"
1053
1054    if test "$support_tls" = "yes"; then
1055       AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL library is available])
1056       AC_DEFINE(HAVE_TLS, 1, [Define if TLS support should be enabled])
1057       AC_DEFINE(HAVE_CRYPTO, 1, [Define if encryption support should be enabled])
1058    fi
1059
1060    if test "$ac_cv_openssl_sha2" = "yes"; then
1061       AC_DEFINE(HAVE_SHA2, 1, [Define if the SHA-2 family of digest algorithms is available])
1062    fi
1063
1064    if test "$ac_cv_openssl_export" = "yes"; then
1065       AC_DEFINE(HAVE_OPENSSL_EXPORT_LIBRARY, 1, [Define if the OpenSSL library is export-contrained to 128bit ciphers])
1066    fi
1067 else
1068    support_tls="no"
1069    support_crypto="no"
1070    OPENSSL_LIBS=""
1071    OPENSSL_INC=""
1072 fi
1073
1074 AC_MSG_RESULT([$support_tls])
1075 AC_SUBST(OPENSSL_LIBS)
1076 AC_SUBST(OPENSSL_INC)
1077
1078 dnl -----------------------------------------------------------
1079 dnl dlopen is needed for plugins
1080 dnl -----------------------------------------------------------
1081 AC_SEARCH_LIBS(dlopen, [dl])
1082
1083 dnl ------------------------------------------
1084 dnl Where to place working dir
1085 dnl ------------------------------------------
1086 working_dir=`eval echo ${prefix}/var/bacula/working`
1087 AC_ARG_WITH(working-dir,
1088    AC_HELP_STRING([--with-working-dir=PATH], [specify path of Bacula working directory]),
1089    [
1090        if test "x$withval" != "xno" ; then     
1091          working_dir=$withval
1092        fi
1093    ]
1094 )
1095
1096 AC_SUBST(working_dir)
1097
1098 dnl ------------------------------------------------------------------
1099 dnl If the user has not set archivedir, we set our default as /tmp
1100 dnl ------------------------------------------------------------------
1101 archive_dir=/tmp
1102 AC_ARG_WITH(archivedir,
1103    AC_HELP_STRING([--with-archivedir=PATH], [specify path of SD archive directory]),
1104    [
1105        if test "x$withval" != "xno" ; then     
1106           archivedir=$withval
1107        fi
1108    ]
1109 )
1110
1111 AC_SUBST(archivedir)
1112
1113 dnl ------------------------------------------
1114 dnl Where to place scriptdir (script files)
1115 dnl ------------------------------------------
1116 scriptdir=`eval echo ${sysconfdir}`
1117 AC_ARG_WITH(scriptdir,
1118    AC_HELP_STRING([--with-scriptdir=PATH], [specify path of Bacula scripts directory]),
1119    [
1120        if test "x$withval" != "xno" ; then     
1121           scriptdir=$withval
1122        fi
1123    ]
1124 )
1125
1126 AC_SUBST(scriptdir)
1127
1128 # ------------------------------------------
1129 # Where to place plugindir (script files)
1130 # ------------------------------------------
1131 plugindir=`eval echo ${sysconfdir}`
1132 AC_ARG_WITH(plugindir,
1133    AC_HELP_STRING([--with-plugindir=PATH], [specify path of Bacula plugins directory]),
1134    [
1135        if test "x$withval" != "xno" ; then     
1136           plugindir=$withval
1137        fi
1138    ]
1139 )
1140
1141 AC_SUBST(plugindir)
1142
1143 dnl ------------------------------------------
1144 dnl Where to send dump email
1145 dnl ------------------------------------------
1146 dump_email=root@localhost
1147 AC_ARG_WITH(dump-email,
1148    AC_HELP_STRING([--with-dump-email=EMAIL], [dump email address]),
1149    [
1150        if test "x$withval" != "xno" ; then     
1151           dump_email=$withval
1152        fi
1153    ]
1154 )
1155
1156 AC_SUBST(dump_email)
1157
1158 dnl ------------------------------------------
1159 dnl Where to send job email
1160 dnl ------------------------------------------
1161 job_email=root@localhost
1162 AC_ARG_WITH(job-email,
1163    AC_HELP_STRING([--with-job-email=EMAIL], [job output email address]),
1164    [
1165        if test "x$withval" != "xno" ; then     
1166           job_email=$withval
1167        fi
1168    ]
1169 )
1170
1171 AC_SUBST(job_email)
1172
1173 dnl ------------------------------------------
1174 dnl Where to find smtp host
1175 dnl ------------------------------------------
1176 smtp_host=localhost
1177 AC_ARG_WITH(smtp_host,
1178    AC_HELP_STRING([--with-smtp-host=HOST], [SMTP mail host address]),
1179    [
1180        if test "x$withval" != "xno" ; then     
1181           smtp_host=$withval
1182        fi
1183    ]
1184 )
1185
1186 AC_SUBST(smtp_host)
1187
1188 dnl ------------------------------------
1189 dnl Where to place pid files
1190 dnl ------------------------------------
1191 piddir=/var/run
1192 AC_ARG_WITH(pid-dir,
1193    AC_HELP_STRING([--with-pid-dir=PATH], [specify location of Bacula pid files]),
1194    [
1195        if test "x$withval" != "xno" ; then   
1196           piddir=$withval
1197        fi
1198    ]
1199 )
1200
1201 AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
1202 AC_SUBST(piddir)
1203
1204 dnl ------------------------------------
1205 dnl Where to place subsys "lock file"
1206 dnl ------------------------------------
1207 subsysdir=/var/run/subsys
1208 if test -d /var/run/subsys; then
1209    subsysdir=/var/run/subsys
1210 elif test -d /var/lock/subsys; then
1211    subsysdir=/var/lock/subsys
1212 else
1213    subsysdir=/var/run/subsys
1214 fi
1215 AC_ARG_WITH(subsys-dir,
1216    AC_HELP_STRING([--with-subsys-dir=PATH], [specify location of Bacula subsys file]),
1217    [
1218        if test "x$withval" != "xno" ; then   
1219           subsysdir=$withval
1220        fi
1221    ]
1222 )
1223
1224 AC_SUBST(subsysdir)
1225
1226 dnl ------------------------------------
1227 dnl Where to start assigning ports
1228 dnl ------------------------------------
1229 baseport=9101
1230 AC_ARG_WITH(baseport,
1231    AC_HELP_STRING([--with-baseport=PORT], [specify base port address for daemons]),
1232    [
1233        if test "x$withval" != "xno" ; then   
1234           baseport=$withval
1235        fi
1236    ]
1237 )
1238
1239 AC_SUBST(baseport)
1240 dir_port=`expr $baseport`
1241 fd_port=`expr $baseport + 1`
1242 sd_port=`expr $fd_port + 1`
1243
1244 AC_SUBST(dir_port)
1245 AC_SUBST(fd_port)
1246 AC_SUBST(sd_port)
1247
1248 dnl ------------------------------------------
1249 dnl Generate passwords
1250 dnl ------------------------------------------
1251 dir_password=
1252 AC_ARG_WITH(dir-password,
1253    AC_HELP_STRING([--with-dir-password=PASSWORD], [specify Director's password]),
1254    [
1255        if test "x$withval" != "xno" ; then     
1256           dir_password=$withval
1257        fi
1258    ]
1259 )
1260
1261 if test "x$dir_password" = "x" ; then
1262    if test "x$OPENSSL" = "xnone" ; then
1263       key=`autoconf/randpass 33`
1264    else
1265       key=`openssl rand -base64 33`
1266    fi
1267    dir_password=$key
1268 fi
1269
1270 fd_password=
1271 AC_ARG_WITH(fd-password,
1272    AC_HELP_STRING([--with-fd-password=PASSWORD], [specify Client's password]),
1273    [
1274        if test "x$withval" != "xno" ; then     
1275           fd_password=$withval
1276        fi
1277    ]
1278 )
1279
1280 if test "x$fd_password" = "x" ; then
1281    if test "x$OPENSSL" = "xnone" ; then
1282       key=`autoconf/randpass 37`
1283    else
1284       key=`openssl rand -base64 33`
1285    fi
1286    fd_password=$key
1287 fi
1288
1289 sd_password=
1290 AC_ARG_WITH(sd-password,
1291    AC_HELP_STRING([--with-sd-password=PASSWORD], [specify Storage daemon's password]),
1292    [
1293        if test "x$withval" != "xno" ; then     
1294           sd_password=$withval
1295        fi
1296    ]
1297 )
1298
1299 if test "x$sd_password" = "x" ; then
1300    if test "x$OPENSSL" = "xnone" ; then
1301       key=`autoconf/randpass 41`
1302    else
1303       key=`openssl rand -base64 33`
1304    fi
1305    sd_password=$key
1306 fi
1307
1308 mon_dir_password=
1309 AC_ARG_WITH(mon-dir-password,
1310    AC_HELP_STRING([--with-mon-dir-password=PASSWORD], [specify Director's password used by the monitor]),
1311    [
1312        if test "x$withval" != "xno" ; then     
1313           mon_dir_password=$withval
1314        fi
1315    ]
1316 )
1317
1318 if test "x$mon_dir_password" = "x" ; then
1319    if test "x$OPENSSL" = "xnone" ; then
1320       key=`autoconf/randpass 33`
1321    else
1322       key=`openssl rand -base64 33`
1323    fi
1324    mon_dir_password=$key
1325 fi
1326
1327 mon_fd_password=
1328 AC_ARG_WITH(mon-fd-password,
1329    AC_HELP_STRING([--with-mon-fd-password=PASSWORD], [specify Client's password used by the monitor]),
1330    [
1331        if test "x$withval" != "xno" ; then     
1332           mon_fd_password=$withval
1333        fi
1334    ]
1335 )
1336
1337 if test "x$mon_fd_password" = "x" ; then
1338    if test "x$OPENSSL" = "xnone" ; then
1339       key=`autoconf/randpass 37`
1340    else
1341       key=`openssl rand -base64 33`
1342    fi
1343    mon_fd_password=$key
1344 fi
1345
1346 mon_sd_password=
1347 AC_ARG_WITH(mon-sd-password,
1348    AC_HELP_STRING([--with-mon-sd-password=PASSWORD], [specify Storage daemon's password used by the monitor]),
1349    [
1350        if test "x$withval" != "xno" ; then     
1351           mon_sd_password=$withval
1352        fi
1353    ]
1354 )
1355
1356 if test "x$mon_sd_password" = "x" ; then
1357    if test "x$OPENSSL" = "xnone" ; then
1358       key=`autoconf/randpass 41`
1359    else
1360       key=`openssl rand -base64 33`
1361    fi
1362    mon_sd_password=$key
1363 fi
1364
1365 AC_SUBST(dir_password)
1366 AC_SUBST(fd_password)
1367 AC_SUBST(sd_password)
1368 AC_SUBST(mon_dir_password)
1369 AC_SUBST(mon_fd_password)
1370 AC_SUBST(mon_sd_password)
1371
1372 dnl
1373 dnl Pickup any database name
1374 dnl
1375 db_name=bacula
1376 AC_ARG_WITH(db_name,
1377    AC_HELP_STRING([--with-db-name=DBNAME], [specify database name @<:@default=bacula@:>@]),
1378    [
1379        if test "x$withval" != "x" ; then   
1380           db_name=$withval
1381        fi
1382    ]
1383 )
1384 AC_SUBST(db_name)
1385
1386 db_user=bacula
1387 AC_ARG_WITH(db_user,
1388    AC_HELP_STRING([--with-db-user=UNAME], [specify database user @<:@default=bacula@:>@]),
1389    [
1390        if test "x$withval" != "x" ; then   
1391           db_user=$withval
1392        fi
1393    ]
1394 )
1395 AC_SUBST(db_user)
1396
1397 db_password=
1398 AC_ARG_WITH(db_password,
1399    AC_HELP_STRING([--with-db-password=PWD], [specify database password @<:@default=*none*@:>@]),
1400    [
1401        if test "x$withval" != "x" ; then   
1402           db_password=$withval
1403        fi
1404    ]
1405 )
1406 AC_SUBST(db_password)
1407
1408 dnl
1409 dnl Pickup a database port
1410 dnl
1411 db_port=" "
1412 AC_ARG_WITH(db_port,
1413    AC_HELP_STRING([--with-db-port=DBPORT], [specify a database port @<:@default=null@:>@]),
1414    [
1415        if test "x$withval" != "x" ; then
1416           db_port=$withval
1417        fi
1418    ]
1419 )
1420 AC_SUBST(db_port)
1421
1422 #
1423 # Handle users and groups for each daemon
1424 #
1425 dir_user=
1426 AC_ARG_WITH(dir_user,
1427    AC_HELP_STRING([--with-dir-user=USER], [specify user for Director daemon]),
1428    [
1429        if test "x$withval" != "x" ; then   
1430            dir_user=$withval
1431        fi
1432    ]
1433 )
1434
1435 dir_group=
1436 AC_ARG_WITH(dir_group,
1437    AC_HELP_STRING([--with-dir-group=GROUP], [specify group for Director daemon]),
1438    [
1439        if test "x$withval" != "x" ; then   
1440           dir_group=$withval
1441        fi
1442    ]
1443 )
1444
1445 sd_user=
1446 AC_ARG_WITH(sd_user,
1447    AC_HELP_STRING([--with-sd-user=USER], [specify user for Storage daemon]),
1448    [
1449        if test "x$withval" != "x" ; then   
1450           sd_user=$withval
1451        fi
1452    ]
1453 )
1454
1455 sd_group=
1456 AC_ARG_WITH(sd_group,
1457    AC_HELP_STRING([--with-sd-group=GROUP], [specify group for Storage daemon]),
1458    [
1459        if test "x$withval" != "x" ; then   
1460           sd_group=$withval
1461        fi
1462    ]
1463 )
1464
1465 fd_user=
1466 AC_ARG_WITH(fd_user,
1467    AC_HELP_STRING([--with-fd-user=USER], [specify user for File daemon]),
1468    [
1469        if test "x$withval" != "x" ; then   
1470           fd_user=$withval
1471        fi
1472    ]
1473 )
1474
1475 fd_group=
1476 AC_ARG_WITH(fd_group,
1477    AC_HELP_STRING([--with-fd-group=GROUP], [specify group for File daemon]),
1478    [
1479        if test "x$withval" != "x" ; then   
1480           fd_group=$withval
1481        fi
1482    ]
1483 )
1484
1485 AC_SUBST(dir_user)
1486 AC_SUBST(dir_group)
1487 AC_SUBST(sd_user)
1488 AC_SUBST(sd_group)
1489 AC_SUBST(fd_user)
1490 AC_SUBST(fd_group)
1491
1492 dnl
1493 dnl allow setting default executable permissions
1494 dnl
1495 SBINPERM=0754
1496 AC_ARG_WITH(sbin-perm,
1497    AC_HELP_STRING([--with-sbin-perm=MODE], [specify permissions for sbin binaries @<:@default=0754@:>@]),
1498    [
1499        if test "x$withval" != "x" ; then   
1500           SBINPERM=$withval
1501        fi
1502    ]
1503 )
1504
1505 AC_SUBST(SBINPERM)
1506
1507 dnl ------------------------------------------------
1508 dnl Bacula check for various SQL database engines
1509 dnl ------------------------------------------------
1510 SQL_LIB=
1511 BA_CHECK_POSTGRESQL_DB
1512
1513 BA_CHECK_MYSQL_DB
1514
1515 BA_CHECK_SQLITE3_DB
1516
1517 BA_CHECK_SQLITE_DB
1518
1519 BA_CHECK_DBI_DB
1520
1521 BA_CHECK_DBI_DRIVER
1522
1523 AC_SUBST(cats)
1524 AC_SUBST(DB_TYPE)
1525
1526 dnl -------------------------------------------
1527 dnl enable batch attribute DB insert (default on)
1528 dnl -------------------------------------------
1529 support_batch_insert=no
1530 A=`test -f $SQL_LIB && nm $SQL_LIB | grep pthread_mutex_lock`
1531 pkg=$?
1532 if test $pkg = 0; then
1533    support_batch_insert=yes
1534    AC_ARG_ENABLE(batch-insert,
1535       AC_HELP_STRING([--enable-batch-insert], [enable the DB batch insert code @<:@default=no@:>@]),
1536       [
1537           if test x$enableval = xno; then
1538              support_batch_insert=no
1539           else
1540              support_batch_insert=yes
1541           fi
1542       ]
1543    )
1544 fi
1545    
1546 dnl Check if postgresql support batch mode   
1547 if test x$DB_TYPE = xpostgresql; then
1548    A=`test -f $SQL_LIB && nm $SQL_LIB | grep PQputCopyData`
1549    pkg=$?
1550    if test $pkg != 0; then
1551       support_batch_insert=no
1552    fi
1553 fi
1554
1555 if test x$DB_TYPE = xdbi; then
1556    DB_TYPE=$DB_PROG
1557    db_type=$DB_PROG
1558    pkg=1
1559    dnl Check for batch insert
1560    if test $DB_PROG = postgresql; then
1561       A=`test -f $SQL_LIB && nm $SQL_LIB | grep PQputCopyData`
1562       pkg=$?
1563    fi
1564
1565    if test $DB_PROG = mysql; then
1566       A=`test -f $SQL_LIB && nm $DB_PROG_LIB | grep pthread_mutex_lock`
1567       pkg=$?    
1568    fi
1569
1570    if test $DB_PROG = sqlite3; then
1571       A=`test -f $SQL_LIB && nm $DB_PROG_LIB | grep pthread_mutex_lock`
1572       pkg=$?
1573    fi
1574
1575    if test $pkg = 0; then
1576       AC_ARG_ENABLE(batch-insert,
1577          AC_HELP_STRING([--enable-batch-insert], [enable the DB batch insert code @<:@default=no@:>@]),
1578          [
1579              if test x$enableval = xno; then
1580                 support_batch_insert=no
1581              else
1582                 support_batch_insert=yes
1583              fi
1584          ]
1585       )
1586    fi
1587 else 
1588    dnl If dbi was not chosen, let the comment in file
1589    uncomment_dbi="#"  
1590 fi
1591
1592 AC_SUBST(uncomment_dbi)
1593
1594 if test $support_batch_insert = yes ; then
1595    AC_DEFINE(HAVE_BATCH_FILE_INSERT, 1, [Set if DB batch insert code enabled])
1596 fi
1597
1598 AC_DEFINE(PROTOTYPES)
1599
1600 dnl --------------------------------------------------------------------------
1601 dnl Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
1602 dnl
1603 if test -z "$CFLAGS" -o "$CFLAGS" = "-g -O2"; then
1604    if test -z "$CCOPTS"; then
1605       CCOPTS='-g -O2 -Wall'
1606    fi
1607    CFLAGS="$CCOPTS"
1608 fi
1609
1610 dnl A few others 
1611 AC_EXEEXT
1612
1613 dnl See if we can use 64 bit file addresses
1614 largefile_support="no"
1615 AC_BAC_LARGEFILE
1616
1617 AC_PATH_XTRA
1618
1619 dnl --------------------------------------------------------------------------
1620 dnl CHECKING FOR HEADER FILES
1621 dnl --------------------------------------------------------------------------
1622 AC_CHECK_HEADERS( \
1623    assert.h \
1624    fcntl.h \
1625    grp.h \
1626    pwd.h \
1627    libc.h \
1628    limits.h \
1629    stdarg.h \
1630    stdlib.h \
1631    stdint.h \
1632    string.h \
1633    strings.h \
1634    termios.h \
1635    termcap.h \
1636    term.h \
1637    unistd.h \
1638    sys/bitypes.h \
1639    sys/byteorder.h \
1640    sys/ioctl.h \
1641    sys/select.h \
1642    sys/socket.h \
1643    sys/sockio.h \
1644    sys/stat.h \
1645    sys/time.h \
1646    sys/types.h \
1647    arpa/nameser.h \
1648    resolv.h \
1649    mtio.h \
1650    sys/mtio.h \
1651    sys/tape.h \
1652    regex.h \
1653 )
1654 AC_HEADER_STDC
1655 AC_HEADER_MAJOR
1656 AC_HEADER_DIRENT
1657 AC_HEADER_STAT
1658 AC_HEADER_SYS_WAIT
1659 AC_HEADER_TIME
1660 AC_STRUCT_ST_BLKSIZE
1661 AC_STRUCT_ST_BLOCKS
1662 AC_STRUCT_TIMEZONE
1663
1664 dnl --------------------------------------------------------------------------
1665 dnl Check for utime.h structure 
1666 dnl --------------------------------------------------------------------------
1667 AC_CACHE_CHECK(for utime.h, ba_cv_header_utime_h,
1668    [
1669        AC_TRY_COMPILE(
1670           [
1671               #include <sys/types.h>
1672               #include <utime.h>
1673           ], [
1674               struct utimbuf foo
1675           ], [
1676               ba_cv_header_utime_h=yes
1677           ], [
1678               ba_cv_header_utime_h=no
1679           ]
1680        )
1681    ]
1682 )
1683 test $ba_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H, 1, [Set if utime.h exists])
1684
1685 dnl --------------------------------------------------------------------------
1686 dnl Check for socklen_t
1687 dnl --------------------------------------------------------------------------
1688 AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
1689    [
1690        AC_TRY_COMPILE(
1691           [
1692               #include <sys/types.h>
1693               #include <sys/socket.h>
1694           ], [
1695               socklen_t x
1696           ], [
1697              ba_cv_header_socklen_t=yes
1698           ], [
1699              ba_cv_header_socklen_t=no
1700           ]
1701        )
1702    ]
1703 )
1704 test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T)
1705
1706 dnl --------------------------------------------------------------------------
1707 dnl Check for bigendian
1708 dnl --------------------------------------------------------------------------
1709 AC_CACHE_CHECK([for bigendian], ba_cv_bigendian,
1710    [
1711        AC_TRY_RUN(
1712           [
1713               main(){long a=1L; char *p=(char *)&a; exit(*p);}
1714           ], [
1715              ba_cv_bigendian=yes
1716           ], [
1717              ba_cv_bigendian=no
1718           ], [
1719              ba_cv_bigendian=no
1720           ]
1721        )
1722    ]
1723 )
1724 test $ba_cv_bigendian = yes && AC_DEFINE(HAVE_BIGENDIAN)
1725
1726 dnl --------------------------------------------------------------------------
1727 dnl Check for typeof()
1728 dnl --------------------------------------------------------------------------
1729 AC_LANG_PUSH(C++)
1730 AC_CACHE_CHECK(for typeof, ba_cv_have_typeof,
1731    [
1732        AC_TRY_RUN(
1733           [
1734               main(){char *a = 0; a = (typeof a)a;}
1735           ], [
1736               ba_cv_have_typeof=yes
1737           ], [
1738               ba_cv_have_typeof=no
1739           ], [
1740               ba_cv_have_typeof=no
1741           ]
1742        )
1743    ]
1744 )
1745 test $ba_cv_have_typeof = yes && AC_DEFINE([HAVE_TYPEOF], 1, [Defind to 1 if compiler has typeof])
1746 AC_LANG_POP(C++)
1747
1748 AC_C_CONST
1749
1750 dnl --------------------------------------------------------------------------
1751 dnl CHECKING FOR FILESYSTEM TYPE
1752 dnl --------------------------------------------------------------------------
1753 AC_MSG_CHECKING(how to get filesystem type)
1754 fstype=no
1755 # The order of these tests is important.
1756 AC_TRY_CPP(
1757    [
1758        #include <sys/statvfs.h>
1759        #include <sys/fstyp.h>
1760    ],
1761    AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4
1762 )
1763 if test $fstype = no; then
1764    AC_TRY_CPP(
1765       [
1766           #include <sys/statfs.h>
1767           #include <sys/fstyp.h>
1768       ],
1769       AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3
1770    )
1771 fi
1772 if test $fstype = no; then
1773    AC_TRY_CPP(
1774       [
1775           #include <sys/statfs.h>
1776           #include <sys/vmount.h>
1777       ],
1778       AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX
1779    )
1780 fi
1781 if test $fstype = no; then  
1782    AC_TRY_CPP(
1783       [
1784           #include <mntent.h>
1785       ],
1786       AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD
1787    )
1788 fi
1789 if test $fstype = no; then  
1790    AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
1791 fi
1792 if test $fstype = no; then  
1793    AC_TRY_CPP(
1794       [
1795           #include <sys/mount.h>
1796           #include <sys/fs_types.h>
1797       ],
1798       AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix
1799    )
1800 fi
1801 AC_MSG_RESULT($fstype)
1802
1803 AC_CHECK_HEADER(sys/statvfs.h, [ AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Defines if your system have the sys/statvfs.h header file])] , )
1804
1805 dnl --------------------------------------------------------------------------
1806 dnl CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
1807 dnl --------------------------------------------------------------------------
1808 AC_TYPE_SIGNAL
1809 SIGNAL_CHECK
1810 AC_TYPE_MODE_T
1811 AC_TYPE_UID_T
1812 AC_TYPE_SIZE_T
1813 AC_TYPE_PID_T
1814 AC_TYPE_OFF_T
1815 AC_CHECK_TYPE(ino_t, unsigned long)
1816 AC_CHECK_TYPE(dev_t, unsigned long)
1817 AC_CHECK_TYPE(daddr_t, long)
1818 AC_CHECK_TYPE(major_t, int)
1819 AC_CHECK_TYPE(minor_t, int)
1820 AC_CHECK_TYPE(ssize_t, int)
1821 AC_STRUCT_ST_BLOCKS
1822 AC_STRUCT_ST_RDEV
1823 AC_STRUCT_TM
1824 AC_C_CONST
1825
1826 AC_CHECK_SIZEOF(char, 1)
1827 AC_CHECK_SIZEOF(short int, 2)
1828 AC_CHECK_SIZEOF(int, 4)
1829 AC_CHECK_SIZEOF(long int, 4)
1830 AC_CHECK_SIZEOF(long long int, 8)
1831 AC_CHECK_SIZEOF(int *, 4)
1832
1833 dnl Check for sys/types.h types
1834 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int,
1835    [
1836        AC_TRY_COMPILE(
1837           [
1838               #include <sys/types.h>
1839           ], [
1840               u_int a; a = 1;
1841           ], [
1842               ac_cv_have_u_int="yes"
1843           ], [
1844               ac_cv_have_u_int="no"
1845           ]
1846        )
1847    ]
1848 )
1849 if test "x$ac_cv_have_u_int" = "xyes" ; then
1850    AC_DEFINE(HAVE_U_INT)
1851    have_u_int=1
1852 fi
1853
1854 AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t,
1855    [
1856        AC_TRY_COMPILE(
1857           [
1858               #include <sys/types.h>
1859           ], [
1860               intmax_t a; a = 1;
1861           ], [
1862               ac_cv_have_intmax_t="yes"
1863           ], [ 
1864               AC_TRY_COMPILE(
1865                  [
1866                      #include <stdint.h>
1867                  ], [
1868                      intmax_t a; a = 1;
1869                  ], [
1870                      ac_cv_have_intmax_t="yes"
1871                  ], [
1872                      ac_cv_have_intmax_t="no"
1873                  ]
1874               )
1875           ]
1876        )       
1877    ]
1878 )
1879 if test "x$ac_cv_have_intmax_t" = "xyes" ; then
1880    AC_DEFINE(HAVE_INTMAX_T)
1881    have_intmax_t=1
1882 fi
1883
1884 AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t,
1885    [
1886        AC_TRY_COMPILE(
1887           [
1888               #include <sys/types.h>
1889           ], [
1890               u_intmax_t a; a = 1;
1891           ], [
1892               ac_cv_have_u_intmax_t="yes"
1893           ], [ 
1894               AC_TRY_COMPILE(
1895                  [
1896                      #include <stdint.h>
1897                  ], [
1898                     u_intmax_t a; a = 1;
1899                  ], [
1900                     ac_cv_have_u_intmax_t="yes"
1901                  ], [
1902                     ac_cv_have_u_intmax_t="no"
1903                  ]
1904               )
1905           ]
1906        )
1907    ]
1908 )
1909 if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
1910    AC_DEFINE(HAVE_U_INTMAX_T)
1911    have_u_intmax_t=1
1912 fi
1913
1914 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t,
1915    [
1916        AC_TRY_COMPILE(
1917           [
1918               #include <sys/types.h>
1919           ], [
1920               int8_t a; int16_t b; int32_t c; a = b = c = 1;
1921           ], [
1922               ac_cv_have_intxx_t="yes"
1923           ], [
1924               ac_cv_have_intxx_t="no"
1925           ]
1926        )
1927    ]
1928 )
1929 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1930    AC_DEFINE(HAVE_INTXX_T)
1931    have_intxx_t=1
1932 fi
1933    
1934 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t,
1935    [
1936        AC_TRY_COMPILE(
1937           [
1938               #include <sys/types.h>
1939           ], [
1940               int64_t a; a = 1;
1941           ], [
1942               ac_cv_have_int64_t="yes"
1943           ], [
1944               ac_cv_have_int64_t="no"
1945           ]
1946        )
1947    ]
1948 )
1949 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1950    AC_DEFINE(HAVE_INT64_T)
1951    have_int64_t=1
1952 fi
1953    
1954 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t,
1955    [
1956        AC_TRY_COMPILE(
1957           [
1958               #include <sys/types.h>
1959           ], [
1960               u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;
1961           ], [
1962              ac_cv_have_u_intxx_t="yes"
1963           ], [
1964              ac_cv_have_u_intxx_t="no"
1965           ]
1966        )
1967    ]
1968 )
1969 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1970    AC_DEFINE(HAVE_U_INTXX_T)
1971    have_u_intxx_t=1
1972 fi
1973
1974 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t,
1975    [
1976        AC_TRY_COMPILE(
1977           [
1978               #include <sys/types.h>
1979           ], [
1980               u_int64_t a; a = 1;
1981           ], [
1982              ac_cv_have_u_int64_t="yes"
1983           ], [
1984              ac_cv_have_u_int64_t="no"
1985           ]
1986        )
1987    ]
1988 )
1989 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1990    AC_DEFINE(HAVE_U_INT64_T)
1991    have_u_int64_t=1
1992 fi
1993
1994 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1995     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1996 then
1997    AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1998    AC_TRY_COMPILE(
1999       [
2000           #include <sys/bitypes.h>
2001       ], [
2002           int8_t a; int16_t b; int32_t c;
2003           u_int8_t e; u_int16_t f; u_int32_t g;
2004           a = b = c = e = f = g = 1;
2005       ], [
2006           AC_DEFINE(HAVE_U_INTXX_T)
2007           AC_DEFINE(HAVE_INTXX_T)
2008           AC_DEFINE(HAVE_SYS_BITYPES_H)
2009           AC_MSG_RESULT(yes)
2010       ], [
2011           AC_MSG_RESULT(no)
2012       ]
2013    ) 
2014 fi
2015
2016 if test -z "$have_u_intxx_t" ; then
2017    AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t,
2018       [
2019           AC_TRY_COMPILE(
2020              [
2021                  #include <sys/types.h>
2022              ], [
2023                  uint8_t a; uint16_t b; 
2024                  uint32_t c; a = b = c = 1;
2025              ], [
2026                 ac_cv_have_uintxx_t="yes"
2027              ], [
2028                 ac_cv_have_uintxx_t="no"
2029              ]
2030           )
2031       ]
2032    )
2033    if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
2034       AC_DEFINE(HAVE_UINTXX_T)
2035    fi
2036 fi
2037
2038 if (test -z "$have_u_int64_t" || test -z "$have_int64_t" && \
2039     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2040 then
2041    AC_MSG_CHECKING([for int64_t and u_int64_t types in sys/bitypes.h])
2042    AC_TRY_COMPILE(
2043       [
2044           #include <sys/bitypes.h>
2045       ], [
2046           int64_t a; u_int64_t b; 
2047           a = b = 1;
2048       ], [
2049           AC_DEFINE(HAVE_U_INT64_T)
2050           AC_DEFINE(HAVE_INT64_T)
2051           AC_MSG_RESULT(yes)
2052       ], [
2053           AC_MSG_RESULT(no)
2054       ]
2055    ) 
2056 fi
2057
2058 if (test -z "$have_uintxx_t" && \
2059     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2060 then
2061    AC_MSG_CHECKING([for uintXX_t types in sys/bitypes.h])
2062    AC_TRY_COMPILE(
2063       [
2064           #include <sys/bitypes.h>
2065       ], [
2066           uint8_t a; uint16_t b; 
2067           uint32_t c; a = b = c = 1;
2068       ], [
2069           AC_DEFINE(HAVE_UINTXX_T)
2070           AC_MSG_RESULT(yes)
2071       ], [
2072           AC_MSG_RESULT(no)
2073       ]
2074    ) 
2075 fi
2076
2077 dnl --------------------------------------------------------------------------
2078 dnl CHECKING FOR REQUIRED LIBRARY FUNCTIONS
2079 dnl --------------------------------------------------------------------------
2080 AC_CHECK_FUNCS( \
2081    fork \
2082    getcwd \
2083    gethostname \
2084    getpid \
2085    gettimeofday \
2086    setpgid \
2087    setpgrp \
2088    setsid \
2089    signal \
2090    strerror \
2091    strncmp \
2092    strncpy \
2093    vfprintf \
2094    ,,
2095    [echo 'configure: cannot find needed function.'; exit 1]
2096 )
2097
2098 AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
2099 AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)])
2100 AC_CHECK_FUNCS(posix_fadvise)
2101 AC_CHECK_FUNCS(fdatasync)
2102
2103 AC_CHECK_FUNCS(chflags) 
2104
2105 AC_CHECK_FUNCS(snprintf vsnprintf gethostid fseeko)
2106
2107 AC_CACHE_CHECK(for va_copy, ba_cv_va_copy,
2108    [
2109        AC_TRY_LINK(
2110           [
2111               #include <stdarg.h>
2112               void use_va_copy(va_list args){va_list args2; va_copy(args2,args); va_end(args2);}
2113               void call_use_va_copy(int junk,...){va_list args; va_start(args,junk); use_va_copy(args); va_end(args);}
2114           ], [
2115               call_use_va_copy(1,2,3)
2116           ], [
2117               ba_cv_va_copy=yes,
2118           ], [
2119               ba_cv_va_copy=no
2120           ]
2121        )
2122    ]
2123 )
2124 test $ba_cv_va_copy = yes && AC_DEFINE(HAVE_VA_COPY, 1, [Set if va_copy exists])
2125
2126 dnl --------------------------------------------------------------------------
2127 dnl CHECKING FOR THREAD SAFE FUNCTIONS
2128 dnl --------------------------------------------------------------------------
2129 AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
2130
2131 # If resolver functions are not in libc check for -lnsl or -lresolv.
2132 AC_CHECK_FUNC(gethostbyname_r,
2133     AC_MSG_RESULT(using libc's resolver),
2134     AC_CHECK_LIB(nsl,gethostbyname_r)
2135     AC_CHECK_LIB(resolv,gethostbyname_r))
2136
2137 AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
2138 AC_CHECK_FUNCS(inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
2139 AC_CHECK_FUNCS(gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2)])
2140
2141 dnl ----------------------------
2142 dnl check sa_len of sockaddr
2143 dnl ----------------------------
2144 AC_CACHE_CHECK(for struct sockaddr has a sa_len field, ac_cv_struct_sockaddr_sa_len,
2145    [
2146        AC_TRY_COMPILE(
2147           [
2148               #include <sys/socket.h>
2149           ], [
2150               struct sockaddr s; s.sa_len;
2151           ], [
2152              ac_cv_struct_sockaddr_sa_len=yes
2153           ], [ac_cv_struct_sockaddr_sa_len=no
2154           ]
2155        )
2156    ]
2157 )
2158
2159 if test $ac_cv_struct_sockaddr_sa_len = yes; then
2160   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
2161 fi
2162
2163 AC_FUNC_STRFTIME
2164 AC_FUNC_VPRINTF
2165 AC_FUNC_ALLOCA
2166 AC_FUNC_GETMNTENT
2167 AC_FUNC_CLOSEDIR_VOID
2168 AC_FUNC_SETPGRP             dnl check for BSD setpgrp.
2169 # AC_FUNC_FNMATCH    dnl use local version
2170
2171 AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"])
2172
2173 AC_CHECK_LIB(sun, getpwnam)
2174
2175 AC_CHECK_HEADERS(zlib.h)
2176 AC_CHECK_LIB(z, deflate, [FDLIBS="-lz"])
2177 have_zlib=no
2178 if test x$FDLIBS = x-lz; then
2179    AC_DEFINE(HAVE_LIBZ)
2180    have_zlib=yes
2181 fi
2182
2183 dnl
2184 dnl Check for ACL libraries
2185 dnl
2186 have_acl=no
2187 AC_CHECK_HEADER(sys/acl.h)
2188 AC_CHECK_FUNC(acl_get_file, [have_acl=yes],
2189    [
2190        AC_CHECK_LIB(acl, acl_get_file,
2191           [
2192               have_acl=yes;
2193               FDLIBS="-lacl $FDLIBS"
2194           ], [
2195               AC_CHECK_LIB(sec, acltotext,
2196                  [
2197                      have_acl=yes;
2198                      FDLIBS="-lsec $FDLIBS"
2199                  ]
2200               )
2201           ]
2202        )
2203    ]
2204 )
2205 if test $have_acl = yes; then
2206    AC_DEFINE(HAVE_ACL)
2207 fi
2208
2209 dnl Check for pthread libraries
2210 PTHREAD_LIB=""
2211 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
2212    [
2213        AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
2214           [
2215               AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
2216                  [
2217                      AC_CHECK_FUNC(pthread_create)
2218                  ]
2219               )
2220           ]
2221        )
2222    ]
2223 )
2224
2225 AC_SUBST(FDLIBS)
2226 AC_DEFINE(FDLIBS)
2227
2228 CFLAGS=${CFLAGS--O}
2229
2230 if test x$have_gcc = xyes ; then
2231    CPPFLAGS="$CPPFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
2232    CFLAGS="$CFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
2233 fi
2234 LDFLAGS=${LDFLAGS--O}
2235 DB_LIBS="${SQL_LFLAGS}"
2236 CPPFLAGS="$CPPFLAGS"
2237 CFLAGS="$CFLAGS"
2238 AC_SUBST(DEBUG)
2239 AC_SUBST(DINCLUDE)
2240 AC_SUBST(CFLAGS)
2241 AC_SUBST(CPPFLAGS)
2242 AC_SUBST(LDFLAGS)
2243 AC_SUBST(X_CFLAGS)
2244 AC_SUBST(DEFS)
2245 AC_SUBST(LIBS)
2246 AC_SUBST(DLIB)
2247 AC_SUBST(DB_LIBS)
2248 AC_SUBST(X_LIBS)
2249 AC_SUBST(X_EXTRA_LIBS)
2250 AC_SUBST(WCFLAGS)
2251 AC_SUBST(WLDFLAGS)
2252 AC_SUBST(WRAPLIBS)
2253
2254 dnl extra configurable objects
2255 OBJLIST=
2256 AC_SUBST(OBJLIST)
2257
2258 lld="lld"
2259 llu="llu"
2260
2261 WCFLAGS=
2262 WLDFLAGS=
2263
2264 dnl
2265 dnl Finally we set appropriate distribution specific
2266 dnl  variables and defaults
2267 dnl
2268 dnl PFILES are platform specific files
2269 PFILES="platforms/Makefile"
2270 PSCMD="ps -e"
2271 WIN32=
2272 MACOSX=
2273 hostname=`uname -n | cut -d '.' -f 1`
2274 if test x${hostname} = x ; then
2275    hostname="localhost"
2276 fi
2277 case "$DISTNAME" in
2278 aix)
2279    DISTVER=`uname -r`
2280    PSCMD="ps -e -o pid,comm"
2281    PFILES="${PFILES} \
2282       platforms/aix/Makefile"
2283    TAPEDRIVE="/dev/rmt0.1" 
2284   ;;     
2285 alpha)
2286    DISTVER=`uname -r`
2287    PTHREAD_LIB="-lpthread -lexc"
2288    if test "${CC}" = "gcc" ; then
2289       lld="lld"
2290       llu="llu"
2291    else
2292       lld="ld"
2293       llu="lu"
2294    fi
2295    TAPEDRIVE="/dev/nrmt0"
2296   ;;
2297 bsdi)
2298    DISTVER=`uname -a |awk '{print $3}'`
2299    TAPEDRIVE="/dev/nrmt0"
2300    PTHREAD_LIB="-pthread"
2301    CFLAGS="${CFLAGS} -pthread"
2302    PSCMD="ps -ax -o pid,command"
2303    lld="qd"
2304    llu="qu"
2305    PFILES="${PFILES} \
2306        platforms/bsdi/Makefile \
2307        platforms/bsdi/bacula-fd \
2308        platforms/bsdi/bacula-sd \
2309        platforms/bsdi/bacula-dir"
2310    largefile_support="yes"
2311   ;;
2312 cygwin)
2313    DISTVER=`uname -a |awk '{print $3}'`
2314    TAPEDRIVE="/dev/nrst0"
2315    WIN32=win32
2316    WCFLAGS="-mwindows"
2317    WLDFLAGS="-mwindows"
2318   ;;
2319 darwin)
2320    DISTVER=`uname -r`
2321    TAPEDRIVE="/dev/nst0"
2322    PSCMD="ps -e -o pid,command"
2323    MACOSX=macosx
2324    PFILES="${PFILES} \
2325       platforms/darwin/Makefile"
2326   ;;
2327 debian)
2328    dnl Make sure hostname is resolved
2329    ping -c 1 $hostname 2>&1 1>/dev/null
2330    if test ! $? = 0; then
2331       hostname="localhost"
2332    fi
2333    if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then
2334       DISTNAME="ubuntu"
2335    fi
2336    DISTVER=`cat /etc/debian_version`
2337    if test -f /etc/lsb-release ; then
2338       . /etc/lsb-release
2339       if test "x$DISTRIB_ID" != "x" ; then
2340          DISTNAME=$DISTRIB_ID
2341       fi
2342       if test "x$DISTRIB_RELEASE" != "x" ; then
2343          DISTVER=$DISTRIB_RELEASE
2344       fi
2345    fi
2346    if test "$DISTNAME" = "Ubuntu" ; then
2347       DISTNAME="ubuntu"
2348    fi
2349    TAPEDRIVE="/dev/nst0"
2350    PSCMD="ps -e -o pid,command"
2351    if test "$DISTNAME" = "ubuntu" ; then
2352       PFILES="${PFILES} \
2353          platforms/ubuntu/Makefile \
2354          platforms/ubuntu/bacula-fd \
2355          platforms/ubuntu/bacula-sd \
2356          platforms/ubuntu/bacula-dir"
2357    else 
2358       PFILES="${PFILES} \
2359          platforms/debian/Makefile \
2360          platforms/debian/bacula-fd \
2361          platforms/debian/bacula-sd \
2362          platforms/debian/bacula-dir"
2363    fi
2364   ;;
2365 freebsd)
2366    dnl Make sure hostname is resolved
2367    ping -c 1 $hostname 2>&1 1>/dev/null
2368    if test ! $? = 0; then
2369       hostname="localhost"
2370    fi
2371    DISTVER=`uname -a |awk '{print $3}'`
2372    VER=`echo $DISTVER | cut -c 1`
2373    if test x$VER = x4 ; then
2374       PTHREAD_LIB="${PTHREAD_LIBS:--pthread}"
2375       CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS:--pthread}"
2376    fi
2377    lld="qd"
2378    llu="qu"
2379    TAPEDRIVE="/dev/nrsa0"
2380    PSCMD="ps -ax -o pid,command"
2381    PFILES="${PFILES} \
2382        platforms/freebsd/Makefile \
2383        platforms/freebsd/bacula-fd \
2384        platforms/freebsd/bacula-sd \
2385        platforms/freebsd/bacula-dir"
2386    largefile_support="yes"
2387   ;;
2388 hpux)
2389    PSCMD="UNIX95=1; ps -e -o pid,comm"
2390    CFLAGS="${CFLAGS} -D_XOPEN_SOURCE_EXTENDED=1"
2391    DISTVER=`uname -r`
2392    TAPEDRIVE="/dev/rmt/0hnb"
2393    PTHREAD_LIB="-lpthread"
2394    AC_DEFINE([_INCLUDE_LONGLONG])
2395   ;;
2396 irix)
2397    DISTVER=`uname -r`
2398    TAPEDRIVE="/dev/rmt/0cbn"
2399    PSCMD="ps -e -o pid,comm"
2400    PFILES="${PFILES} \
2401        platforms/irix/Makefile \
2402        platforms/irix/bacula-fd \
2403        platforms/irix/bacula-sd \
2404        platforms/irix/bacula-dir"
2405   ;;
2406 netbsd)
2407    DISTVER=`uname -a |awk '{print $3}'`
2408    lld="qd"
2409    llu="qu"
2410    TAPEDRIVE="/dev/nrst0"
2411    PSCMD="ps -ax -o pid,command"
2412    PTHREAD_LIB="-pthread"
2413    CFLAGS="${CFLAGS} -pthread"
2414   ;;
2415 openbsd)
2416    DISTVER=`uname -a |awk '{print $3}'`
2417    lld="qd"
2418    llu="qu"
2419    TAPEDRIVE="/dev/nrst0"
2420    PSCMD="ps -ax -o pid,command"
2421    PTHREAD_LIB="-pthread"
2422    CFLAGS="${CFLAGS} -pthread"
2423    PFILES="${PFILES} \
2424        platforms/openbsd/Makefile \
2425        platforms/openbsd/bacula-fd \
2426        platforms/openbsd/bacula-sd \
2427        platforms/openbsd/bacula-dir"
2428   ;;
2429 redhat)
2430    dnl Make sure hostname is resolved
2431    ping -c 1 $hostname 2>&1 1>/dev/null
2432    if test ! $? = 0; then
2433       hostname="localhost"
2434    fi
2435    if test -f /etc/whitebox-release ; then
2436       f=/etc/whitebox-release
2437    else
2438       f=/etc/redhat-release
2439    fi
2440    if test `cat $f | grep release |\
2441          cut -f 3 -d ' '`x = "Enterprise"x ; then
2442       DISTVER="Enterprise "`cat $f | grep release |\
2443           cut -f 6 -d ' '`
2444    else
2445        DISTVER=`cat /etc/redhat-release | grep release |\
2446            cut -f 5 -d ' '`
2447    fi
2448    TAPEDRIVE="/dev/nst0"
2449    PSCMD="ps -e -o pid,command"
2450    PFILES="${PFILES} \
2451        platforms/redhat/Makefile \
2452        platforms/redhat/bacula-fd \
2453        platforms/redhat/bacula-sd \
2454        platforms/redhat/bacula-dir \
2455        platforms/redhat/bacula.spec \
2456        "
2457   ;;
2458 mandrake)
2459    dnl Make sure hostname is resolved
2460    ping -c 1 $hostname 2>&1 1>/dev/null
2461    if test ! $? = 0; then
2462       hostname="localhost"
2463    fi
2464    DISTVER=`cat /etc/mandrake-release | grep release |\
2465       cut -f 5 -d ' '`
2466    TAPEDRIVE="/dev/nst0"
2467    PSCMD="ps -e -o pid,command"
2468    PFILES="${PFILES} \
2469        platforms/mandrake/Makefile \
2470        platforms/mandrake/bacula-fd \
2471        platforms/mandrake/bacula-sd \
2472        platforms/mandrake/bacula-dir \
2473        platforms/mandrake/bacula.spec \
2474        "
2475   ;;
2476 gentoo)
2477    dnl Make sure hostname is resolved
2478    ping -c 1 $hostname 2>&1 1>/dev/null
2479    if test ! $? = 0; then
2480       hostname="localhost"
2481    fi
2482    DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
2483    TAPEDRIVE="/dev/nst0"
2484    PSCMD="ps -e -o pid,command"
2485    PFILES="${PFILES} \
2486        platforms/gentoo/Makefile \
2487     platforms/gentoo/bacula-init \
2488        platforms/gentoo/bacula-fd \
2489        platforms/gentoo/bacula-sd \
2490        platforms/gentoo/bacula-dir"
2491   ;;
2492 slackware)
2493    dnl Make sure hostname is resolved
2494    ping -c 1 $hostname 2>&1 1>/dev/null
2495    if test ! $? = 0; then
2496       hostname="localhost"
2497    fi
2498    DISTVER=`cat /etc/slackware-version`
2499    TAPEDRIVE="/dev/nst0"
2500    PSCMD="ps -e -o pid,command"
2501    PFILES="${PFILES} \
2502        platforms/slackware/Makefile \
2503        platforms/slackware/rc.bacula-fd \
2504        platforms/slackware/rc.bacula-sd \
2505        platforms/slackware/rc.bacula-dir\
2506        platforms/slackware/functions.bacula"
2507   ;;
2508 solaris)
2509    DISTVER=`uname -r`
2510    TAPEDRIVE="/dev/rmt/0cbn"
2511    PSCMD="ps -e -o pid,comm"
2512    PFILES="${PFILES} \
2513        platforms/solaris/Makefile \
2514        platforms/solaris/bacula-fd \
2515        platforms/solaris/bacula-sd \
2516        platforms/solaris/bacula-dir"
2517    if test x$DISTVER = x5.6 ; then
2518        AC_DEFINE(HAVE_OLD_SOCKOPT)
2519    fi
2520    LIBS="$LIBS -lresolv"
2521   ;;
2522 suse)
2523    dnl Make sure hostname is resolved
2524    ping -c 1 $hostname 2>&1 1>/dev/null
2525    if test ! $? = 0; then
2526       hostname="localhost"
2527    fi
2528    DISTVER=`cat /etc/SuSE-release |grep VERSION|\
2529        cut -f 3 -d ' '`
2530    TAPEDRIVE="/dev/nst0"
2531    PSCMD="ps -e -o pid,command"
2532    PFILES="${PFILES} \
2533        platforms/suse/Makefile \
2534        platforms/suse/bacula-fd \
2535        platforms/suse/bacula-sd \
2536        platforms/suse/bacula-dir \
2537        platforms/suse/bacula \
2538        platforms/suse/bacula.spec"
2539   ;;
2540 suse5)
2541    dnl Make sure hostname is resolved
2542    ping -c 1 $hostname 2>&1 1>/dev/null
2543    if test ! $? = 0; then
2544       hostname="localhost"
2545    fi
2546    DISTNAME=suse
2547    DISTVER=5.x
2548    TAPEDRIVE="/dev/nst0"
2549    PSCMD="ps -e -o pid,command"
2550    PFILES="${PFILES} \
2551        platforms/suse/Makefile \
2552        platforms/suse/bacula-fd \
2553        platforms/suse/bacula-sd \
2554        platforms/suse/bacula-dir"
2555   ;;
2556 unknown)
2557    DISTVER=unknown
2558    TAPEDRIVE="/dev/nst0"
2559   ;;
2560 *)
2561   echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
2562   ;;
2563 esac  
2564
2565 AC_SUBST(hostname)
2566
2567 LIBS="$PTHREAD_LIB $LIBS"
2568
2569 AC_DEFINE_UNQUOTED(lld, "$lld")
2570 AC_DEFINE_UNQUOTED(llu, "$llu")
2571 AC_SUBST(TAPEDRIVE)
2572 AC_SUBST(PSCMD)
2573 AC_SUBST(WIN32)
2574 AC_SUBST(MACOSX)
2575 AC_SUBST(DISTNAME)
2576 AC_SUBST(DISTVER)
2577
2578 dnl common parts of the Makefile
2579 MCOMMON=./autoconf/Make.common
2580 AC_SUBST_FILE(MCOMMON)
2581
2582 dnl Insanity check
2583 if test "x${subsysdir}" = "x${sbindir}" ; then
2584    echo " "
2585    echo " "
2586    echo "You have set both --sbindir and --with-subsys-dir"
2587    echo "  equal to: ${subsysdir} "
2588    echo "This is not permitted. Please reconfigure."
2589    echo " "
2590    echo "Aborting configuration ..."
2591    echo " "
2592    echo " "
2593    exit 1
2594 fi 
2595
2596 AC_OUTPUT([autoconf/Make.common \
2597            Makefile \
2598            manpages/Makefile \
2599            scripts/startmysql \
2600            scripts/stopmysql \
2601            scripts/btraceback \
2602            scripts/startit \
2603            scripts/stopit \
2604            scripts/bconsole \
2605            scripts/gconsole \
2606            scripts/bacula \
2607            scripts/bacula-ctl-dir \
2608            scripts/bacula-ctl-fd \
2609            scripts/bacula-ctl-sd \
2610            scripts/devel_bacula \
2611            scripts/Makefile \
2612            scripts/logrotate \
2613            scripts/bacula.desktop.gnome1 \
2614            scripts/bacula.desktop.gnome2 \
2615            scripts/bacula.desktop.gnome1.consolehelper \
2616            scripts/bacula.desktop.gnome2.consolehelper \
2617            scripts/bacula.desktop.gnome1.xsu \
2618            scripts/bacula.desktop.gnome2.xsu \
2619            scripts/bgnome-console.console_apps \
2620            scripts/mtx-changer \
2621            scripts/disk-changer \
2622            scripts/dvd-handler \
2623            scripts/dvd-simulator \
2624            scripts/bacula-tray-monitor.desktop \
2625            scripts/logwatch/Makefile \
2626            scripts/logwatch/logfile.bacula.conf \
2627            scripts/wxconsole.console_apps \
2628            scripts/wxconsole.desktop.consolehelper \
2629            scripts/wxconsole.desktop.xsu \
2630            scripts/bat.desktop \
2631            scripts/bat.desktop.xsu \
2632            scripts/bat.desktop.consolehelper \
2633            scripts/bat.console_apps \
2634            src/Makefile \
2635            src/host.h \
2636            src/console/Makefile \
2637            src/console/bconsole.conf \
2638            src/gnome2-console/Makefile \
2639            src/gnome2-console/bgnome-console.conf \
2640            src/qt-console/bat.conf \
2641            src/qt-console/bat.pro \
2642            src/qt-console/bat.pro.mingw32 \
2643            src/qt-console/install_conf_file \
2644            src/wx-console/Makefile \
2645            src/wx-console/bwx-console.conf \
2646            src/tray-monitor/Makefile \
2647            src/tray-monitor/tray-monitor.conf \
2648            src/dird/Makefile \
2649            src/dird/bacula-dir.conf \
2650            src/lib/Makefile \
2651            src/stored/Makefile \
2652            src/stored/bacula-sd.conf \
2653            src/filed/Makefile \
2654            src/filed/bacula-fd.conf \
2655            src/cats/Makefile \
2656            src/cats/make_catalog_backup \
2657            src/cats/delete_catalog_backup \
2658            src/cats/create_postgresql_database \
2659            src/cats/update_postgresql_tables \
2660            src/cats/make_postgresql_tables \
2661            src/cats/grant_postgresql_privileges \
2662            src/cats/drop_postgresql_tables \
2663            src/cats/drop_postgresql_database \
2664            src/cats/create_mysql_database \
2665            src/cats/update_mysql_tables \
2666            src/cats/make_mysql_tables \
2667            src/cats/grant_mysql_privileges \
2668            src/cats/drop_mysql_tables \
2669            src/cats/drop_mysql_database \
2670            src/cats/create_sqlite_database \
2671            src/cats/update_sqlite_tables \
2672            src/cats/make_sqlite_tables \
2673            src/cats/grant_sqlite_privileges \
2674            src/cats/drop_sqlite_tables \
2675            src/cats/drop_sqlite_database \
2676            src/cats/create_sqlite3_database \
2677            src/cats/update_sqlite3_tables \
2678            src/cats/make_sqlite3_tables \
2679            src/cats/grant_sqlite3_privileges \
2680            src/cats/drop_sqlite3_tables \
2681            src/cats/drop_sqlite3_database \
2682            src/cats/sqlite \
2683            src/cats/mysql \
2684            src/cats/create_bdb_database \
2685            src/cats/update_bdb_tables \
2686            src/cats/make_bdb_tables \
2687            src/cats/grant_bdb_privileges \
2688            src/cats/drop_bdb_tables \
2689            src/cats/drop_bdb_database \
2690            src/cats/create_bacula_database \
2691            src/cats/update_bacula_tables \
2692            src/cats/grant_bacula_privileges \
2693            src/cats/make_bacula_tables \
2694            src/cats/drop_bacula_tables \
2695            src/cats/drop_bacula_database \
2696            src/findlib/Makefile \
2697            src/tools/Makefile \
2698            src/plugins/fd/Makefile \
2699            po/Makefile.in \
2700            updatedb/update_mysql_tables_10_to_11 \
2701            updatedb/update_sqlite3_tables_10_to_11 \
2702            updatedb/update_postgresql_tables_10_to_11 \
2703            updatedb/update_sqlite_tables_10_to_11 \
2704            $PFILES ],  
2705      [ ]
2706 )
2707
2708 if test "${support_bat}" = "yes" ; then
2709    if test "x$QMAKE" = "xnone" && test "x$QMAKEQT4" = "xnone"; then
2710       echo "Could not find qmake or qmake-qt4 in $PATH. Check your Qt installation"
2711       exit 1
2712    fi
2713
2714    QMAKEBIN="qmake"
2715
2716    if test "x$QMAKEQT4" != "xnone"; then
2717        QMAKEBIN=qmake-qt4
2718    fi
2719   
2720    cd src/qt-console
2721    chmod 755 install_conf_file build-depkgs-qt-console
2722    echo "Creating bat Makefile"
2723    $QMAKEBIN
2724    make clean
2725    cd ${BUILD_DIR}
2726 fi
2727
2728 dnl
2729 dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
2730 dnl requires gcc).  If it's not, don't rebuild dependencies
2731 dnl
2732 if test X"$GCC" = "Xyes" ; then
2733   echo "Doing make of dependencies"
2734   ${MAKE:-make} depend
2735 fi
2736
2737 cd scripts
2738 chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
2739 chmod 755 dvd-handler dvd-simulator
2740 chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate
2741 cd ..
2742
2743 c=updatedb
2744 chmod 755 $c/update_mysql_tables_10_to_11   $c/update_sqlite3_tables_10_to_11
2745 chmod 755 $c/update_postgresql_tables_10_to_11   $c/update_sqlite_tables_10_to_11
2746
2747 c=src/cats
2748
2749 chmod 755 $c/create_bacula_database   $c/update_bacula_tables  $c/make_bacula_tables
2750 chmod 755 $c/grant_bacula_privileges  $c/drop_bacula_tables    $c/drop_bacula_database
2751
2752 chmod 755 $c/create_bdb_database      $c/update_bdb_tables     $c/make_bdb_tables
2753 chmod 755 $c/grant_bdb_privileges     $c/drop_bdb_tables       $c/drop_bdb_database
2754
2755 chmod 755 $c/create_mysql_database    $c/update_mysql_tables   $c/make_mysql_tables
2756 chmod 755 $c/grant_mysql_privileges   $c/drop_mysql_tables     $c/drop_mysql_database
2757
2758 chmod 755 $c/create_sqlite_database   $c/update_sqlite_tables  $c/make_sqlite_tables
2759 chmod 755 $c/grant_sqlite_privileges  $c/drop_sqlite_tables    $c/drop_sqlite_database
2760
2761 chmod 755 $c/create_sqlite3_database   $c/update_sqlite3_tables  $c/make_sqlite3_tables
2762 chmod 755 $c/grant_sqlite3_privileges  $c/drop_sqlite3_tables    $c/drop_sqlite3_database
2763
2764 chmod 755 $c/create_postgresql_database  $c/update_postgresql_tables $c/make_postgresql_tables
2765 chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables   $c/drop_postgresql_database
2766
2767 chmod 755 $c/make_catalog_backup $c/delete_catalog_backup
2768 chmod 755 $c/sqlite
2769 chmod 755 $c/mysql
2770
2771 chmod 755 src/win32/build-depkgs-mingw32
2772
2773 if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
2774    largefile_support="yes"
2775 fi
2776
2777 dnl Only try to find out the version number of the compiler when we know its some kind of GCC compiler
2778 if test X"$GCC" = "Xyes" ; then
2779    dnl
2780    dnl A whole lot of hand springs to get the compiler version.
2781    dnl  This is because gcc changed the output in version 3.0
2782    dnl
2783    CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 3 -d ' '`
2784    if test "x${CCVERSION}" = "x" ; then
2785       CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 1 -d ' '`
2786    fi
2787    CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
2788    if test x"${CXXVERSION}" = x ; then
2789       CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
2790    fi
2791 fi
2792
2793 if test "x${db_type}" = "xInternal" ; then
2794    echo " "
2795    echo " "
2796    echo "You have not specified either --enable-client-only or one of the"
2797    echo "  supported databases: MySQL, PostgreSQL, SQLite3, SQLite or DBI."
2798    echo "  This is not permitted. Please reconfigure."
2799    echo " "
2800    echo "Aborting the configuration ..."
2801    echo " "
2802    echo " "
2803    exit 1
2804 fi
2805
2806 echo "
2807 Configuration on `date`:
2808
2809    Host:                    ${host}${post_host} -- ${DISTNAME} ${DISTVER}
2810    Bacula version:          ${BACULA} ${VERSION} (${DATE})
2811    Source code location:    ${srcdir}
2812    Install binaries:        ${sbindir}
2813    Install libraries:       ${libdir}
2814    Install config files:    ${sysconfdir}
2815    Scripts directory:       ${scriptdir}
2816    Archive directory:       ${archivedir}
2817    Working directory:       ${working_dir}
2818    PID directory:           ${piddir}
2819    Subsys directory:        ${subsysdir}
2820    Man directory:           ${mandir}
2821    Data directory:          ${datarootdir}
2822    C Compiler:              ${CC} ${CCVERSION}
2823    C++ Compiler:            ${CXX} ${CXXVERSION}
2824    Compiler flags:          ${WCFLAGS} ${CFLAGS} 
2825    Linker flags:            ${WLDFLAGS} ${LDFLAGS}
2826    Libraries:               ${LIBS}
2827    Statically Linked Tools: ${support_static_tools}
2828    Statically Linked FD:    ${support_static_fd}
2829    Statically Linked SD:    ${support_static_sd}
2830    Statically Linked DIR:   ${support_static_dir}
2831    Statically Linked CONS:  ${support_static_cons}
2832    Database type:           ${db_type}
2833    Database port:           ${db_port}
2834    Database lib:            ${DB_LIBS}
2835    Database name:           ${db_name}
2836    Database user:           ${db_user}
2837  
2838    Job Output Email:        ${job_email}
2839    Traceback Email:         ${dump_email}
2840    SMTP Host Address:       ${smtp_host}
2841  
2842    Director Port:           ${dir_port}
2843    File daemon Port:        ${fd_port}
2844    Storage daemon Port:     ${sd_port}
2845  
2846    Director User:           ${dir_user}
2847    Director Group:          ${dir_group}
2848    Storage Daemon User:     ${sd_user}
2849    Storage DaemonGroup:     ${sd_group}
2850    File Daemon User:        ${fd_user}
2851    File Daemon Group:       ${fd_group}
2852  
2853    SQL binaries Directory   ${SQL_BINDIR}
2854  
2855    Large file support:      $largefile_support
2856    Bacula conio support:    ${got_conio} ${CONS_LIBS}
2857    readline support:        ${got_readline} ${PRTREADLINE_SRC}
2858    TCP Wrappers support:    ${TCPW_MSG} ${WRAPLIBS}
2859    TLS support:             ${support_tls}
2860    Encryption support:      ${support_crypto} 
2861    ZLIB support:            ${have_zlib}
2862    enable-smartalloc:       ${support_smartalloc} 
2863    bat support:             ${support_bat} ${QWT_LDFLAGS}
2864    enable-gnome:            ${support_gnome} ${gnome_version}
2865    enable-bwx-console:      ${support_wx_console} ${wx_version}
2866    enable-tray-monitor:     ${support_tray_monitor}
2867    client-only:             ${build_client_only}
2868    build-dird:              ${build_dird}
2869    build-stored:            ${build_stored}
2870    ACL support:             ${have_acl}
2871    Python support:          ${support_python} ${PYTHON_LIBS}
2872    Batch insert enabled:    ${support_batch_insert}
2873
2874   " > config.out
2875
2876 cat config.out