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