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