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