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