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