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