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