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