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