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