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