]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/configure.in
Tweak remove last reference to __SQL_C which is not needed 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(ncurses, tgetent, 
813     [ TERM_LIB="-lncurses" ],
814     [ AC_CHECK_LIB(termcap, tgetent, [ TERM_LIB="-ltermcap" ])
815     ])
816   ],
817   [  AC_CHECK_HEADERS(curses.h)
818      AC_CHECK_HEADER(term.h,
819        [ AC_CHECK_LIB(curses, tgetent, 
820          [ TERM_LIB="-lcurses" ] )
821        ])
822   ])
823
824
825 got_conio="no"
826 if test x$support_conio = xyes; then
827    if test x$TERM_LIB != x; then
828       CONS_LIBS=$TERM_LIB
829       CONS_OBJ="conio.o"
830       CONS_SRC="conio.c"
831       got_conio="yes"
832       support_readline=no
833       AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
834    else
835       echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " "],
836    fi
837 fi
838
839
840 dnl ---------------------------------------------------
841 dnl Check for readline support/directory (default off)
842 dnl ---------------------------------------------------
843 dnl this allows you to turn it completely off
844 AC_ARG_ENABLE(readline,
845    AC_HELP_STRING([--disable-readline], [disable readline support @<:@default=yes@:>@]),
846    [
847        if test x$enableval = xno; then
848           support_readline=no
849        fi
850    ]
851 )
852 if test x$TERM_LIB = x ; then
853    support_readline=no
854 fi
855
856 got_readline="no"
857 READLINE_SRC=
858 if test x$support_readline = xyes; then
859    AC_ARG_WITH(readline,
860       AC_HELP_STRING([--with-readline@<:@=DIR@:>@], [specify readline library directory]),
861       [
862           case "$with_readline" in
863           no)
864              :
865              ;;
866           yes|*)
867              if test -f ${with_readline}/readline.h; then
868                 CONS_INC="-I${with_readline}"
869                 CONS_LDFLAGS="-L$with_readline"
870              elif test -f ${with_readline}/include/readline/readline.h; then
871                 CONS_INC="-I${with_readline}/include/readline"
872                 CONS_LDFLAGS="-L${with_readline}/lib"
873                 with_readline="${with_readline}/include/readline"
874              else
875                 with_readline="/usr/include/readline" 
876              fi
877
878              AC_CHECK_HEADER(${with_readline}/readline.h, 
879                 [
880                     AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
881                     CONS_LIBS="-lreadline -lhistory $TERM_LIB"
882                     got_readline="yes"   
883                 ], [
884                     echo " "
885                     echo "readline.h not found. readline turned off ..."
886                     echo " "
887                 ]
888              )
889              ;;
890           esac
891       ],[
892          dnl check for standard readline library
893          AC_CHECK_HEADER(/usr/include/readline/readline.h, 
894             [
895                 AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
896                 got_readline="yes"
897                 CONS_INC="-I/usr/include/readline"
898                 CONS_LIBS="-lreadline $TERM_LIB"
899             ], [
900                 dnl Did not find standard library, so try Bacula's default
901                 AC_CHECK_HEADER(${TOP_DIR}/depkgs/readline/readline.h, 
902                     [
903                         AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
904                         got_readline="yes"   
905                         CONS_INC="-I${TOP_DIR}/depkgs/readline"
906                         CONS_LIBS="-lreadline -lhistory $TERM_LIB"
907                         CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
908                         PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
909                     ], [
910                         echo " "
911                         echo "readline.h not found. readline turned off ..."
912                         echo " "
913                     ]
914                 )
915             ]
916          )
917       ]    
918    )
919 fi
920
921 AC_SUBST(CONS_INC)
922 AC_SUBST(CONS_OBJ)
923 AC_SUBST(CONS_SRC)
924 AC_SUBST(CONS_LIBS)
925 AC_SUBST(CONS_LDFLAGS)
926 AC_SUBST(READLINE_SRC)
927
928 dnl Minimal stuff for readline Makefile configuration
929 MAKE_SHELL=/bin/sh
930 AC_SUBST(MAKE_SHELL)
931 AC_HEADER_STAT
932 AC_HEADER_DIRENT
933 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr lstat lchown)
934 AC_CHECK_FUNCS(nanosleep nl_langinfo)
935 AC_CHECK_HEADERS(varargs.h)
936
937 dnl End of readline/conio stuff
938 dnl -----------------------------------------------------------------------
939
940 dnl -----------------------------------------------------------------------
941 dnl  Check for Python support
942 dnl
943 AC_MSG_CHECKING(for Python support)
944 AC_ARG_WITH(python,
945    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.]),
946    [
947        PYTHON_INCDIR= 
948        PYTHON_LIBS=
949        if test "$withval" != "no"; then
950           if test "$withval" = "yes"; then
951              if test -e /usr/bin/python-config ; then
952                 PYTHON_INCDIR=`/usr/bin/python-config --includes`
953                 PYTHON_LIBS=`/usr/bin/python-config --libs`
954              else
955                 for python_root in /usr /usr/local /usr/sfw; do
956                    for ver in python2.2 python2.3 python2.4 python2.5 python2.6 python3; do
957                       if test -f $python_root/include/${ver}/Python.h; then
958                          PYTHON_INCDIR=-I$python_root/include/${ver}
959                          if test -d $python_root/lib64/${ver}/config; then
960                             PYTHON_LIBS="-L$python_root/lib64/${ver}/config -l${ver}"
961                          else
962                             PYTHON_LIBS="-L$python_root/lib/${ver}/config -l${ver}"
963                          fi
964                          break 
965                       fi
966                    done
967                 done
968
969                 if test x$PYTHON_INCDIR = x; then
970                    if test -f $prefix/include/Python.h; then
971                       PYTHON_INCDIR=-I$prefix/include
972                       if test -d $prefix/lib64/config; then
973                          PYTHON_LIBS="-L$prefix/lib64/config -lpython"
974                       else
975                          PYTHON_LIBS="-L$prefix/lib/config -lpython"
976                       fi
977                    else
978                       AC_MSG_RESULT(no)
979                       AC_MSG_ERROR(Unable to find Python.h in standard locations)
980                    fi
981                 fi
982              fi
983           else
984              if test -e $withval/bin/python-config ; then
985                 PYTHON_INCDIR=`$withval/bin/python-config --includes`
986                 PYTHON_LIBS=`$withval/bin/python-config --libs`
987              elif test -f $withval/Python.h; then
988                 PYTHON_INCDIR=-I$withval
989                 PYTHON_LIBS="-L$withval/config -lpython"
990              elif test -f $withval/include/Python.h; then
991                 PYTHON_INCDIR=-I$withval/include
992                 if test -d $withval/lib64/config; then
993                    PYTHON_LIBS="-L$withval/lib64/config -lpython"
994                 else
995                    PYTHON_LIBS="-L$withval/lib/config -lpython"
996                 fi
997              elif test -f $withval/include/python/Python.h; then
998                 PYTHON_INCDIR=-I$withval/include/python
999                 if test -d $withval/lib64/python/config; then
1000                    PYTHON_LIBS="-L$withval/lib64/python/config -lpython"
1001                 else
1002                    PYTHON_LIBS="-L$withval/lib/python/config -lpython"
1003                 fi
1004              else
1005                 AC_MSG_RESULT(no)
1006                 AC_MSG_ERROR(Invalid Python directory $withval - unable to find Python.h under $withval)
1007              fi
1008           fi
1009
1010           AC_DEFINE([HAVE_PYTHON], 1)
1011           AC_MSG_RESULT(yes)
1012           support_python=yes
1013           AC_MSG_NOTICE(checking for more Python libs)
1014           saved_LIBS="$LIBS"; LIBS=
1015           AC_SEARCH_LIBS(shm_open, [rt])
1016           AC_CHECK_LIB(util, openpty)
1017           PYTHON_LIBS="$PYTHON_LIBS $LIBS"
1018           LIBS="$saved_LIBS"
1019        else
1020           AC_MSG_RESULT(no)
1021        fi
1022    ],[
1023        AC_MSG_RESULT(no)
1024    ]
1025 )
1026 AC_SUBST(PYTHON_LIBS)
1027 AC_SUBST(PYTHON_INCDIR)
1028
1029 dnl
1030 dnl Find where sockets are (especially for Solaris)
1031 dnl Do this before the TCP Wrappers test since tcp wrappers
1032 dnl uses the socket library and some linkers are stupid.
1033 dnl
1034 AC_CHECK_FUNC(socket,
1035     AC_MSG_RESULT(using libc's socket),
1036     AC_CHECK_LIB(xnet,socket)
1037     AC_CHECK_LIB(socket,socket)
1038     AC_CHECK_LIB(inet,socket))
1039
1040 dnl -----------------------------------------------------------
1041 dnl Check whether user wants TCP wrappers support (default off)
1042 dnl -----------------------------------------------------------
1043 TCPW_MSG="no" 
1044 WRAPLIBS=""
1045 AC_ARG_WITH(tcp-wrappers,
1046    AC_HELP_STRING([--with-tcp-wrappers@<:@=DIR@:>@], [enable tcpwrappers support]),
1047    [
1048        if test "x$withval" != "xno" ; then
1049           saved_LIBS="$LIBS"
1050           LIBS="$saved_LIBS -lwrap"
1051           AC_SEARCH_LIBS(nanosleep, [rt])
1052           AC_MSG_CHECKING(for libwrap)
1053           AC_TRY_LINK(
1054              [ 
1055                #include <sys/types.h>
1056                #include <tcpd.h>
1057                int deny_severity = 0;
1058                int allow_severity = 0;
1059                struct request_info *req;
1060              ], [
1061                 hosts_access(req);
1062              ], [
1063                  AC_MSG_RESULT(yes)
1064                  AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
1065                  TCPW_MSG="yes" 
1066                  LIBS="$saved_LIBS"
1067                  WRAPLIBS="-lwrap"
1068              ], [
1069                  LIBS="$saved_LIBS -lwrap -lnsl"
1070                  WRAPLIBS="$saved_LIBS -lwrap -lnsl"
1071                  AC_TRY_LINK(
1072                    [
1073                        #include <sys/types.h>
1074                        #include <tcpd.h>
1075                        int deny_severity = 0;
1076                        int allow_severity = 0;
1077                        struct request_info *req;
1078                    ], [
1079                        hosts_access(req);
1080                    ], [
1081                       AC_MSG_RESULT(yes)
1082                       AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
1083                       TCPW_MSG="yes" 
1084                       LIBS="$saved_LIBS"
1085                       WRAPLIBS="-lwrap"
1086                    ], [
1087                       AC_MSG_ERROR([*** libwrap missing])
1088                    ]
1089                 )
1090              ]
1091           )
1092        fi
1093    ]
1094 )
1095
1096 dnl -----------------------------------------------------------
1097 dnl Check whether OpenSSL is available
1098 dnl -----------------------------------------------------------
1099 AC_MSG_CHECKING([for OpenSSL])
1100 dnl The following uses quadrigraphs:
1101 dnl '@<:@' = '['
1102 dnl '@:>@' = ']'
1103 AC_ARG_WITH(openssl,
1104     AC_HELP_STRING([--with-openssl@<:@=DIR@:>@], [Include OpenSSL support. DIR is the OpenSSL base]),
1105     [
1106         with_openssl_directory=${withval}
1107     ]
1108 )
1109
1110 if test "x$with_openssl_directory" != "xno"; then
1111    OPENSSL_LIBS="-lssl -lcrypto"
1112    OPENSSL_INC=""
1113
1114    if test "x$with_openssl_directory" != "xyes" && test x"${with_openssl_directory}" != "x"; then
1115       #
1116       # Make sure the $with_openssl_directory also makes sense
1117       #
1118       if test -d "$with_openssl_directory/lib" -a -d "$with_openssl_directory/include"; then
1119          OPENSSL_LIBS="-L$with_openssl_directory/lib $OPENSSL_LIBS"
1120          OPENSSL_INC="-I$with_openssl_directory/include $OPENSSL_INC"
1121       fi
1122    fi
1123
1124    saved_LIBS="${LIBS}"
1125    saved_CFLAGS="${CFLAGS}"
1126    LIBS="${saved_LIBS} ${OPENSSL_LIBS}"
1127    CFLAGS="${saved_CFLAGS} ${OPENSSL_INC}"
1128
1129    AC_TRY_LINK(
1130       [
1131           #include <openssl/ssl.h>
1132       ], [
1133            CRYPTO_set_id_callback(NULL);
1134       ], [
1135           support_tls="yes"
1136           support_crypto="yes"
1137       ], [
1138           support_tls="no"
1139           support_crypto="no"
1140       ]
1141    )
1142
1143    AC_TRY_LINK(
1144       [
1145           #include <openssl/evp.h>
1146       ], [
1147           EVP_sha512();
1148       ], [
1149           ac_cv_openssl_sha2="yes"
1150       ], [
1151           ac_cv_openssl_sha2="no"
1152       ]
1153    )
1154
1155    dnl Solaris disables greater than 128+ bit encryption in their OpenSSL
1156    dnl implementation, presumably for export reasons. If 192bit AES
1157    dnl is available, we assume that we're running with a 'non-export'
1158    dnl openssl library.
1159    AC_TRY_LINK(
1160       [
1161           #include <openssl/evp.h>
1162       ], [
1163           EVP_aes_192_cbc();
1164       ], [
1165           ac_cv_openssl_export="no"
1166       ], [
1167           ac_cv_openssl_export="yes"
1168       ]
1169    )
1170
1171    if test "$support_tls" = "yes"; then
1172       AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL library is available])
1173       AC_DEFINE(HAVE_TLS, 1, [Define if TLS support should be enabled])
1174       AC_DEFINE(HAVE_CRYPTO, 1, [Define if encryption support should be enabled])
1175    fi
1176
1177    if test "$ac_cv_openssl_sha2" = "yes"; then
1178       AC_DEFINE(HAVE_SHA2, 1, [Define if the SHA-2 family of digest algorithms is available])
1179    fi
1180
1181    if test "$ac_cv_openssl_export" = "yes"; then
1182       AC_DEFINE(HAVE_OPENSSL_EXPORT_LIBRARY, 1, [Define if the OpenSSL library is export-contrained to 128bit ciphers])
1183    fi
1184
1185    if test "$support_crypto" = "yes"; then
1186       AC_CHECK_LIB(ssl, EVP_PKEY_encrypt_old, AC_DEFINE(HAVE_OPENSSLv1, 1, [Set if have OpenSSL version 1.x]))
1187    fi
1188
1189    LIBS="${saved_LIBS}"
1190    CFLAGS="${saved_CFLAGS}"
1191 else
1192    support_tls="no"
1193    support_crypto="no"
1194    OPENSSL_LIBS=""
1195    OPENSSL_INC=""
1196 fi
1197 AC_MSG_RESULT([$support_tls])
1198
1199 if test "$support_tls" = "no"; then
1200    OPENSSL_LIBS=""
1201    OPENSSL_INC=""
1202 fi  
1203 if test "$support_crypto" = "no"; then
1204    OPENSSL_LIBS=""
1205    OPENSSL_INC=""
1206 fi  
1207
1208 AC_SUBST(OPENSSL_LIBS)
1209 AC_SUBST(OPENSSL_INC)
1210
1211 dnl -----------------------------------------------------------
1212 dnl dlopen is needed for plugins
1213 dnl -----------------------------------------------------------
1214 AC_SEARCH_LIBS(dlopen, [dl])
1215
1216 dnl ------------------------------------------
1217 dnl Where to place working dir
1218 dnl ------------------------------------------
1219 working_dir=`eval echo ${prefix}/var/bacula/working`
1220 AC_ARG_WITH(working-dir,
1221    AC_HELP_STRING([--with-working-dir=PATH], [specify path of Bacula working directory]),
1222    [
1223        if test "x$withval" != "xno" ; then     
1224          working_dir=$withval
1225        fi
1226    ]
1227 )
1228
1229 AC_SUBST(working_dir)
1230
1231 dnl ------------------------------------------------------------------
1232 dnl If the user has not set archivedir, we set our default as /tmp
1233 dnl ------------------------------------------------------------------
1234 archivedir=/tmp
1235 AC_ARG_WITH(archivedir,
1236    AC_HELP_STRING([--with-archivedir=PATH], [specify path of SD archive directory]),
1237    [
1238        if test "x$withval" != "xno" ; then     
1239           archivedir=$withval
1240        fi
1241    ]
1242 )
1243
1244 AC_SUBST(archivedir)
1245
1246 dnl ------------------------------------------------------------------
1247 dnl Allow the user to specify the daemon resource name default hostname
1248 dnl ------------------------------------------------------------------
1249 basename=`hostname`
1250 AC_ARG_WITH(basename,
1251    AC_HELP_STRING([--with-basename=RESNAME], [specify base resource name for daemons]),
1252    [
1253        if test "x$withval" != "xno" ; then     
1254           basename=$withval
1255        fi
1256    ]
1257 )
1258
1259 AC_SUBST(basename)
1260
1261 dnl ------------------------------------------------------------------
1262 dnl Allow the user to override the hostname (default = machine hostname)
1263 dnl ------------------------------------------------------------------
1264 hostname=`uname -n | cut -d '.' -f 1`
1265 if test x${hostname} = x ; then
1266   hostname="localhost"
1267 fi
1268 AC_ARG_WITH(hostname,
1269    AC_HELP_STRING([--with-hostname=RESNAME], [specify host name for daemons]),
1270    [
1271        if test "x$withval" != "xno" ; then
1272          hostname=$withval
1273        fi
1274    ]
1275 )
1276
1277 AC_SUBST(hostname)
1278
1279
1280 dnl ------------------------------------------
1281 dnl Where to place scriptdir (script files)
1282 dnl ------------------------------------------
1283 scriptdir=`eval echo ${sysconfdir}`
1284 AC_ARG_WITH(scriptdir,
1285    AC_HELP_STRING([--with-scriptdir=PATH], [specify path of Bacula scripts directory]),
1286    [
1287        if test "x$withval" != "xno" ; then     
1288           scriptdir=$withval
1289        fi
1290    ]
1291 )
1292
1293 AC_SUBST(scriptdir)
1294
1295
1296 dnl ------------------------------------------
1297 dnl Where to place bsrdir (bsr files)
1298 dnl ------------------------------------------
1299 bsrdir=/tmp
1300 AC_ARG_WITH(bsrdir,
1301    AC_HELP_STRING([--with-bsrdir=PATH], [specify path of Bacula bsrs directory]),
1302    [
1303        if test "x$withval" != "xno" ; then     
1304           bsrdir=$withval
1305        fi
1306    ]
1307 )
1308
1309 AC_SUBST(bsrdir)
1310
1311 dnl ------------------------------------------
1312 dnl Where to place logdir (bsr files)
1313 dnl ------------------------------------------
1314 logdir=/tmp
1315 AC_ARG_WITH(logdir,
1316    AC_HELP_STRING([--with-logdir=PATH], [specify path of Bacula logs directory]),
1317    [
1318        if test "x$withval" != "xno" ; then     
1319           logdir=$withval
1320        fi
1321    ]
1322 )
1323
1324 AC_SUBST(logdir)
1325
1326
1327 # ------------------------------------------
1328 # Where to place plugindir (plugin files)
1329 # ------------------------------------------
1330 plugindir=`eval echo ${libdir}`
1331 AC_ARG_WITH(plugindir,
1332    AC_HELP_STRING([--with-plugindir=PATH], [specify path of Bacula plugins directory]),
1333    [
1334        if test "x$withval" != "xno" ; then     
1335           plugindir=$withval
1336        fi
1337    ]
1338 )
1339
1340 AC_SUBST(plugindir)
1341
1342 dnl ------------------------------------------
1343 dnl Where to send dump email
1344 dnl ------------------------------------------
1345 dump_email=root@localhost
1346 AC_ARG_WITH(dump-email,
1347    AC_HELP_STRING([--with-dump-email=EMAIL], [dump email address]),
1348    [
1349        if test "x$withval" != "xno" ; then     
1350           dump_email=$withval
1351        fi
1352    ]
1353 )
1354
1355 AC_SUBST(dump_email)
1356
1357 dnl ------------------------------------------
1358 dnl Where to send job email
1359 dnl ------------------------------------------
1360 job_email=root@localhost
1361 AC_ARG_WITH(job-email,
1362    AC_HELP_STRING([--with-job-email=EMAIL], [job output email address]),
1363    [
1364        if test "x$withval" != "xno" ; then     
1365           job_email=$withval
1366        fi
1367    ]
1368 )
1369
1370 AC_SUBST(job_email)
1371
1372 dnl ------------------------------------------
1373 dnl Where to find smtp host
1374 dnl ------------------------------------------
1375 smtp_host=localhost
1376 AC_ARG_WITH(smtp_host,
1377    AC_HELP_STRING([--with-smtp-host=HOST], [SMTP mail host address]),
1378    [
1379        if test "x$withval" != "xno" ; then     
1380           smtp_host=$withval
1381        fi
1382    ]
1383 )
1384
1385 AC_SUBST(smtp_host)
1386
1387 dnl ------------------------------------
1388 dnl Where to place pid files
1389 dnl ------------------------------------
1390 piddir=/var/run
1391 AC_ARG_WITH(pid-dir,
1392    AC_HELP_STRING([--with-pid-dir=PATH], [specify location of Bacula pid files]),
1393    [
1394        if test "x$withval" != "xno" ; then   
1395           piddir=$withval
1396        fi
1397    ]
1398 )
1399
1400 AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
1401 AC_SUBST(piddir)
1402
1403 dnl ------------------------------------
1404 dnl Where to place subsys "lock file"
1405 dnl ------------------------------------
1406 subsysdir=/var/run/subsys
1407 if test -d /var/run/subsys; then
1408    subsysdir=/var/run/subsys
1409 elif test -d /var/lock/subsys; then
1410    subsysdir=/var/lock/subsys
1411 else
1412    subsysdir=/var/run/subsys
1413 fi
1414 AC_ARG_WITH(subsys-dir,
1415    AC_HELP_STRING([--with-subsys-dir=PATH], [specify location of Bacula subsys file]),
1416    [
1417        if test "x$withval" != "xno" ; then   
1418           subsysdir=$withval
1419        fi
1420    ]
1421 )
1422
1423 AC_SUBST(subsysdir)
1424
1425 dnl ------------------------------------
1426 dnl Where to start assigning ports
1427 dnl ------------------------------------
1428 baseport=9101
1429 AC_ARG_WITH(baseport,
1430    AC_HELP_STRING([--with-baseport=PORT], [specify base port address for daemons]),
1431    [
1432        if test "x$withval" != "xno" ; then   
1433           baseport=$withval
1434        fi
1435    ]
1436 )
1437
1438 AC_SUBST(baseport)
1439 dir_port=`expr $baseport`
1440 fd_port=`expr $baseport + 1`
1441 sd_port=`expr $fd_port + 1`
1442
1443 AC_SUBST(dir_port)
1444 AC_SUBST(fd_port)
1445 AC_SUBST(sd_port)
1446
1447 dnl ------------------------------------------
1448 dnl Generate passwords
1449 dnl ------------------------------------------
1450 dir_password=
1451 AC_ARG_WITH(dir-password,
1452    AC_HELP_STRING([--with-dir-password=PASSWORD], [specify Director's password]),
1453    [
1454        if test "x$withval" != "xno" ; then     
1455           dir_password=$withval
1456        fi
1457    ]
1458 )
1459
1460 if test "x$dir_password" = "x" ; then
1461    if test "x$OPENSSL" = "xnone" ; then
1462       key=`autoconf/randpass 33`
1463    else
1464       key=`openssl rand -base64 33`
1465    fi
1466    dir_password=$key
1467 fi
1468
1469 fd_password=
1470 AC_ARG_WITH(fd-password,
1471    AC_HELP_STRING([--with-fd-password=PASSWORD], [specify Client's password]),
1472    [
1473        if test "x$withval" != "xno" ; then     
1474           fd_password=$withval
1475        fi
1476    ]
1477 )
1478
1479 if test "x$fd_password" = "x" ; then
1480    if test "x$OPENSSL" = "xnone" ; then
1481       key=`autoconf/randpass 37`
1482    else
1483       key=`openssl rand -base64 33`
1484    fi
1485    fd_password=$key
1486 fi
1487
1488 sd_password=
1489 AC_ARG_WITH(sd-password,
1490    AC_HELP_STRING([--with-sd-password=PASSWORD], [specify Storage daemon's password]),
1491    [
1492        if test "x$withval" != "xno" ; then     
1493           sd_password=$withval
1494        fi
1495    ]
1496 )
1497
1498 if test "x$sd_password" = "x" ; then
1499    if test "x$OPENSSL" = "xnone" ; then
1500       key=`autoconf/randpass 41`
1501    else
1502       key=`openssl rand -base64 33`
1503    fi
1504    sd_password=$key
1505 fi
1506
1507 mon_dir_password=
1508 AC_ARG_WITH(mon-dir-password,
1509    AC_HELP_STRING([--with-mon-dir-password=PASSWORD], [specify Director's password used by the monitor]),
1510    [
1511        if test "x$withval" != "xno" ; then     
1512           mon_dir_password=$withval
1513        fi
1514    ]
1515 )
1516
1517 if test "x$mon_dir_password" = "x" ; then
1518    if test "x$OPENSSL" = "xnone" ; then
1519       key=`autoconf/randpass 33`
1520    else
1521       key=`openssl rand -base64 33`
1522    fi
1523    mon_dir_password=$key
1524 fi
1525
1526 mon_fd_password=
1527 AC_ARG_WITH(mon-fd-password,
1528    AC_HELP_STRING([--with-mon-fd-password=PASSWORD], [specify Client's password used by the monitor]),
1529    [
1530        if test "x$withval" != "xno" ; then     
1531           mon_fd_password=$withval
1532        fi
1533    ]
1534 )
1535
1536 if test "x$mon_fd_password" = "x" ; then
1537    if test "x$OPENSSL" = "xnone" ; then
1538       key=`autoconf/randpass 37`
1539    else
1540       key=`openssl rand -base64 33`
1541    fi
1542    mon_fd_password=$key
1543 fi
1544
1545 mon_sd_password=
1546 AC_ARG_WITH(mon-sd-password,
1547    AC_HELP_STRING([--with-mon-sd-password=PASSWORD], [specify Storage daemon's password used by the monitor]),
1548    [
1549        if test "x$withval" != "xno" ; then     
1550           mon_sd_password=$withval
1551        fi
1552    ]
1553 )
1554
1555 if test "x$mon_sd_password" = "x" ; then
1556    if test "x$OPENSSL" = "xnone" ; then
1557       key=`autoconf/randpass 41`
1558    else
1559       key=`openssl rand -base64 33`
1560    fi
1561    mon_sd_password=$key
1562 fi
1563
1564 AC_SUBST(dir_password)
1565 AC_SUBST(fd_password)
1566 AC_SUBST(sd_password)
1567 AC_SUBST(mon_dir_password)
1568 AC_SUBST(mon_fd_password)
1569 AC_SUBST(mon_sd_password)
1570
1571 dnl
1572 dnl Pickup any database name
1573 dnl
1574 db_name=bacula
1575 AC_ARG_WITH(db_name,
1576    AC_HELP_STRING([--with-db-name=DBNAME], [specify database name @<:@default=bacula@:>@]),
1577    [
1578        if test "x$withval" != "x" ; then   
1579           db_name=$withval
1580        fi
1581    ]
1582 )
1583 AC_SUBST(db_name)
1584
1585 db_user=bacula
1586 AC_ARG_WITH(db_user,
1587    AC_HELP_STRING([--with-db-user=UNAME], [specify database user @<:@default=bacula@:>@]),
1588    [
1589        if test "x$withval" != "x" ; then   
1590           db_user=$withval
1591        fi
1592    ]
1593 )
1594 AC_SUBST(db_user)
1595
1596 db_password=
1597 AC_ARG_WITH(db_password,
1598    AC_HELP_STRING([--with-db-password=PWD], [specify database password @<:@default=*none*@:>@]),
1599    [
1600        if test "x$withval" != "x" ; then   
1601           db_password=$withval
1602        fi
1603    ]
1604 )
1605 AC_SUBST(db_password)
1606
1607 dnl
1608 dnl Pickup a database port
1609 dnl
1610 db_port=" "
1611 AC_ARG_WITH(db_port,
1612    AC_HELP_STRING([--with-db-port=DBPORT], [specify a database port @<:@default=null@:>@]),
1613    [
1614        if test "x$withval" != "x" ; then
1615           db_port=$withval
1616        fi
1617    ]
1618 )
1619 AC_SUBST(db_port)
1620
1621 #
1622 # Handle users and groups for each daemon
1623 #
1624 dir_user=
1625 AC_ARG_WITH(dir_user,
1626    AC_HELP_STRING([--with-dir-user=USER], [specify user for Director daemon]),
1627    [
1628        if test "x$withval" != "x" ; then   
1629            dir_user=$withval
1630        fi
1631    ]
1632 )
1633
1634 dir_group=
1635 AC_ARG_WITH(dir_group,
1636    AC_HELP_STRING([--with-dir-group=GROUP], [specify group for Director daemon]),
1637    [
1638        if test "x$withval" != "x" ; then   
1639           dir_group=$withval
1640        fi
1641    ]
1642 )
1643
1644 sd_user=
1645 AC_ARG_WITH(sd_user,
1646    AC_HELP_STRING([--with-sd-user=USER], [specify user for Storage daemon]),
1647    [
1648        if test "x$withval" != "x" ; then   
1649           sd_user=$withval
1650        fi
1651    ]
1652 )
1653
1654 sd_group=
1655 AC_ARG_WITH(sd_group,
1656    AC_HELP_STRING([--with-sd-group=GROUP], [specify group for Storage daemon]),
1657    [
1658        if test "x$withval" != "x" ; then   
1659           sd_group=$withval
1660        fi
1661    ]
1662 )
1663
1664 fd_user=
1665 AC_ARG_WITH(fd_user,
1666    AC_HELP_STRING([--with-fd-user=USER], [specify user for File daemon]),
1667    [
1668        if test "x$withval" != "x" ; then   
1669           fd_user=$withval
1670        fi
1671    ]
1672 )
1673
1674 fd_group=
1675 AC_ARG_WITH(fd_group,
1676    AC_HELP_STRING([--with-fd-group=GROUP], [specify group for File daemon]),
1677    [
1678        if test "x$withval" != "x" ; then   
1679           fd_group=$withval
1680        fi
1681    ]
1682 )
1683
1684 AC_SUBST(dir_user)
1685 AC_SUBST(dir_group)
1686 AC_SUBST(sd_user)
1687 AC_SUBST(sd_group)
1688 AC_SUBST(fd_user)
1689 AC_SUBST(fd_group)
1690
1691 dnl
1692 dnl allow setting default executable permissions
1693 dnl
1694 SBINPERM=0750
1695 AC_ARG_WITH(sbin-perm,
1696    AC_HELP_STRING([--with-sbin-perm=MODE], [specify permissions for sbin binaries @<:@default=0750@:>@]),
1697    [
1698        if test "x$withval" != "x" ; then   
1699           SBINPERM=$withval
1700        fi
1701    ]
1702 )
1703
1704 AC_SUBST(SBINPERM)
1705
1706 dnl ------------------------------------------------
1707 dnl Bacula check for various SQL database engines
1708 dnl ------------------------------------------------
1709 BA_CHECK_POSTGRESQL_DB
1710
1711 BA_CHECK_MYSQL_DB
1712
1713 BA_CHECK_SQLITE3_DB
1714
1715 BA_CHECK_INGRES_DB
1716
1717 BA_CHECK_DBI_DB
1718
1719 BA_CHECK_DBI_DRIVER
1720
1721 dnl -------------------------------------------
1722 dnl Make sure at least one database backend is found
1723 dnl -------------------------------------------
1724 if test "x${db_backends}" = "x" ; then
1725    echo " "
1726    echo " "
1727    echo "You have not specified either --enable-client-only or one of the"
1728    echo "supported databases: MySQL, PostgreSQL, Ingres, SQLite3 or DBI."
1729    echo "This is not permitted. Please reconfigure."
1730    echo " "
1731    echo "Aborting the configuration ..."
1732    echo " "
1733    echo " "
1734    exit 1
1735 fi
1736
1737 dnl -------------------------------------------
1738 dnl See how many catalog backends are configured.
1739 dnl -------------------------------------------
1740 case `echo $DB_BACKENDS | wc -w | sed -e 's/^ *//'` in
1741    1)
1742       DEFAULT_DB_TYPE="${DB_BACKENDS}"
1743       if test x$use_libtool = xno; then
1744          SHARED_CATALOG_TARGETS=""
1745       else
1746          SHARED_CATALOG_TARGETS="libbaccats-${DEFAULT_DB_TYPE}.la"
1747       fi
1748       ;;
1749    *)
1750       dnl ------------------------------------------------
1751       dnl Set the default backend to the first backend found
1752       dnl ------------------------------------------------
1753       DEFAULT_DB_TYPE=`echo ${DB_BACKENDS} | cut -d' ' -f1`
1754
1755       dnl ------------------------------------------------
1756       dnl For multiple backend we need libtool support.
1757       dnl ------------------------------------------------
1758       if test x$use_libtool = xno; then
1759          echo " "
1760          echo " "
1761          echo "You have specified two or more of the"
1762          echo "supported databases: MySQL, PostgreSQL, Ingres, SQLite3 or DBI."
1763          echo "This is not permitted when not using libtool Please reconfigure."
1764          echo " "
1765          echo "Aborting the configuration ..."
1766          echo " "
1767          echo " "
1768          exit 1
1769       fi
1770
1771       SHARED_CATALOG_TARGETS=""
1772       for db_type in ${DB_BACKENDS}
1773       do
1774          if test -z "${SHARED_CATALOG_TARGETS}"; then
1775             SHARED_CATALOG_TARGETS="libbaccats-${db_type}.la"
1776          else
1777             SHARED_CATALOG_TARGETS="${SHARED_CATALOG_TARGETS} libbaccats-${db_type}.la"
1778          fi
1779       done
1780       ;;
1781 esac
1782
1783 dnl -------------------------------------------
1784 dnl Unset DB_LIBS when using libtool as we link the
1785 dnl shared library using the right database lib no need to
1786 dnl set DB_LIBS which is only used for non shared versions
1787 dnl of the backends.
1788 dnl -------------------------------------------
1789 if test x$use_libtool = xyes; then
1790    DB_LIBS=""
1791 fi
1792
1793 AC_SUBST(DB_BACKENDS)
1794 AC_SUBST(DB_LIBS)
1795 AC_SUBST(DEFAULT_DB_TYPE)
1796 AC_SUBST(SHARED_CATALOG_TARGETS)
1797
1798 dnl -------------------------------------------
1799 dnl enable batch attribute DB insert (default on)
1800 dnl -------------------------------------------
1801 support_batch_insert=yes
1802 AC_ARG_ENABLE(batch-insert,
1803    AC_HELP_STRING([--enable-batch-insert], [enable the DB batch insert code @<:@default=yes@:>@]),
1804    [
1805        if test x$enableval = xno; then
1806           support_batch_insert=no
1807        fi
1808    ]
1809 )
1810
1811 if test x$support_batch_insert = xyes; then
1812    AC_DEFINE(USE_BATCH_FILE_INSERT, 1, [Set if DB batch insert code enabled])
1813 fi
1814
1815 dnl -------------------------------------------
1816 dnl Check if mysql supports batch mode   
1817 dnl -------------------------------------------
1818 if test ! -z "$MYSQL_LIB"; then
1819    AC_CHECK_LIB(mysql_r, mysql_thread_safe, AC_DEFINE(HAVE_MYSQL_THREAD_SAFE, 1, [Set if have mysql_thread_safe]))
1820 fi
1821
1822 dnl -------------------------------------------
1823 dnl Check if sqlite supports batch mode   
1824 dnl -------------------------------------------
1825 if test ! -z "SQLITE_LIB"; then
1826    AC_CHECK_LIB(sqlite3, sqlite3_threadsafe, AC_DEFINE(HAVE_SQLITE3_THREADSAFE, 1, [Set if have sqlite3_threadsafe]))
1827 fi
1828
1829 dnl -------------------------------------------
1830 dnl Check if postgresql supports batch mode   
1831 dnl -------------------------------------------
1832 if test ! -z "$POSTGRESQL_LIB"; then
1833    dnl For postgresql checking
1834    saved_LIBS="${LIBS}"
1835    LIBS="${saved_LIBS} ${POSTGRESQL_LIB}"
1836    
1837    AC_CHECK_LIB(pq, PQisthreadsafe, AC_DEFINE(HAVE_PQISTHREADSAFE, 1, [Set if have PQisthreadsafe]))
1838    AC_CHECK_LIB(pq, PQputCopyData, AC_DEFINE(HAVE_PQ_COPY, 1, [Set if have PQputCopyData]))
1839    if test "x$ac_cv_lib_pq_PQputCopyData" = "xyes"; then
1840       if test $support_batch_insert = yes ; then
1841          AC_DEFINE(HAVE_POSTGRESQL_BATCH_FILE_INSERT, 1, [Set if PostgreSQL DB batch insert code enabled])
1842       fi
1843    fi
1844
1845    if test x$ac_cv_lib_pq_PQisthreadsafe != xyes -a x$support_batch_insert = xyes
1846    then
1847       echo "WARNING: Your PostgreSQL client library is too old to detect "
1848       echo "if it was compiled with --enable-thread-safety, consider to "
1849       echo "upgrade it in order to avoid problems with Batch insert mode"
1850       echo
1851    fi
1852
1853    dnl Revert after postgresql checks
1854    LIBS="${saved_LIBS}"
1855 fi
1856
1857 dnl -------------------------------------------
1858 dnl Check if dbi supports batch mode   
1859 dnl -------------------------------------------
1860 if test ! -z "$DBI_LIBS"; then
1861    dnl -------------------------------------------
1862    dnl Push the DB_PROG onto the stack of supported database backends for DBI
1863    dnl -------------------------------------------
1864    DB_BACKENDS="${DB_BACKENDS} ${DB_PROG}"
1865
1866    dnl -------------------------------------------
1867    dnl Check for batch insert
1868    dnl -------------------------------------------
1869    if test $DB_PROG = postgresql; then
1870       AC_CHECK_LIB(pq, PQisthreadsafe, AC_DEFINE(HAVE_PQISTHREADSAFE))
1871       AC_CHECK_LIB(pq, PQputCopyData, AC_DEFINE(HAVE_PQ_COPY))
1872       test "x$ac_cv_lib_pq_PQputCopyData" = "xyes"
1873       pkg=$?
1874       if test $pkg = 0; then
1875          if test $support_batch_insert = yes ; then
1876             AC_DEFINE(HAVE_DBI_BATCH_FILE_INSERT, 1, [Set if DBI DB batch insert code enabled])
1877          fi
1878       fi
1879    fi
1880 else 
1881    dnl -------------------------------------------
1882    dnl If dbi was not chosen, let the comment in file
1883    dnl -------------------------------------------
1884    uncomment_dbi="#"  
1885 fi
1886
1887 AC_SUBST(uncomment_dbi)
1888
1889 AC_DEFINE(PROTOTYPES)
1890
1891 dnl --------------------------------------------------------------------------
1892 dnl Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
1893 dnl
1894 if test -z "$CFLAGS" -o "$CFLAGS" = "-g -O2"; then
1895    if test -z "$CCOPTS"; then
1896       CCOPTS='-g -O2 -Wall'
1897    fi
1898    CFLAGS="$CCOPTS"
1899 fi
1900
1901 dnl A few others 
1902 AC_EXEEXT
1903
1904 dnl See if we can use 64 bit file addresses
1905 largefile_support="no"
1906 AC_BAC_LARGEFILE
1907
1908 AC_PATH_XTRA
1909
1910 dnl --------------------------------------------------------------------------
1911 dnl CHECKING FOR HEADER FILES
1912 dnl --------------------------------------------------------------------------
1913 AC_CHECK_HEADERS( \
1914    assert.h \
1915    fcntl.h \
1916    grp.h \
1917    pwd.h \
1918    libc.h \
1919    limits.h \
1920    stdarg.h \
1921    stdlib.h \
1922    stdint.h \
1923    string.h \
1924    strings.h \
1925    termios.h \
1926    termcap.h \
1927    term.h \
1928    unistd.h \
1929    sys/bitypes.h \
1930    sys/byteorder.h \
1931    sys/ioctl.h \
1932    sys/select.h \
1933    sys/socket.h \
1934    sys/sockio.h \
1935    sys/stat.h \
1936    sys/time.h \
1937    sys/types.h \
1938    arpa/nameser.h \
1939    mtio.h \
1940    sys/mtio.h \
1941    sys/tape.h \
1942    regex.h \
1943 )
1944 AC_HEADER_STDC
1945 AC_HEADER_MAJOR
1946 AC_HEADER_DIRENT
1947 AC_HEADER_STAT
1948 AC_HEADER_SYS_WAIT
1949 AC_HEADER_TIME
1950 AC_STRUCT_ST_BLKSIZE
1951 AC_STRUCT_ST_BLOCKS
1952 AC_STRUCT_TIMEZONE
1953
1954 dnl --------------------------------------------------------------------------
1955 dnl Check for utime.h structure 
1956 dnl --------------------------------------------------------------------------
1957 AC_CACHE_CHECK(for utime.h, ba_cv_header_utime_h,
1958    [
1959        AC_TRY_COMPILE(
1960           [
1961               #include <sys/types.h>
1962               #include <utime.h>
1963           ], [
1964               struct utimbuf foo
1965           ], [
1966               ba_cv_header_utime_h=yes
1967           ], [
1968               ba_cv_header_utime_h=no
1969           ]
1970        )
1971    ]
1972 )
1973 test $ba_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H, 1, [Set if utime.h exists])
1974
1975 dnl --------------------------------------------------------------------------
1976 dnl Check for socklen_t
1977 dnl --------------------------------------------------------------------------
1978 AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
1979    [
1980        AC_TRY_COMPILE(
1981           [
1982               #include <sys/types.h>
1983               #include <sys/socket.h>
1984           ], [
1985               socklen_t x
1986           ], [
1987              ba_cv_header_socklen_t=yes
1988           ], [
1989              ba_cv_header_socklen_t=no
1990           ]
1991        )
1992    ]
1993 )
1994 test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T, 1, [Set if socklen_t exists])
1995
1996 dnl --------------------------------------------------------------------------
1997 dnl Check for ioctl request type
1998 dnl --------------------------------------------------------------------------
1999 AC_LANG(C++)
2000 AC_CACHE_CHECK(for ioctl_req_t, ba_cv_header_ioctl_req_t,
2001    [
2002        AC_TRY_COMPILE(
2003           [
2004               #include <unistd.h>
2005               #include <sys/types.h>
2006               #include <sys/ioctl.h>
2007           ], [
2008               int (*d_ioctl)(int fd, unsigned long int request, ...);
2009               d_ioctl = ::ioctl;
2010           ], [
2011              ba_cv_header_ioctl_req_t=yes
2012           ], [
2013              ba_cv_header_ioctl_req_t=no
2014           ]
2015        )
2016    ]
2017 )
2018 test $ba_cv_header_ioctl_req_t = yes && AC_DEFINE(HAVE_IOCTL_ULINT_REQUEST, 1, [Set if ioctl request is unsigned long int])
2019
2020 dnl Note: it is more correct to use AC_LANG(C++) but some of the older
2021 dnl   *BSD systems still use old style C prototypes, which are wrong with
2022 dnl   compiled with a C++ compiler. 
2023 AC_LANG(C)
2024
2025 dnl --------------------------------------------------------------------------
2026 dnl Check for typeof()
2027 dnl --------------------------------------------------------------------------
2028 AC_LANG_PUSH(C++)
2029 AC_CACHE_CHECK(for typeof, ba_cv_have_typeof,
2030    [
2031        AC_TRY_RUN(
2032           [
2033               main(){char *a = 0; a = (typeof a)a;}
2034           ], [
2035               ba_cv_have_typeof=yes
2036           ], [
2037               ba_cv_have_typeof=no
2038           ], [
2039               ba_cv_have_typeof=no
2040           ]
2041        )
2042    ]
2043 )
2044 test $ba_cv_have_typeof = yes && AC_DEFINE([HAVE_TYPEOF], 1, [Defind to 1 if compiler has typeof])
2045 AC_LANG_POP(C++)
2046
2047 AC_C_CONST
2048
2049 AC_C_BIGENDIAN([AC_DEFINE([HAVE_BIG_ENDIAN], [1], [Big Endian])], [AC_DEFINE([HAVE_LITTLE_ENDIAN], [1], [Little Endian])])
2050
2051 dnl --------------------------------------------------------------------------
2052 dnl CHECKING FOR FILESYSTEM TYPE
2053 dnl --------------------------------------------------------------------------
2054 AC_MSG_CHECKING(how to get filesystem type)
2055 fstype=no
2056 # The order of these tests is important.
2057 AC_TRY_CPP(
2058    [
2059        #include <sys/statvfs.h>
2060        #include <sys/fstyp.h>
2061    ],
2062    AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4
2063 )
2064 if test $fstype = no; then
2065    AC_TRY_CPP(
2066       [
2067           #include <sys/statfs.h>
2068           #include <sys/fstyp.h>
2069       ],
2070       AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3
2071    )
2072 fi
2073 if test $fstype = no; then
2074    AC_TRY_CPP(
2075       [
2076           #include <sys/statfs.h>
2077           #include <sys/vmount.h>
2078       ],
2079       AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX
2080    )
2081 fi
2082 if test $fstype = no; then  
2083    AC_TRY_CPP(
2084       [
2085           #include <mntent.h>
2086       ],
2087       AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD
2088    )
2089 fi
2090 if test $fstype = no; then  
2091    AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
2092 fi
2093 if test $fstype = no; then  
2094    AC_TRY_CPP(
2095       [
2096           #include <sys/mount.h>
2097           #include <sys/fs_types.h>
2098       ],
2099       AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix
2100    )
2101 fi
2102 AC_MSG_RESULT($fstype)
2103
2104 AC_CHECK_HEADER(sys/statvfs.h, [ AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Defines if your system have the sys/statvfs.h header file])] , )
2105
2106 dnl --------------------------------------------------------------------------
2107 dnl CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
2108 dnl --------------------------------------------------------------------------
2109 AC_TYPE_SIGNAL
2110 SIGNAL_CHECK
2111 AC_TYPE_MODE_T
2112 AC_TYPE_UID_T
2113 AC_TYPE_SIZE_T
2114 AC_TYPE_PID_T
2115 AC_TYPE_OFF_T
2116 AC_TYPE_INTPTR_T
2117 AC_TYPE_UINTPTR_T
2118 AC_CHECK_TYPE(ino_t, unsigned long)
2119 AC_CHECK_TYPE(dev_t, unsigned long)
2120 AC_CHECK_TYPE(daddr_t, long)
2121 AC_CHECK_TYPE(major_t, int)
2122 AC_CHECK_TYPE(minor_t, int)
2123 AC_CHECK_TYPE(ssize_t, int)
2124 AC_STRUCT_ST_BLOCKS
2125 AC_STRUCT_ST_RDEV
2126 AC_STRUCT_TM
2127 AC_C_CONST
2128
2129 AC_CHECK_SIZEOF(char, 1)
2130 AC_CHECK_SIZEOF(short int, 2)
2131 AC_CHECK_SIZEOF(int, 4)
2132 AC_CHECK_SIZEOF(long int, 4)
2133 AC_CHECK_SIZEOF(long long int, 8)
2134 AC_CHECK_SIZEOF(int *, 4)
2135
2136 dnl Check for sys/types.h types
2137 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int,
2138    [
2139        AC_TRY_COMPILE(
2140           [
2141               #include <sys/types.h>
2142           ], [
2143               u_int a; a = 1;
2144           ], [
2145               ac_cv_have_u_int="yes"
2146           ], [
2147               ac_cv_have_u_int="no"
2148           ]
2149        )
2150    ]
2151 )
2152 if test "x$ac_cv_have_u_int" = "xyes" ; then
2153    AC_DEFINE(HAVE_U_INT)
2154    have_u_int=1
2155 fi
2156
2157 AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t,
2158    [
2159        AC_TRY_COMPILE(
2160           [
2161               #include <sys/types.h>
2162           ], [
2163               intmax_t a; a = 1;
2164           ], [
2165               ac_cv_have_intmax_t="yes"
2166           ], [ 
2167               AC_TRY_COMPILE(
2168                  [
2169                      #include <stdint.h>
2170                  ], [
2171                      intmax_t a; a = 1;
2172                  ], [
2173                      ac_cv_have_intmax_t="yes"
2174                  ], [
2175                      ac_cv_have_intmax_t="no"
2176                  ]
2177               )
2178           ]
2179        )       
2180    ]
2181 )
2182 if test "x$ac_cv_have_intmax_t" = "xyes" ; then
2183    AC_DEFINE(HAVE_INTMAX_T)
2184    have_intmax_t=1
2185 fi
2186
2187 AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t,
2188    [
2189        AC_TRY_COMPILE(
2190           [
2191               #include <sys/types.h>
2192           ], [
2193               u_intmax_t a; a = 1;
2194           ], [
2195               ac_cv_have_u_intmax_t="yes"
2196           ], [ 
2197               AC_TRY_COMPILE(
2198                  [
2199                      #include <stdint.h>
2200                  ], [
2201                     u_intmax_t a; a = 1;
2202                  ], [
2203                     ac_cv_have_u_intmax_t="yes"
2204                  ], [
2205                     ac_cv_have_u_intmax_t="no"
2206                  ]
2207               )
2208           ]
2209        )
2210    ]
2211 )
2212 if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
2213    AC_DEFINE(HAVE_U_INTMAX_T)
2214    have_u_intmax_t=1
2215 fi
2216
2217 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t,
2218    [
2219        AC_TRY_COMPILE(
2220           [
2221               #include <sys/types.h>
2222           ], [
2223               int8_t a; int16_t b; int32_t c; a = b = c = 1;
2224           ], [
2225               ac_cv_have_intxx_t="yes"
2226           ], [
2227               ac_cv_have_intxx_t="no"
2228           ]
2229        )
2230    ]
2231 )
2232 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
2233    AC_DEFINE(HAVE_INTXX_T)
2234    have_intxx_t=1
2235 fi
2236    
2237 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t,
2238    [
2239        AC_TRY_COMPILE(
2240           [
2241               #include <sys/types.h>
2242           ], [
2243               int64_t a; a = 1;
2244           ], [
2245               ac_cv_have_int64_t="yes"
2246           ], [
2247               ac_cv_have_int64_t="no"
2248           ]
2249        )
2250    ]
2251 )
2252 if test "x$ac_cv_have_int64_t" = "xyes" ; then
2253    AC_DEFINE(HAVE_INT64_T)
2254    have_int64_t=1
2255 fi
2256    
2257 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t,
2258    [
2259        AC_TRY_COMPILE(
2260           [
2261               #include <sys/types.h>
2262           ], [
2263               u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;
2264           ], [
2265              ac_cv_have_u_intxx_t="yes"
2266           ], [
2267              ac_cv_have_u_intxx_t="no"
2268           ]
2269        )
2270    ]
2271 )
2272 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
2273    AC_DEFINE(HAVE_U_INTXX_T)
2274    have_u_intxx_t=1
2275 fi
2276
2277 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t,
2278    [
2279        AC_TRY_COMPILE(
2280           [
2281               #include <sys/types.h>
2282           ], [
2283               u_int64_t a; a = 1;
2284           ], [
2285              ac_cv_have_u_int64_t="yes"
2286           ], [
2287              ac_cv_have_u_int64_t="no"
2288           ]
2289        )
2290    ]
2291 )
2292 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
2293    AC_DEFINE(HAVE_U_INT64_T)
2294    have_u_int64_t=1
2295 fi
2296
2297 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
2298     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2299 then
2300    AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
2301    AC_TRY_COMPILE(
2302       [
2303           #include <sys/bitypes.h>
2304       ], [
2305           int8_t a; int16_t b; int32_t c;
2306           u_int8_t e; u_int16_t f; u_int32_t g;
2307           a = b = c = e = f = g = 1;
2308       ], [
2309           AC_DEFINE(HAVE_U_INTXX_T)
2310           AC_DEFINE(HAVE_INTXX_T)
2311           AC_DEFINE(HAVE_SYS_BITYPES_H)
2312           AC_MSG_RESULT(yes)
2313       ], [
2314           AC_MSG_RESULT(no)
2315       ]
2316    ) 
2317 fi
2318
2319 if test -z "$have_u_intxx_t" ; then
2320    AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t,
2321       [
2322           AC_TRY_COMPILE(
2323              [
2324                  #include <sys/types.h>
2325              ], [
2326                  uint8_t a; uint16_t b; 
2327                  uint32_t c; a = b = c = 1;
2328              ], [
2329                 ac_cv_have_uintxx_t="yes"
2330              ], [
2331                 ac_cv_have_uintxx_t="no"
2332              ]
2333           )
2334       ]
2335    )
2336    if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
2337       AC_DEFINE(HAVE_UINTXX_T)
2338    fi
2339 fi
2340
2341 if (test -z "$have_u_int64_t" || test -z "$have_int64_t" && \
2342     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2343 then
2344    AC_MSG_CHECKING([for int64_t and u_int64_t types in sys/bitypes.h])
2345    AC_TRY_COMPILE(
2346       [
2347           #include <sys/bitypes.h>
2348       ], [
2349           int64_t a; u_int64_t b; 
2350           a = b = 1;
2351       ], [
2352           AC_DEFINE(HAVE_U_INT64_T)
2353           AC_DEFINE(HAVE_INT64_T)
2354           AC_MSG_RESULT(yes)
2355       ], [
2356           AC_MSG_RESULT(no)
2357       ]
2358    ) 
2359 fi
2360
2361 if (test -z "$have_uintxx_t" && \
2362     test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2363 then
2364    AC_MSG_CHECKING([for uintXX_t types in sys/bitypes.h])
2365    AC_TRY_COMPILE(
2366       [
2367           #include <sys/bitypes.h>
2368       ], [
2369           uint8_t a; uint16_t b; 
2370           uint32_t c; a = b = c = 1;
2371       ], [
2372           AC_DEFINE(HAVE_UINTXX_T)
2373           AC_MSG_RESULT(yes)
2374       ], [
2375           AC_MSG_RESULT(no)
2376       ]
2377    ) 
2378 fi
2379
2380 dnl --------------------------------------------------------------------------
2381 dnl CHECKING FOR REQUIRED LIBRARY FUNCTIONS
2382 dnl --------------------------------------------------------------------------
2383 AC_CHECK_FUNCS( \
2384    fork \
2385    getcwd \
2386    gethostname \
2387    getpid \
2388    gettimeofday \
2389    setpgid \
2390    setpgrp \
2391    setsid \
2392    signal \
2393    strerror \
2394    strncmp \
2395    strncpy \
2396    vfprintf \
2397    ,,
2398    [echo 'configure: cannot find needed function.'; exit 1]
2399 )
2400
2401 AC_CHECK_FUNCS(malloc_trim, [AC_DEFINE(HAVE_MALLOC_TRIM, 1, [Set if have malloc_trim])])
2402
2403 AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
2404 AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)])
2405 AC_CHECK_FUNCS(posix_fadvise)
2406 AC_CHECK_FUNCS(fdatasync)
2407
2408 AC_CHECK_FUNCS(chflags) 
2409
2410 AC_CHECK_FUNCS(snprintf vsnprintf gethostid fseeko)
2411
2412 AC_CACHE_CHECK(for va_copy, ba_cv_va_copy,
2413    [
2414        AC_TRY_LINK(
2415           [
2416               #include <stdarg.h>
2417               void use_va_copy(va_list args){va_list args2; va_copy(args2,args); va_end(args2);}
2418               void call_use_va_copy(int junk,...){va_list args; va_start(args,junk); use_va_copy(args); va_end(args);}
2419           ], [
2420               call_use_va_copy(1,2,3)
2421           ], [
2422               ba_cv_va_copy=yes,
2423           ], [
2424               ba_cv_va_copy=no
2425           ]
2426        )
2427    ]
2428 )
2429 test $ba_cv_va_copy = yes && AC_DEFINE(HAVE_VA_COPY, 1, [Set if va_copy exists])
2430
2431 dnl --------------------------------------------------------------------------
2432 dnl CHECKING FOR THREAD SAFE FUNCTIONS
2433 dnl --------------------------------------------------------------------------
2434 AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
2435
2436 # If resolver functions are not in libc check for -lnsl or -lresolv.
2437 AC_CHECK_FUNC(gethostbyname_r,
2438     AC_MSG_RESULT(using libc's resolver),
2439     AC_CHECK_LIB(nsl,gethostbyname_r)
2440     AC_CHECK_LIB(resolv,gethostbyname_r))
2441
2442 AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
2443 AC_CHECK_FUNCS(inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
2444 AC_CHECK_FUNCS(gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2)])
2445
2446 dnl ----------------------------
2447 dnl check sa_len of sockaddr
2448 dnl ----------------------------
2449 AC_CACHE_CHECK(for struct sockaddr has a sa_len field, ac_cv_struct_sockaddr_sa_len,
2450    [
2451        AC_TRY_COMPILE(
2452           [
2453               #include <sys/socket.h>
2454           ], [
2455               struct sockaddr s; s.sa_len;
2456           ], [
2457              ac_cv_struct_sockaddr_sa_len=yes
2458           ], [ac_cv_struct_sockaddr_sa_len=no
2459           ]
2460        )
2461    ]
2462 )
2463
2464 if test $ac_cv_struct_sockaddr_sa_len = yes; then
2465   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
2466 fi
2467
2468 AC_FUNC_STRFTIME
2469 AC_FUNC_VPRINTF
2470 AC_FUNC_ALLOCA
2471 AC_FUNC_GETMNTENT
2472 AC_CHECK_FUNCS(getmntinfo, [AC_DEFINE(HAVE_GETMNTINFO)])
2473 AC_FUNC_CLOSEDIR_VOID
2474 AC_FUNC_SETPGRP             dnl check for BSD setpgrp.
2475 # AC_FUNC_FNMATCH    dnl use local version
2476
2477 AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"])
2478
2479 AC_CHECK_LIB(sun, getpwnam)
2480
2481 AC_CHECK_HEADERS(zlib.h)
2482 AC_CHECK_LIB(z, deflate, [ZLIBS="-lz"])
2483 have_zlib=no
2484 if test x$ZLIBS = x-lz; then
2485    AC_DEFINE(HAVE_LIBZ)
2486    have_zlib=yes
2487 fi
2488 AC_SUBST(ZLIBS)
2489
2490 dnl
2491 dnl Check if we have AFS on this system
2492 dnl
2493 AFS_CFLAGS=""
2494 AFS_LIBS=""
2495 support_afs=auto
2496 AC_ARG_ENABLE(afs,
2497    AC_HELP_STRING([--disable-afs], [disable afs support @<:@default=auto@:>@]),
2498    [
2499        if test x$enableval = xyes; then
2500           support_afs=yes
2501        elif test x$enableval = xno; then
2502           support_afs=no
2503        fi
2504    ]
2505 )
2506
2507 have_afs=no
2508 if test x$support_afs = xyes -o x$support_afs = xauto; then
2509    AC_ARG_WITH(afsdir,
2510       AC_HELP_STRING([--with-afsdir@<:@=DIR@:>@], [Directory holding AFS includes/libs]),
2511       with_afsdir=$withval
2512    )
2513
2514    dnl
2515    dnl Search in standard places, or --with-afsdir not specified
2516    dnl
2517    if test x$with_afsdir = x; then
2518       for root in /usr /usr/local; do
2519          if test -d ${root}/include/afs/ ; then
2520             with_afsdir=${root}
2521             break
2522          fi
2523       done
2524    fi
2525
2526    AFS_CFLAGS="-I${with_afsdir}/include"
2527
2528    saved_CFLAGS="${CFLAGS}"
2529    CFLAGS="${AFS_CFLAGS} ${saved_CFLAGS}"
2530
2531    AC_CHECK_HEADERS(afs/stds.h)
2532
2533    CFLAGS="${saved_CFLAGS}"
2534
2535    dnl
2536    dnl See if we can find a libsys with the pioctl symbol in there
2537    dnl
2538    for dir in ${with_afsdir}/lib ${with_afsdir}/lib/afs
2539    do
2540       for arch_type in .a .so
2541       do
2542          A=`test -f ${dir}/libsys${arch_type} && nm ${dir}/libsys${arch_type} | grep pioctl`
2543          pkg=$?
2544          if test $pkg = 0; then
2545             have_afs=yes
2546             AFS_LIBS="-L${dir} -lsys -lrx -llwp ${dir}/util.a"
2547             break
2548          fi
2549       done
2550    done
2551
2552    if test x$support_afs = xyes -a $have_afs != yes; then
2553       AC_MSG_ERROR([afs support explicitly enabled but no supported afs implementation found, 
2554   please either load the afs libraries or rerun configure without --enable-afs])
2555    else
2556       if test $have_afs = yes; then
2557          AC_DEFINE([HAVE_AFS],1,[Defines if your system has AFS support])
2558          AC_DEFINE([HAVE_AFS_ACL],1,[Andrew FileSystem ACL support])
2559       fi
2560    fi
2561 fi
2562
2563 AC_SUBST(AFS_CFLAGS)
2564 AC_SUBST(AFS_LIBS)
2565
2566 dnl
2567 dnl Check for ACL support and libraries
2568 dnl
2569 support_acl=auto
2570 AC_ARG_ENABLE(acl,
2571    AC_HELP_STRING([--disable-acl], [disable acl support @<:@default=auto@:>@]),
2572    [
2573        if test x$enableval = xyes; then
2574           support_acl=yes
2575        elif test x$enableval = xno; then
2576           support_acl=no
2577        fi
2578    ]
2579 )
2580
2581 have_acl=no
2582 have_extended_acl=no
2583 if test x$support_acl = xyes -o x$support_acl = xauto; then
2584    AC_CHECK_HEADER(sys/acl.h, [ AC_DEFINE(HAVE_SYS_ACL_H,1,[Defines if your system have the sys/acl.h header file])] , )
2585
2586    dnl
2587    dnl First check for acl_get_file in libc
2588    dnl
2589    AC_CHECK_FUNC(acl_get_file,
2590       [
2591           have_acl=yes
2592       ]
2593    )
2594
2595    dnl
2596    dnl Check for acl_get_file in libacl (Linux)
2597    dnl
2598    if test $have_acl = no; then
2599       AC_CHECK_LIB(acl, acl_get_file,
2600          [
2601              have_acl=yes
2602              if test $have_afs = yes; then
2603                 dnl
2604                 dnl Because of possible naming conflict with AFS libacl make sure we use the one in /usr/lib64 or /usr/lib !!!
2605                 dnl
2606                 if test -d /usr/lib64/; then
2607                    FDLIBS="-L/usr/lib64 -lacl $FDLIBS"
2608                 else
2609                    FDLIBS="-L/usr/lib -lacl $FDLIBS"
2610                 fi
2611              else
2612                 FDLIBS="-lacl $FDLIBS"
2613              fi
2614          ]
2615       )
2616    fi
2617
2618    dnl
2619    dnl Check for acl_get_file in libpacl (OSF1)
2620    dnl
2621    if test $have_acl = no; then
2622       AC_CHECK_LIB(pacl, acl_get_file,
2623          [
2624              have_acl=yes
2625              FDLIBS="-lpacl $FDLIBS"
2626          ]
2627       )
2628    fi
2629
2630    dnl
2631    dnl Check for acltotext and acl_totext (Solaris)
2632    dnl
2633    if test $have_acl = no -a \
2634            x${HAVE_SUN_OS_TRUE} = x; then
2635       AC_CHECK_LIB(sec, acltotext,
2636          [
2637              have_acl=yes
2638              FDLIBS="-lsec $FDLIBS"
2639
2640              AC_CHECK_LIB(sec, acl_totext,
2641                 [
2642                     have_extended_acl=yes
2643                 ]
2644              )
2645          ]
2646       )
2647    fi
2648
2649    dnl
2650    dnl Check for acl_get and aclx_get (AIX)
2651    dnl
2652    if test $have_acl = no -a \
2653            x${HAVE_AIX_OS_TRUE} = x; then
2654       AC_CHECK_FUNC(acl_get,
2655          [
2656              have_acl=yes
2657
2658              AC_CHECK_FUNC(aclx_get,
2659                 [
2660                     have_extended_acl=yes
2661                 ]
2662              )
2663          ]
2664       )
2665    fi
2666
2667    if test x$support_acl = xyes -a $have_acl != yes; then
2668       AC_MSG_ERROR([acl support explicitly enabled but no supported acl implementation found, 
2669   please either load the acl libraries or rerun configure without --enable-acl])
2670    else
2671       if test $have_acl = yes; then
2672          AC_DEFINE([HAVE_ACL],1,[Normal acl support])
2673       fi
2674
2675       if test $have_extended_acl = yes; then
2676          AC_DEFINE([HAVE_EXTENDED_ACL],1,[Extended acl support])
2677       fi
2678    fi
2679 fi
2680
2681 dnl
2682 dnl Check for XATTR support
2683 dnl
2684 support_xattr=auto
2685 AC_ARG_ENABLE(xattr,
2686    AC_HELP_STRING([--disable-xattr], [disable xattr support @<:@default=auto@:>@]),
2687    [
2688        if test x$enableval = xyes; then
2689           support_xattr=yes
2690        elif test x$enableval = xno; then
2691           support_xattr=no
2692        fi
2693    ]
2694 )
2695
2696 have_xattr=no
2697 if test x$support_xattr = xyes -o x$support_xattr = xauto; then
2698    dnl
2699    dnl First check for *BSD support
2700    dnl When running on a BSD variant
2701    dnl
2702    if test x${HAVE_FREEBSD_OS_TRUE} = x -o \
2703            x${HAVE_NETBSD_OS_TRUE} = x -o \
2704            x${HAVE_OPENBSD_OS_TRUE} = x; then
2705       AC_CHECK_HEADER(sys/extattr.h, [ AC_DEFINE(HAVE_SYS_EXTATTR_H,1,[Defines if your system have the sys/extattr.h header file])] , )
2706       AC_CHECK_HEADER(libutil.h, [ AC_DEFINE(HAVE_LIBUTIL_H,1,[Defines if your system have the libutil.h header file])] , )
2707       AC_CHECK_FUNCS(extattr_get_link extattr_set_link extattr_list_link,
2708          [
2709              have_xattr=yes
2710              AC_DEFINE([HAVE_EXTATTR_GET_LINK],1,[Define to 1 if you have the 'extattr_get_link' function.])
2711              AC_DEFINE([HAVE_EXTATTR_SET_LINK],1,[Define to 1 if you have the 'extattr_set_link' function.])
2712              AC_DEFINE([HAVE_EXTATTR_LIST_LINK],1,[Define to 1 if you have the 'extattr_list_link' function.])
2713          ]
2714       )
2715    
2716       if test $have_xattr = no; then
2717          AC_CHECK_FUNCS(extattr_get_file extattr_set_file extattr_list_file,
2718             [
2719                 have_xattr=yes
2720                 AC_DEFINE([HAVE_EXTATTR_GET_FILE],1,[Define to 1 if you have the 'extattr_get_file' function.])
2721                 AC_DEFINE([HAVE_EXTATTR_SET_FILE],1,[Define to 1 if you have the 'extattr_set_file' function.])
2722                 AC_DEFINE([HAVE_EXTATTR_LIST_FILE],1,[Define to 1 if you have the 'extattr_list_file' function.])
2723             ]
2724          )
2725       fi
2726    
2727       if test $have_xattr = yes; then
2728          have_extattr_string_in_libc=no
2729          AC_CHECK_FUNCS(extattr_namespace_to_string extattr_string_to_namespace,
2730             [
2731                 have_extattr_string_in_libc=yes
2732                 AC_DEFINE([HAVE_EXTATTR_NAMESPACE_TO_STRING],1,[Define to 1 if you have the 'extattr_namespace_to_string' function.])
2733                 AC_DEFINE([HAVE_EXTATTR_STRING_TO_NAMESPACE],1,[Define to 1 if you have the 'extattr_string_to_namespace' function.])
2734             ]
2735          )
2736
2737          dnl
2738          dnl If extattr_namespace_to_string and extattr_string_to_namespace are not in libc see if they are in libutil
2739          dnl
2740          if test $have_extattr_string_in_libc = no; then
2741             AC_CHECK_LIB(util, extattr_namespace_to_string extattr_string_to_namespace,
2742                [
2743                    AC_DEFINE([HAVE_EXTATTR_NAMESPACE_TO_STRING],1,[Define to 1 if you have the 'extattr_namespace_to_string' function.])
2744                    AC_DEFINE([HAVE_EXTATTR_STRING_TO_NAMESPACE],1,[Define to 1 if you have the 'extattr_string_to_namespace' function.])
2745                    FDLIBS="-lutil $FDLIBS"
2746                ]
2747             )
2748          fi
2749       fi
2750    fi
2751
2752    dnl
2753    dnl If we failed to find *BSD support try the AIX implementation of extented attributes (EA)
2754    dnl When running on AIX
2755    dnl
2756    if test $have_xattr = no -a \
2757            x${HAVE_AIX_OS_TRUE} = x; then
2758       AC_CHECK_HEADER(sys/ea.h, [ AC_DEFINE(HAVE_SYS_EA_H,1,[Defines if your system have the sys/ea.h header file])] , )
2759       AC_CHECK_FUNCS(llistea lgetea lsetea,
2760          [
2761              have_xattr=yes
2762              AC_DEFINE([HAVE_LLISTEA],1,[Define to 1 if you have the 'llistea' function.])
2763              AC_DEFINE([HAVE_LGETEA],1,[Define to 1 if you have the 'lgetea' function.])
2764              AC_DEFINE([HAVE_LSETEA],1,[Define to 1 if you have the 'lsetea' function.])
2765          ]
2766       )
2767
2768       if test $have_xattr = no; then
2769          AC_CHECK_FUNCS(listea getea setea,
2770             [
2771                 have_xattr=yes
2772                 AC_DEFINE([HAVE_LISTEA],1,[Define to 1 if you have the 'listea' function.])
2773                 AC_DEFINE([HAVE_GETEA],1,[Define to 1 if you have the 'getea' function.])
2774                 AC_DEFINE([HAVE_SETEA],1,[Define to 1 if you have the 'setea' function.])
2775             ]
2776          )
2777       fi
2778    fi
2779
2780    dnl
2781    dnl If we failed to find AIX support try the TRU64 implementation of extented attributes
2782    dnl when running on a TRU64 OS.
2783    dnl
2784    if test $have_xattr = no -a \
2785            x${HAVE_OSF1_OS_TRUE} = x; then
2786       AC_CHECK_HEADER(sys/proplist.h, [ AC_DEFINE(HAVE_SYS_PROPLIST_H,1,[Defines if your system have the sys/proplist.h header file])] , )
2787       AC_CHECK_FUNCS(getproplist get_proplist_entry sizeof_proplist_entry add_proplist_entry setproplist,
2788          [
2789              have_xattr=yes
2790              AC_DEFINE([HAVE_GETPROPLIST],1,[Define to 1 if you have the 'getproplist' function.])
2791              AC_DEFINE([HAVE_GET_PROPLIST_ENTRY],1,[Define to 1 if you have the 'get_proplist_entry' function.])
2792              AC_DEFINE([HAVE_SIZEOF_PROPLIST_ENTRY],1,[Define to 1 if you have the 'sizeof_proplist_entry' function.])
2793              AC_DEFINE([HAVE_ADD_PROPLIST_ENTRY],1,[Define to 1 if you have the 'add_proplist_entry' function.])
2794              AC_DEFINE([HAVE_SETPROPLIST],1,[Define to 1 if you have the 'setproplist' function.])
2795          ]
2796       )
2797    fi
2798
2799    dnl
2800    dnl If we failed to find TRU64 support try the SOLARIS implementation of extented and extensible attributes
2801    dnl when running on a Solaris.
2802    dnl
2803    if test $have_xattr = no -a \
2804            x${HAVE_SUN_OS_TRUE} = x; then
2805       AC_CHECK_HEADER(sys/attr.h, [ AC_DEFINE(HAVE_SYS_ATTR_H,1,[Defines if your system have the sys/attr.h header file])] , )
2806       AC_CHECK_HEADER(sys/nvpair.h, [ AC_DEFINE(HAVE_SYS_NVPAIR_H,1,[Defines if your system have the sys/nvpair.h header file])] , )
2807       AC_CHECK_HEADER(attr.h, [ AC_DEFINE(HAVE_ATTR_H,1,[Defines if your system have the attr.h header file])] , )
2808
2809       AC_CHECK_FUNCS(openat fstatat unlinkat fchownat futimesat,
2810          [
2811              have_xattr=yes
2812              AC_DEFINE([HAVE_OPENAT],1,[Define to 1 if you have the 'openat' function.])
2813              AC_DEFINE([HAVE_FSTATAT],1,[Define to 1 if you have the 'fstatat' function.])
2814              AC_DEFINE([HAVE_UNLINKAT],1,[Define to 1 if you have the 'unlinkat' function.])
2815              AC_DEFINE([HAVE_FCHOWNAT],1,[Define to 1 if you have the 'fchownat' function.])
2816              AC_DEFINE([HAVE_FUTIMESAT],1,[Define to 1 if you have the 'futimesat' function.])
2817          ]
2818       )
2819
2820       if test $have_xattr = yes; then
2821          AC_CHECK_LIB(nvpair, nvlist_next_nvpair,
2822             [
2823                 AC_DEFINE([HAVE_NVLIST_NEXT_NVPAIR],1,[Define to 1 if you have the 'nvlist_next_nvpair' function.])
2824                 FDLIBS="-lnvpair $FDLIBS"
2825             ]
2826          )
2827       fi
2828    fi
2829
2830    dnl
2831    dnl If we failed to find Solaris support try the generic xattr support code
2832    dnl
2833    if test $have_xattr = no; then
2834       AC_CHECK_HEADER(sys/xattr.h, [ AC_DEFINE(HAVE_SYS_XATTR_H,1,[Defines if your system have the sys/xattr.h header file])] , )
2835       AC_CHECK_FUNCS(llistxattr lgetxattr lsetxattr,
2836          [
2837              have_xattr=yes
2838              AC_DEFINE([HAVE_LLISTXATTR],1,[Define to 1 if you have the 'llistxattr' function.])
2839              AC_DEFINE([HAVE_LGETXATTR],1,[Define to 1 if you have the 'lgetxattr' function.])
2840              AC_DEFINE([HAVE_LSETXATTR],1,[Define to 1 if you have the 'lsetxattr' function.])
2841          ]
2842       )
2843
2844       if test $have_xattr = no; then
2845          AC_CHECK_FUNCS(listxattr getxattr setxattr,
2846             [
2847                 have_xattr=yes
2848                 AC_DEFINE([HAVE_LISTXATTR],1,[Define to 1 if you have the 'listxattr' function.])
2849                 AC_DEFINE([HAVE_GETXATTR],1,[Define to 1 if you have the 'getxattr' function.])
2850                 AC_DEFINE([HAVE_SETXATTR],1,[Define to 1 if you have the 'setxattr' function.])
2851             ]
2852          )
2853       fi
2854    fi
2855
2856    if test x$support_xattr = xyes -a $have_xattr != yes; then
2857       AC_MSG_ERROR([xattr support explicitly enabled but no supported xattr implementation found, 
2858   please either load the xattr libraries or rerun configure without --enable-xattr])
2859    else
2860       if test $have_xattr = yes; then
2861          AC_DEFINE([HAVE_XATTR],1,[Extended Attributes support])
2862       fi
2863    fi
2864 fi
2865
2866 dnl
2867 dnl Check for pthread libraries
2868 dnl
2869 PTHREAD_LIB=""
2870 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
2871    [
2872        AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
2873           [
2874               AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
2875                  [
2876                      AC_CHECK_FUNC(pthread_create)
2877                  ]
2878               )
2879           ]
2880        )
2881    ]
2882 )
2883
2884 dnl
2885 dnl Check for headers, functions and libraries required to support
2886 dnl keeping readall capabilities
2887 dnl
2888 AC_CHECK_HEADERS(sys/prctl.h sys/capability.h)
2889 AC_CHECK_FUNCS(prctl setreuid)
2890 AC_CHECK_LIB([cap], [cap_set_proc], [CAP_LIBS="-lcap"], [CAP_LIBS=])
2891 if test x$CAP_LIBS = x-lcap; then
2892    AC_DEFINE(HAVE_LIBCAP, 1, [Define if you have libcap])
2893 fi
2894 AC_SUBST(CAP_LIBS)
2895
2896 AC_SUBST(FDLIBS)
2897 AC_DEFINE(FDLIBS)
2898
2899 CFLAGS=${CFLAGS--O}
2900
2901 if test x$have_gcc = xyes ; then
2902    CPPFLAGS="$CPPFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
2903    CFLAGS="$CFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
2904 fi
2905 LDFLAGS=${LDFLAGS--O}
2906 CPPFLAGS="$CPPFLAGS"
2907 CFLAGS="$CFLAGS"
2908 AC_SUBST(DEBUG)
2909 AC_SUBST(DINCLUDE)
2910 AC_SUBST(CFLAGS)
2911 AC_SUBST(CPPFLAGS)
2912 AC_SUBST(LDFLAGS)
2913 AC_SUBST(X_CFLAGS)
2914 AC_SUBST(DEFS)
2915 AC_SUBST(LIBS)
2916 AC_SUBST(DLIB)
2917 AC_SUBST(X_LIBS)
2918 AC_SUBST(X_EXTRA_LIBS)
2919 AC_SUBST(WCFLAGS)
2920 AC_SUBST(WLDFLAGS)
2921 AC_SUBST(WRAPLIBS)
2922
2923 dnl extra configurable objects
2924 OBJLIST=
2925 AC_SUBST(OBJLIST)
2926
2927 lld="lld"
2928 llu="llu"
2929
2930 WCFLAGS=
2931 WLDFLAGS=
2932
2933 dnl
2934 dnl Finally we set appropriate distribution specific
2935 dnl  variables and defaults
2936 dnl
2937 dnl PFILES are platform specific files
2938 PFILES="platforms/Makefile"
2939 PSCMD="ps -e"
2940 WIN32=
2941 MACOSX=
2942
2943 hostname=`uname -n | cut -d '.' -f 1`
2944 if test x${hostname} = x ; then
2945    hostname="localhost"
2946 fi
2947 dnl Make sure hostname is resolved
2948 ping -c 1 $hostname 2>/dev/null 1>/dev/null
2949 if test ! $? = 0; then
2950   hostname="localhost"
2951 fi
2952
2953 case "$DISTNAME" in
2954 aix)
2955    DISTVER=`uname -r`
2956    PSCMD="ps -e -o pid,comm"
2957    PFILES="${PFILES} \
2958       platforms/aix/Makefile"
2959    TAPEDRIVE="/dev/rmt0.1" 
2960   ;;     
2961 alpha)
2962    DISTVER=`uname -r`
2963    PTHREAD_LIB="-lpthread -lexc"
2964    if test "${CC}" = "gcc" ; then
2965       lld="lld"
2966       llu="llu"
2967    else
2968       lld="ld"
2969       llu="lu"
2970    fi
2971    TAPEDRIVE="/dev/nrmt0"
2972   ;;
2973 bsdi)
2974    DISTVER=`uname -a |awk '{print $3}'`
2975    TAPEDRIVE="/dev/nrmt0"
2976    PTHREAD_LIB="-pthread"
2977    CFLAGS="${CFLAGS} -pthread"
2978    PSCMD="ps -ax -o pid,command"
2979    lld="qd"
2980    llu="qu"
2981    PFILES="${PFILES} \
2982        platforms/bsdi/Makefile \
2983        platforms/bsdi/bacula-fd \
2984        platforms/bsdi/bacula-sd \
2985        platforms/bsdi/bacula-dir"
2986    largefile_support="yes"
2987   ;;
2988 cygwin)
2989    DISTVER=`uname -a |awk '{print $3}'`
2990    TAPEDRIVE="/dev/nrst0"
2991    WIN32=win32
2992    WCFLAGS="-mwindows"
2993    WLDFLAGS="-mwindows"
2994   ;;
2995 darwin)
2996    DISTVER=`uname -r`
2997    TAPEDRIVE="/dev/nst0"
2998    PSCMD="ps -e -o pid,command"
2999    MACOSX=macosx
3000    PFILES="${PFILES} \
3001       platforms/darwin/Makefile"
3002   ;;
3003 osx)
3004    DISTVER=`uname -r`
3005    TAPEDRIVE="/dev/nst0"
3006    PSCMD="ps -e -o pid,command"
3007    MACOSX=macosx
3008    PFILES="${PFILES} \
3009       platforms/osx/Makefile"
3010   ;;
3011 debian)
3012    if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then
3013       DISTNAME="ubuntu"
3014    fi
3015    DISTVER=`cat /etc/debian_version`
3016    if test -f /etc/lsb-release ; then
3017       . /etc/lsb-release
3018       if test "x$DISTRIB_ID" != "x" ; then
3019          DISTNAME=$DISTRIB_ID
3020       fi
3021       if test "x$DISTRIB_RELEASE" != "x" ; then
3022          DISTVER=$DISTRIB_RELEASE
3023       fi
3024    fi
3025    if test "$DISTNAME" = "Ubuntu" ; then
3026       DISTNAME="ubuntu"
3027    fi
3028    TAPEDRIVE="/dev/nst0"
3029    PSCMD="ps -e -o pid,command"
3030    if test "$DISTNAME" = "ubuntu" ; then
3031       PFILES="${PFILES} \
3032          platforms/ubuntu/Makefile \
3033          platforms/ubuntu/bacula-fd \
3034          platforms/ubuntu/bacula-sd \
3035          platforms/ubuntu/bacula-dir"
3036    else 
3037       PFILES="${PFILES} \
3038          platforms/debian/Makefile \
3039          platforms/debian/bacula-fd \
3040          platforms/debian/bacula-sd \
3041          platforms/debian/bacula-dir"
3042    fi
3043   ;;
3044 freebsd)
3045    DISTVER=`uname -a |awk '{print $3}'`
3046    VER=`echo $DISTVER | cut -c 1`
3047    if test x$VER = x4 ; then
3048       PTHREAD_LIB="${PTHREAD_LIBS:--pthread}"
3049       CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS:--pthread}"
3050    fi
3051    lld="qd"
3052    llu="qu"
3053    TAPEDRIVE="/dev/nrsa0"
3054    PSCMD="ps -ax -o pid,command"
3055    PFILES="${PFILES} \
3056        platforms/freebsd/Makefile \
3057        platforms/freebsd/bacula-fd \
3058        platforms/freebsd/bacula-sd \
3059        platforms/freebsd/bacula-dir"
3060    largefile_support="yes"
3061   ;;
3062 hpux)
3063    PSCMD="UNIX95=1; ps -e -o pid,comm"
3064    CFLAGS="${CFLAGS} -D_XOPEN_SOURCE_EXTENDED=1"
3065    DISTVER=`uname -r`
3066    TAPEDRIVE="/dev/rmt/0hnb"
3067    PTHREAD_LIB="-lpthread"
3068    AC_DEFINE([_INCLUDE_LONGLONG])
3069   ;;
3070 irix)
3071    DISTVER=`uname -r`
3072    TAPEDRIVE="/dev/rmt/0cbn"
3073    PSCMD="ps -e -o pid,comm"
3074    PFILES="${PFILES} \
3075        platforms/irix/Makefile \
3076        platforms/irix/bacula-fd \
3077        platforms/irix/bacula-sd \
3078        platforms/irix/bacula-dir"
3079   ;;
3080 netbsd)
3081    DISTVER=`uname -a |awk '{print $3}'`
3082    lld="qd"
3083    llu="qu"
3084    TAPEDRIVE="/dev/nrst0"
3085    PSCMD="ps -ax -o pid,command"
3086    PTHREAD_LIB="-pthread"
3087    CFLAGS="${CFLAGS} -pthread"
3088   ;;
3089 openbsd)
3090    DISTVER=`uname -a |awk '{print $3}'`
3091    lld="qd"
3092    llu="qu"
3093    TAPEDRIVE="/dev/nrst0"
3094    PSCMD="ps -ax -o pid,command"
3095    PTHREAD_LIB="-pthread"
3096    CFLAGS="${CFLAGS} -pthread"
3097    PFILES="${PFILES} \
3098        platforms/openbsd/Makefile \
3099        platforms/openbsd/bacula-fd \
3100        platforms/openbsd/bacula-sd \
3101        platforms/openbsd/bacula-dir"
3102   ;;
3103 redhat)
3104    if test -f /etc/whitebox-release ; then
3105       f=/etc/whitebox-release
3106    else
3107       f=/etc/redhat-release
3108    fi
3109    if test `cat $f | grep release |\
3110          cut -f 3 -d ' '`x = "Enterprise"x ; then
3111       DISTVER="Enterprise "`cat $f | grep release |\
3112           cut -f 6 -d ' '`
3113    else
3114        DISTVER=`cat /etc/redhat-release | grep release |\
3115            cut -f 5 -d ' '`
3116    fi
3117    TAPEDRIVE="/dev/nst0"
3118    PSCMD="ps -e -o pid,command"
3119    PFILES="${PFILES} \
3120        platforms/redhat/Makefile \
3121        platforms/redhat/bacula-fd \
3122        platforms/redhat/bacula-sd \
3123        platforms/redhat/bacula-dir
3124        "
3125   ;;
3126 mandrake)
3127    DISTVER=`cat /etc/mandrake-release | grep release |\
3128       cut -f 5 -d ' '`
3129    TAPEDRIVE="/dev/nst0"
3130    PSCMD="ps -e -o pid,command"
3131    PFILES="${PFILES} \
3132        platforms/mandrake/Makefile \
3133        platforms/mandrake/bacula-fd \
3134        platforms/mandrake/bacula-sd \
3135        platforms/mandrake/bacula-dir \
3136        "
3137   ;;
3138 gentoo)
3139    DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
3140    TAPEDRIVE="/dev/nst0"
3141    PSCMD="ps -e -o pid,command"
3142    PFILES="${PFILES} \
3143        platforms/gentoo/Makefile \
3144     platforms/gentoo/bacula-init \
3145        platforms/gentoo/bacula-fd \
3146        platforms/gentoo/bacula-sd \
3147        platforms/gentoo/bacula-dir"
3148   ;;
3149 slackware)
3150    DISTVER=`cat /etc/slackware-version`
3151    TAPEDRIVE="/dev/nst0"
3152    PSCMD="ps -e -o pid,command"
3153    PFILES="${PFILES} \
3154        platforms/slackware/Makefile \
3155        platforms/slackware/rc.bacula-fd \
3156        platforms/slackware/rc.bacula-sd \
3157        platforms/slackware/rc.bacula-dir\
3158        platforms/slackware/functions.bacula"
3159   ;;
3160 solaris)
3161    DISTVER=`uname -r`
3162    TAPEDRIVE="/dev/rmt/0cbn"
3163    PSCMD="ps -e -o pid,comm"
3164    PFILES="${PFILES} \
3165        platforms/solaris/Makefile \
3166        platforms/solaris/bacula-fd \
3167        platforms/solaris/bacula-sd \
3168        platforms/solaris/bacula-dir"
3169    if test x$DISTVER = x5.6 ; then
3170        AC_DEFINE(HAVE_OLD_SOCKOPT)
3171    fi
3172    LIBS="$LIBS -lresolv -lrt"
3173   ;;
3174 suse)
3175    DISTVER=`cat /etc/SuSE-release |grep VERSION|\
3176        cut -f 3 -d ' '`
3177    TAPEDRIVE="/dev/nst0"
3178    PSCMD="ps -e -o pid,command"
3179    PFILES="${PFILES} \
3180        platforms/suse/Makefile \
3181        platforms/suse/bacula-fd \
3182        platforms/suse/bacula-sd \
3183        platforms/suse/bacula-dir \
3184        platforms/suse/bacula"
3185   ;;
3186 suse5)
3187    DISTNAME=suse
3188    DISTVER=5.x
3189    TAPEDRIVE="/dev/nst0"
3190    PSCMD="ps -e -o pid,command"
3191    PFILES="${PFILES} \
3192        platforms/suse/Makefile \
3193        platforms/suse/bacula-fd \
3194        platforms/suse/bacula-sd \
3195        platforms/suse/bacula-dir"
3196   ;;
3197 unknown)
3198    DISTVER=unknown
3199    TAPEDRIVE="/dev/nst0"
3200   ;;
3201 *)
3202   echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
3203   ;;
3204 esac  
3205
3206 AC_SUBST(hostname)
3207
3208 LIBS="$PTHREAD_LIB $LIBS"
3209
3210 AC_DEFINE_UNQUOTED(lld, "$lld")
3211 AC_DEFINE_UNQUOTED(llu, "$llu")
3212 AC_SUBST(TAPEDRIVE)
3213 AC_SUBST(PSCMD)
3214 AC_SUBST(WIN32)
3215 AC_SUBST(MACOSX)
3216 AC_SUBST(DISTNAME)
3217 AC_SUBST(DISTVER)
3218
3219 dnl common parts of the Makefile
3220 MCOMMON=./autoconf/Make.common
3221 AC_SUBST_FILE(MCOMMON)
3222
3223 dnl Insanity check
3224 if test "x${subsysdir}" = "x${sbindir}" ; then
3225    echo " "
3226    echo " "
3227    echo "You have set both --sbindir and --with-subsys-dir"
3228    echo "  equal to: ${subsysdir} "
3229    echo "This is not permitted. Please reconfigure."
3230    echo " "
3231    echo "Aborting configuration ..."
3232    echo " "
3233    echo " "
3234    exit 1
3235 fi 
3236
3237 AC_OUTPUT([autoconf/Make.common \
3238            Makefile \
3239            manpages/Makefile \
3240            scripts/startmysql \
3241            scripts/stopmysql \
3242            scripts/btraceback \
3243            scripts/startit \
3244            scripts/stopit \
3245            scripts/bconsole \
3246            scripts/gconsole \
3247            scripts/bacula \
3248            scripts/bacula-ctl-dir \
3249            scripts/bacula-ctl-fd \
3250            scripts/bacula-ctl-sd \
3251            scripts/devel_bacula \
3252            scripts/Makefile \
3253            scripts/logrotate \
3254            scripts/bacula.desktop.gnome1 \
3255            scripts/bacula.desktop.gnome2 \
3256            scripts/bacula.desktop.gnome1.consolehelper \
3257            scripts/bacula.desktop.gnome2.consolehelper \
3258            scripts/bacula.desktop.gnome1.xsu \
3259            scripts/bacula.desktop.gnome2.xsu \
3260            scripts/bgnome-console.console_apps \
3261            scripts/mtx-changer \
3262            scripts/disk-changer \
3263            scripts/dvd-handler \
3264            scripts/dvd-simulator \
3265            scripts/bacula-tray-monitor.desktop \
3266            scripts/logwatch/Makefile \
3267            scripts/logwatch/logfile.bacula.conf \
3268            scripts/wxconsole.console_apps \
3269            scripts/wxconsole.desktop.consolehelper \
3270            scripts/wxconsole.desktop.xsu \
3271            scripts/bat.desktop \
3272            scripts/bat.desktop.xsu \
3273            scripts/bat.desktop.consolehelper \
3274            scripts/bat.console_apps \
3275            src/Makefile \
3276            src/host.h \
3277            src/console/Makefile \
3278            src/console/bconsole.conf \
3279            src/qt-console/tray-monitor/tray-monitor.pro \
3280            src/qt-console/tray-monitor/tray-monitor.conf \
3281            src/qt-console/bat.conf \
3282            src/qt-console/bat.pro \
3283            src/qt-console/bat.pro.mingw32 \
3284            src/qt-console/install_conf_file \
3285            src/wx-console/Makefile \
3286            src/wx-console/bwx-console.conf \
3287            src/tray-monitor/Makefile \
3288            src/tray-monitor/tray-monitor.conf \
3289            src/dird/Makefile \
3290            src/dird/bacula-dir.conf \
3291            src/lib/Makefile \
3292            src/stored/Makefile \
3293            src/stored/bacula-sd.conf \
3294            src/filed/Makefile \
3295            src/filed/bacula-fd.conf \
3296            src/cats/Makefile \
3297            src/cats/make_catalog_backup.pl \
3298            src/cats/make_catalog_backup \
3299            src/cats/delete_catalog_backup \
3300            src/cats/create_postgresql_database \
3301            src/cats/update_postgresql_tables \
3302            src/cats/make_postgresql_tables \
3303            src/cats/grant_postgresql_privileges \
3304            src/cats/drop_postgresql_tables \
3305            src/cats/drop_postgresql_database \
3306            src/cats/create_mysql_database \
3307            src/cats/update_mysql_tables \
3308            src/cats/make_mysql_tables \
3309            src/cats/grant_mysql_privileges \
3310            src/cats/drop_mysql_tables \
3311            src/cats/drop_mysql_database \
3312            src/cats/create_sqlite3_database \
3313            src/cats/update_sqlite3_tables \
3314            src/cats/make_sqlite3_tables \
3315            src/cats/grant_sqlite3_privileges \
3316            src/cats/drop_sqlite3_tables \
3317            src/cats/drop_sqlite3_database \
3318            src/cats/create_ingres_database \
3319            src/cats/update_ingres_tables \
3320            src/cats/make_ingres_tables \
3321            src/cats/grant_ingres_privileges \
3322            src/cats/drop_ingres_tables \
3323            src/cats/drop_ingres_database \
3324            src/cats/sqlite \
3325            src/cats/mysql \
3326            src/cats/create_bacula_database \
3327            src/cats/update_bacula_tables \
3328            src/cats/grant_bacula_privileges \
3329            src/cats/make_bacula_tables \
3330            src/cats/drop_bacula_tables \
3331            src/cats/drop_bacula_database \
3332            src/findlib/Makefile \
3333            src/tools/Makefile \
3334            src/plugins/fd/Makefile \
3335            src/plugins/sd/Makefile \
3336            src/plugins/dir/Makefile \
3337            src/win32/Makefile.inc \
3338            po/Makefile.in \
3339            updatedb/update_mysql_tables_9_to_10 \
3340            updatedb/update_sqlite3_tables_9_to_10 \
3341            updatedb/update_postgresql_tables_9_to_10 \
3342            updatedb/update_mysql_tables_10_to_11 \
3343            updatedb/update_sqlite3_tables_10_to_11 \
3344            updatedb/update_postgresql_tables_10_to_11 \
3345            updatedb/update_mysql_tables_11_to_12 \
3346            updatedb/update_sqlite3_tables_11_to_12 \
3347            updatedb/update_postgresql_tables_11_to_12 \
3348            examples/nagios/check_bacula/Makefile \
3349            $PFILES ],  
3350      [ ]
3351 )
3352
3353 if test "${support_bat}" = "yes" ; then
3354    if test "x$QMAKE" = "xnone"; then
3355       AC_MSG_ERROR([Could not find qmake $PATH. Check your Qt installation])
3356    fi
3357
3358    QMAKEBIN="qmake"
3359    cd src/qt-console
3360    echo "Creating bat Makefile"
3361    touch bat
3362    chmod 755 bat
3363    rm -f Makefile
3364    $QMAKEBIN
3365    ${MAKE:-make} clean
3366    cd ${BUILD_DIR}
3367 fi
3368
3369 dnl
3370 dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
3371 dnl requires gcc).  If it's not, don't rebuild dependencies
3372 dnl
3373 if test X"$GCC" = "Xyes" ; then
3374   echo "Doing make of dependencies"
3375   ${MAKE:-make} depend
3376 fi
3377
3378 cd src/qt-console
3379 chmod 755 install_conf_file build-depkgs-qt-console
3380 cd ${BUILD_DIR}
3381
3382 cd scripts
3383 chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
3384 chmod 755 dvd-handler dvd-simulator
3385 chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate
3386 cd ..
3387
3388 c=updatedb
3389 chmod 755 $c/update_mysql_tables_10_to_11   $c/update_sqlite3_tables_10_to_11
3390 chmod 755 $c/update_postgresql_tables_10_to_11
3391 chmod 755 $c/update_mysql_tables_11_to_12   $c/update_sqlite3_tables_11_to_12
3392 chmod 755 $c/update_postgresql_tables_11_to_12
3393
3394
3395 c=src/cats
3396
3397 chmod 755 $c/create_bacula_database   $c/update_bacula_tables  $c/make_bacula_tables
3398 chmod 755 $c/grant_bacula_privileges  $c/drop_bacula_tables    $c/drop_bacula_database
3399
3400 chmod 755 $c/create_mysql_database    $c/update_mysql_tables   $c/make_mysql_tables
3401 chmod 755 $c/grant_mysql_privileges   $c/drop_mysql_tables     $c/drop_mysql_database
3402
3403 chmod 755 $c/create_sqlite3_database   $c/update_sqlite3_tables  $c/make_sqlite3_tables
3404 chmod 755 $c/grant_sqlite3_privileges  $c/drop_sqlite3_tables    $c/drop_sqlite3_database
3405
3406 chmod 755 $c/create_postgresql_database  $c/update_postgresql_tables $c/make_postgresql_tables
3407 chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables   $c/drop_postgresql_database
3408
3409 chmod 755 $c/create_ingres_database  $c/update_ingres_tables $c/make_ingres_tables
3410 chmod 755 $c/grant_ingres_privileges $c/drop_ingres_tables   $c/drop_ingres_database
3411
3412
3413 chmod 755 $c/make_catalog_backup $c/delete_catalog_backup  $c/make_catalog_backup.pl
3414 chmod 755 $c/sqlite
3415 chmod 755 $c/mysql
3416
3417 chmod 755 src/win32/build-depkgs-mingw32
3418
3419 if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
3420    largefile_support="yes"
3421 fi
3422
3423 dnl Only try to find out the version number of the compiler when we know its some kind of GCC compiler
3424 if test X"$GCC" = "Xyes" ; then
3425    dnl
3426    dnl A whole lot of hand springs to get the compiler version.
3427    dnl  This is because gcc changed the output in version 3.0
3428    dnl
3429    CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 3 -d ' '`
3430    if test "x${CCVERSION}" = "x" ; then
3431       CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 1 -d ' '`
3432    fi
3433    CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
3434    if test x"${CXXVERSION}" = x ; then
3435       CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
3436    fi
3437 fi
3438
3439 # clean up any old junk
3440 echo " "
3441 echo "Cleaning up"
3442 echo " "
3443 ${MAKE:-make} clean
3444
3445 echo "
3446 Configuration on `date`:
3447
3448    Host:                     ${host}${post_host} -- ${DISTNAME} ${DISTVER}
3449    Bacula version:           ${BACULA} ${VERSION} (${DATE})
3450    Source code location:     ${srcdir}
3451    Install binaries:         ${sbindir}
3452    Install libraries:        ${libdir}
3453    Install config files:     ${sysconfdir}
3454    Scripts directory:        ${scriptdir}
3455    Archive directory:        ${archivedir}
3456    Working directory:        ${working_dir}
3457    PID directory:            ${piddir}
3458    Subsys directory:         ${subsysdir}
3459    Man directory:            ${mandir}
3460    Data directory:           ${datarootdir}
3461    Plugin directory:         ${plugindir}
3462    C Compiler:               ${CC} ${CCVERSION}
3463    C++ Compiler:             ${CXX} ${CXXVERSION}
3464    Compiler flags:           ${WCFLAGS} ${CFLAGS} 
3465    Linker flags:             ${WLDFLAGS} ${LDFLAGS}
3466    Libraries:                ${LIBS}
3467    Statically Linked Tools:  ${support_static_tools}
3468    Statically Linked FD:     ${support_static_fd}
3469    Statically Linked SD:     ${support_static_sd}
3470    Statically Linked DIR:    ${support_static_dir}
3471    Statically Linked CONS:   ${support_static_cons}
3472    Database backends:        ${db_backends}
3473    Database port:            ${db_port}
3474    Database name:            ${db_name}
3475    Database user:            ${db_user}
3476  
3477    Job Output Email:         ${job_email}
3478    Traceback Email:          ${dump_email}
3479    SMTP Host Address:        ${smtp_host}
3480  
3481    Director Port:            ${dir_port}
3482    File daemon Port:         ${fd_port}
3483    Storage daemon Port:      ${sd_port}
3484  
3485    Director User:            ${dir_user}
3486    Director Group:           ${dir_group}
3487    Storage Daemon User:      ${sd_user}
3488    Storage DaemonGroup:      ${sd_group}
3489    File Daemon User:         ${fd_user}
3490    File Daemon Group:        ${fd_group}
3491  
3492    Large file support:      $largefile_support
3493    Bacula conio support:    ${got_conio} ${CONS_LIBS}
3494    readline support:        ${got_readline} ${PRTREADLINE_SRC}
3495    TCP Wrappers support:    ${TCPW_MSG} ${WRAPLIBS}
3496    TLS support:             ${support_tls}
3497    Encryption support:      ${support_crypto} 
3498    ZLIB support:            ${have_zlib}
3499    enable-smartalloc:       ${support_smartalloc} 
3500    enable-lockmgr:          ${support_lockmgr}
3501    bat support:             ${support_bat}
3502    enable-gnome:            ${support_gnome} ${gnome_version}
3503    enable-bwx-console:      ${support_wx_console} ${wx_version}
3504    enable-tray-monitor:     ${support_tray_monitor}
3505    client-only:             ${build_client_only}
3506    build-dird:              ${build_dird}
3507    build-stored:            ${build_stored}
3508    Plugin support:          ${have_plugins}
3509    AFS support:             ${have_afs}
3510    ACL support:             ${have_acl}
3511    XATTR support:           ${have_xattr}
3512    Python support:          ${support_python} ${PYTHON_LIBS}
3513    Batch insert enabled:    ${support_batch_insert}
3514
3515   " > config.out
3516
3517 # create a small shell script useful for support with
3518 # configure options and config.out info
3519 cat > scripts/bacula_config << EOF
3520 #!/bin/sh
3521 cat << __EOC__
3522 $ $0 $ac_configure_args
3523 EOF
3524 cat config.out >> scripts/bacula_config
3525 echo __EOC__ >> scripts/bacula_config
3526 chmod 755 scripts/bacula_config
3527
3528 cat config.out