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