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