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