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