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