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