]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/configure.in
kes Begin implemention of Optimize Job Scheduling.
[bacula/bacula] / bacula / autoconf / configure.in
1 lal#
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 require a recent autoconf
16 AC_PREREQ(2.59)
17
18
19 dnl search for true and false programs.
20 AC_PATH_PROGS(TRUEPRG, true, :)
21 AC_PATH_PROGS(FALSEPRG, false, :)
22
23
24 dnl bacula version
25 VERSION=`sed -n -e 's/^.*VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
26 DATE=`sed -n -e 's/^.*[ \t]*BDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
27 LSMDATE=`sed -n -e 's/^.*LSMDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
28 AC_SUBST(VERSION)dnl 
29 AC_SUBST(DATE)dnl 
30 AC_SUBST(LSMDATE)dnl 
31 echo "configuring for bacula $VERSION ($DATE)"
32
33
34 dnl -------------------------------------------------------
35 dnl# Check for compiler.
36 dnl ------------------------------------------------------
37
38 AC_PROG_CC
39 AC_PROG_CXX
40 AC_PROG_CC_C_O                  dnl Determine if C compiler support -c -o.
41 AC_PROG_GCC_TRADITIONAL         dnl Determine if ioctl() need -traditional.
42
43 BASECC=`basename $CC`
44 have_gcc=no
45 if test "x$BASECC" = xgcc; then
46    AC_DEFINE(HAVE_GCC)
47    have_gcc=yes
48 fi
49 AC_PATH_PROG(CXX, $CXX, $CXX)
50 if test ! -e $CXX; then
51    AC_MSG_ERROR(Unable to find C++ compiler)
52 fi
53
54 dnl -------------------------------------------------------
55 dnl# Check for programs.
56 dnl ------------------------------------------------------
57 AC_PROG_INSTALL
58 AC_PROG_RANLIB
59 AC_PATH_PROG(MV, mv, mv)
60 AC_PATH_PROG(RM, rm, rm)
61 AC_PATH_PROG(CP, cp, cp)
62 AC_PATH_PROG(SED, sed, sed)
63 AC_PATH_PROG(ECHO, echo, echo)
64 AC_PATH_PROG(CMP, cmp, cmp)
65 AC_PATH_PROG(TBL, tbl, tbl)
66 AC_PATH_PROG(AR, ar, ar)
67 dnl AC_PATH_PROG(RANLIB, ranlib, ranlib)
68 AC_PATH_PROG(OPENSSL, openssl, none)
69 AC_PATH_PROG(MTX, mtx, mtx)
70 AC_PATH_PROG(DD, dd, dd)
71 AC_PATH_PROG(MKISOFS, mkisofs, mkisofs)
72 AC_PATH_PROG(PYTHON, python, python)
73 AC_PATH_PROG(GROWISOFS, growisofs, growisofs)
74 AC_PATH_PROG(DVDRWMEDIAINFO, dvd+rw-mediainfo, dvd+rw-mediainfo)
75 AC_PATH_PROG(DVDRWFORMAT, dvd+rw-format, dvd+rw-format)
76 AC_PATH_PROG(PKGCONFIG, pkg-config, pkg-config)
77 AC_ARG_VAR(WXCONFIG, [wx-config command. On some systems, you must set it to wx-config-2.6 to use wxWidgets 2.6.])
78 if test "x$WXCONFIG" = x; then
79   WXCONFIG=wx-config
80 fi
81 AC_PATH_PROG(WXCONFIG, ${WXCONFIG}, ${WXCONFIG})
82 AC_ARG_VAR(WXFLAGS, [Parameters to pass to wx-config (e.g. --unicode=no).])
83 AC_PATH_PROG(CDRECORD, cdrecord, cdrecord)
84 AC_PATH_PROG(PIDOF, pidof, pidof)
85 AC_PROG_AWK
86 # Some AWK programs fail, so test it and warn the user
87 if echo xfoo | $AWK 'BEGIN { prog=ARGV[1]; ARGC=1 } 
88       { if ((prog == $2) || (("(" prog ")") == $2) ||
89            (("[" prog "]") == $2) ||
90            ((prog ":") == $2)) { print $1 ; exit 0 } }' xfoo>/dev/null; then :;
91 else
92   AC_MSG_ERROR([!!!!!!!!! WARNING !!!!!!!!!!!!!!
93    The regex engine of $AWK is too broken to be used you 
94    might want to install GNU AWK.
95    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!])
96 fi
97 THE_AWK=$AWK
98 AC_PATH_PROG(AWK, $THE_AWK, $THE_AWK)
99
100
101 test -n "$ARFLAG" || ARFLAGS="cr"
102 AC_SUBST(ARFLAGS)
103
104 MAKE_SHELL=/bin/sh
105 AC_SUBST(MAKE_SHELL)
106
107 AC_SUBST(LOCAL_LIBS)
108 AC_SUBST(LOCAL_CFLAGS)
109 AC_SUBST(LOCAL_LDFLAGS)
110 AC_SUBST(LOCAL_DEFS)
111
112 dnl --------------------------------------------------
113 dnl Bacula OP Sys determination (see aclocal.m4)
114 dnl --------------------------------------------------
115 BA_CHECK_OPSYS
116
117 # -----------------------------------------------------------
118 dnl Bacula OPSys Distribution determination (see aclocal.m4)
119 # ----------------------------------------------------------
120 BA_CHECK_OPSYS_DISTNAME
121
122 # --------------------------------------------------
123 # Suppport for gettext (translations)
124 # By default, $datadir is ${prefix}/share
125 # --------------------------------------------------
126 AM_GNU_GETTEXT([external])
127 if test x${prefix} = xNONE ; then
128    if test `eval echo ${datadir}` = NONE/share ; then
129       datadir=/usr/share
130    fi
131 fi
132
133 # ------------------------------------------------------------------
134 #  If the user has not set --prefix, we set our default to nothing.
135 #  In this case, if the user has not set --sysconfdir, we set it
136 #  to the package default of /etc/bacula.  If either --prefix or
137 #  --sysconfdir is set, we leave sysconfdir alone except to eval it.
138 # ------------------------------------------------------------------
139 if test x${prefix} = xNONE ; then
140     if test `eval echo ${sysconfdir}` = NONE/etc ; then
141         sysconfdir=/etc/bacula
142     fi
143     prefix=
144 fi
145 sysconfdir=`eval echo ${sysconfdir}`
146 datadir=`eval echo ${datadir}`
147 localedir=`eval echo ${datadir}/locale`
148 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir") 
149 AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")
150
151 # -------------------------------------------------------------------------
152 #  If the user has not set --exec-prefix, we default to ${prefix}
153 # -------------------------------------------------------------------------
154 if test x${exec_prefix} = xNONE ; then
155     exec_prefix=${prefix}
156 fi
157
158 # ------------------------------------------------------------------
159 # If the user has not set --sbindir, we set our default as /sbin
160 # ------------------------------------------------------------------
161 if test x$sbindir = x'${exec_prefix}/sbin' ; then
162     sbindir=${exec_prefix}/sbin
163 fi
164 sbindir=`eval echo ${sbindir}`
165
166 # -------------------------------------------------------------------------
167 #  If the user has not set --mandir, we default to /usr/share/man
168 # -------------------------------------------------------------------------
169 if test x$mandir = x'${prefix}/man' ; then
170    mandir=/usr/share/man
171 fi
172
173                       
174 AC_PATH_PROGS(MSGFMT, msgfmt, no)
175 if test "$MSGFMT" = "no"
176 then
177    echo 'msgfmt program not found, disabling NLS !'
178    USE_NLS=no
179    USE_INCLUDED_LIBINTL=no
180 #else
181     AM_GNU_GETTEXT
182 fi
183
184
185 support_mysql=no
186 support_sqlite=no
187 support_sqlite3=no
188 support_postgresql=no
189 support_smartalloc=yes
190 support_readline=yes
191 support_conio=yes
192 support_gnome=no
193 support_bat=no
194 support_wx_console=no
195 support_tls=no
196 support_crypto=no
197 gnome_version=
198 wx_version=
199 support_static_tools=no
200 support_static_fd=no
201 support_static_sd=no
202 support_static_dir=no
203 support_static_cons=no
204 support_python=no
205 build_client_only=no
206 build_dird=yes
207 build_stored=yes
208 cats=
209 db_type=Internal
210 DB_TYPE=bdb
211
212 dnl# --------------------------------------------------------------------------
213 dnl# CHECKING COMMAND LINE OPTIONS
214 dnl# --------------------------------------------------------------------------
215
216 # -------------------------------------------
217 # gnome (default off)
218 # -------------------------------------------
219 AC_ARG_ENABLE(gnome,
220   [  --enable-gnome       enable build of bgnome-console GUI [disabled]],
221   [if test x$enableval = xyes; then
222     support_gnome=yes
223   fi])
224
225 GNOME_DIR=
226 if test x$support_gnome = xyes; then
227   abc=`$PKGCONFIG --exists libgnomeui-2.0`
228   pkg=$?
229   if test $pkg = 0; then
230      GNOME_INCLUDEDIR=`$PKGCONFIG --cflags-only-I libgnomeui-2.0`
231      GNOMEUI_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
232      GNOME_LIBDIR=`$PKGCONFIG --libs libgnomeui-2.0`
233      GNOME_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
234      AC_SUBST(GNOME_INCLUDEDIR)
235      AC_SUBST(GNOMEUI_LIBS)
236      AC_SUBST(GNOME_LIBDIR)
237      AC_SUBST(GNOME_LIBS)
238      GNOME_DIR=src/gnome2-console
239      gnome_version="Version 2.x"
240   else
241      AC_MSG_ERROR(Unable to find Gnome 2 installation)
242   fi
243 fi
244 AC_SUBST(GNOME_DIR)
245
246 # -------------------------------------------
247 # bat (default off)
248 # -------------------------------------------
249 AC_ARG_ENABLE(bat,
250   [  --enable-bat       enable build of bat Qt4 GUI [disabled]],
251   [if test x$enableval = xyes; then
252     AC_DEFINE(HAVE_BAT, 1, [Set if Bacula bat Qt4 GUI support enabled]) 
253     support_bat=yes
254   fi])
255
256 BAT_DIR=
257 if test x$support_bat = xyes; then
258   abc=`$PKGCONFIG --atleast-version=4.2 QtGui`
259   pkg=$?
260   if test $pkg = 0; then
261      BAT_DIR=src/qt-console
262   else
263      AC_MSG_ERROR(Unable to find Qt4 installation needed by bat)
264   fi
265 fi
266
267
268 #  If bat is enabled, we need the qwt library
269 got_qwt=no
270 QWT_INC=
271 QWT_LDFLAGS=
272 if test x$support_bat = xyes; then
273    AC_MSG_CHECKING(for qwt support)
274    AC_ARG_WITH(qwt,
275      [ --with-qwt@<:@=DIR@:>@             specify qwt library directory],
276      [
277         case "$with_qwt" in
278         no)
279           ;;
280         yes|*)
281           if test -f ${with_qwt}/include/qwt.h; then
282              QWT_INC="${with_qwt}/include"
283              QWT_LDFLAGS="-L${with_qwt}/lib"
284           fi
285           ;;
286         esac
287      ]   
288    )
289 #
290 # Search in standard places, or --with-qwt not specified
291 #
292    if test x$QWT_INC = x; then
293       for root in /usr /usr/local; do
294          for ver in qwt qwt5 qwt-qt4; do
295             if test -f ${root}/include/${ver}/qwt.h; then
296                QWT_INC="${root}/include/${ver}"
297                if test -d ${root}/lib64/; then
298                   QWT_LDFLAGS="-L${root}/lib64"
299                else
300                   QWT_LDFLAGS="-L${root}/lib"
301                fi
302                got_qwt=yes
303                break;
304             fi
305          done
306       done
307    fi
308    if test x$QWT_INC = x; then
309       AC_MSG_RESULT(no)
310       AC_MSG_ERROR(Unable to find qwt package needed by bat)
311       BAT_DIR=
312       support_bat=no
313    else
314       AC_MSG_RESULT(yes)
315    fi
316 fi
317
318 AC_SUBST(BAT_DIR)
319 AC_SUBST(QWT_INC)
320 AC_SUBST(QWT_LDFLAGS)
321
322
323 # -------------------------------------------
324 # bwx-console (default off)
325 # -------------------------------------------
326 AC_ARG_ENABLE(bwx-console,
327   [  --enable-bwx-console     enable build of wxWidgets console [disabled]],
328   [if test x$enableval = xyes; then
329     support_wx_console=yes
330   fi])
331
332 WX_DIR=
333 if test x$support_wx_console = xyes; then
334   abc=`$WXCONFIG $WXFLAGS --cppflags`
335   pkg=$?
336   if test $pkg = 0; then
337      wx_version="wxWidgets `$WXCONFIG $WXFLAGS --release`"
338      WXCONS_CPPFLAGS=`$WXCONFIG $WXFLAGS --cppflags`
339      WXCONS_LDFLAGS=`$WXCONFIG $WXFLAGS --libs`
340
341      AC_SUBST(WXCONS_CPPFLAGS)
342      AC_SUBST(WXCONS_LDFLAGS)
343      WX_DIR=src/wx-console
344   else
345      echo " "
346      echo "wx-config program not found. bwx-console disabled."
347      echo " "
348      support_wx_console=no
349   fi
350 fi
351 AC_SUBST(WX_DIR)
352
353
354 # -------------------------------------------
355 # tray-monitor (default off)
356 # -------------------------------------------
357 AC_ARG_ENABLE(tray-monitor,
358   [  --enable-tray-monitor   enable build of Gnome tray monitor (compatible with KDE) [disabled]],
359   [if test x$enableval = xyes; then
360     support_tray_monitor=yes
361   fi])
362
363 TRAY_MONITOR_DIR=
364 if test x$support_tray_monitor = xyes; then
365   abc=`$PKGCONFIG --exists gtk+-2.0`
366   pkg=$?
367   if test $pkg = 0; then
368      TRAY_MONITOR_CPPFLAGS=`$PKGCONFIG --cflags gtk+-2.0`
369      TRAY_MONITOR_LDFLAGS=`$PKGCONFIG --libs gtk+-2.0`
370      AC_SUBST(TRAY_MONITOR_CPPFLAGS)
371      AC_SUBST(TRAY_MONITOR_LDFLAGS)
372      TRAY_MONITOR_DIR=src/tray-monitor
373      abc=`$PKGCONFIG --atleast-version=2.4 gtk+-2.0`
374      pkg=$?
375      if test $pkg = 0; then
376         AC_DEFINE(HAVE_GTK_2_4, 1, [Set if you have GTK 4.2 or greater loaded])
377      fi
378   fi
379 fi
380 AC_SUBST(TRAY_MONITOR_DIR)
381
382 # -------------------------------------------
383 # smartalloc (default off)
384 # -------------------------------------------
385 AC_ARG_ENABLE(smartalloc,
386   [  --enable-smartalloc     enable smartalloc debugging support [disabled]],
387   [if test x$enableval = xno; then
388     support_smartalloc=no
389   fi])
390
391 if test x$support_smartalloc = xyes; then
392    AC_DEFINE(SMARTALLOC, 1, [Set if you want Smartalloc enabled])
393 fi
394
395 # -------------------------------------------
396 # static-tools (default off)
397 # -------------------------------------------
398 AC_ARG_ENABLE(static-tools,
399    [  --enable-static-tools   enable static tape tools [disabled]],
400    [if test x$enableval = xyes; then
401      support_static_tools=yes
402    fi])
403
404 TTOOL_LDFLAGS=
405 if test x$support_static_tools = xyes; then
406    TTOOL_LDFLAGS="-static"
407 fi
408 AC_SUBST(TTOOL_LDFLAGS)
409
410 # -------------------------------------------
411 # static-fd    (default off)
412 # -------------------------------------------
413 AC_ARG_ENABLE(static-fd,
414    [  --enable-static-fd      enable static File daemon [disabled]],
415    [if test x$enableval = xyes; then
416      support_static_fd=yes
417    fi])
418
419 STATIC_FD=
420 if test x$support_static_fd = xyes; then
421    STATIC_FD="static-bacula-fd"
422 fi
423 AC_SUBST(STATIC_FD)
424
425 # -------------------------------------------
426 # static-sd    (default off)
427 # -------------------------------------------
428 AC_ARG_ENABLE(static-sd,
429    [  --enable-static-sd      enable static Storage daemon [disabled]],
430    [if test x$enableval = xyes; then
431      support_static_sd=yes
432    fi])
433
434 STATIC_SD=
435 if test x$support_static_sd = xyes; then
436    STATIC_SD="static-bacula-sd"
437 fi
438 AC_SUBST(STATIC_SD)
439
440 # -------------------------------------------
441 # static-dir   (default off)
442 # -------------------------------------------
443 AC_ARG_ENABLE(static-dir,
444    [  --enable-static-dir     enable static Director [disabled]],
445    [if test x$enableval = xyes; then
446      support_static_dir=yes
447    fi])
448
449 STATIC_DIR=
450 if test x$support_static_dir = xyes; then
451    STATIC_DIR="static-bacula-dir"
452 fi
453 AC_SUBST(STATIC_DIR)
454
455 # -------------------------------------------
456 # static-cons  (default off)
457 # -------------------------------------------
458 AC_ARG_ENABLE(static-cons,
459    [  --enable-static-cons    enable static Console [disabled]],
460    [if test x$enableval = xyes; then
461      support_static_cons=yes
462    fi])
463
464 STATIC_CONS=
465 STATIC_GNOME_CONS=
466 STATIC_WX_CONS=
467 if test x$support_static_cons = xyes; then
468    STATIC_CONS="static-bconsole"
469    STATIC_GNOME_CONS="static-bgnome-console"
470    STATIC_WX_CONS="static-bwx-console"
471 fi
472 AC_SUBST(STATIC_CONS)
473 AC_SUBST(STATIC_GNOME_CONS)
474 AC_SUBST(STATIC_WX_CONS)
475
476 # -------------------------------------------
477 # client_only  (default off)
478 # -------------------------------------------
479 AC_ARG_ENABLE(client-only,
480    [  --enable-client-only    build client (File daemon) only [disabled]],
481    [if test x$enableval = xyes; then
482       build_client_only=yes
483       db_type=None
484       DB_TYPE=none
485    fi])
486 if test x$build_client_only = xno; then
487    ALL_DIRS="subdirs"
488 else
489    ALL_DIRS=""
490 fi
491 AC_SUBST(ALL_DIRS)
492
493 # -------------------------------------------
494 # director  (default on)
495 # -------------------------------------------
496 AC_ARG_ENABLE(build-dird,
497    [  --enable-build-dird     enable building of dird (Director) [enabled]],
498    [if test x$enableval = xno; then
499       build_dird=no
500    fi])
501 if test x$build_dird = xyes; then
502    DIRD_DIR="src/dird"
503    DIR_TOOLS="DIRTOOLS"
504 else
505    DIRD_DIR=""
506    DIR_TOOLS="NODIRTOOLS"
507 fi
508 AC_SUBST(DIRD_DIR)
509 AC_SUBST(DIR_TOOLS)
510
511 # -------------------------------------------
512 # stored  (default on)
513 # -------------------------------------------
514 AC_ARG_ENABLE(build-stored,
515    [  --enable-build-stored   enable building of stored (Storage daemon) [enabled]],
516    [if test x$enableval = xno; then
517       build_stored=no
518    fi])
519 if test x$build_stored = xyes; then
520    STORED_DIR="src/stored"
521 else
522    STORED_DIR=""
523 fi
524 AC_SUBST(STORED_DIR)
525
526 # ---------------------------------------------------
527 # Check for conio (Bacula readline substitute)(
528 # ---------------------------------------------------
529 # this allows you to turn it completely off
530 AC_ARG_ENABLE(conio,
531   [ --disable-conio disable conio support [enabled]
532                                               ],
533   [if test x$enableval = xno; then
534      support_conio=no
535   fi]
536 )
537   
538
539 # ---------------------------------------------------
540 # Check for IPv6 support
541 # ---------------------------------------------------
542 # this allows you to turn it completely off
543 support_ipv6=yes
544 AC_ARG_ENABLE(ipv6,   
545   [  --enable-ipv6                  enable ipv6 support [enabled]
546                                                       ],
547   [if test x$enableval = xno; then
548      support_ipv6=no  
549   fi]
550 )
551
552 if test x$support_ipv6 = xyes; then
553     AC_TRY_LINK([ #include <sys/types.h>
554 #include <sys/socket.h>
555 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;],
556       [support_ipv6=yes], [support_ipv6=no])
557 fi
558
559 if test x$support_ipv6 = xyes; then
560    AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
561 fi
562
563
564
565 got_conio="no"
566 if test x$support_conio = xyes; then
567    AC_CHECK_HEADER(termcap.h, 
568      [ AC_CHECK_LIB(termcap, tgetent, 
569        [ CONS_LIBS="-ltermcap"
570          CONS_OBJ="conio.o"
571          CONS_SRC="conio.c"
572          got_conio="yes"
573          support_readline=no
574          AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
575        ],   
576        [ AC_CHECK_LIB(ncurses, tgetent,
577          [ CONS_LIBS="-lncurses"
578            CONS_OBJ="conio.o"
579            CONS_SRC="conio.c"
580            got_conio="yes"
581            support_readline=no
582            AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
583          ])
584        ])
585      ],
586      [
587          AC_CHECK_HEADERS(curses.h)
588          AC_CHECK_HEADER(term.h,
589                [ AC_CHECK_LIB(curses, tgetent, 
590                  [ CONS_LIBS="-lcurses"
591                    CONS_OBJ="conio.o"
592                    CONS_SRC="conio.c"
593                    got_conio="yes"
594                    support_readline=no
595                    AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
596                  ])
597                ],
598                [ echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " "],
599 [#if HAVE_CURSES_H
600 #include <curses.h>
601 #endif
602 ])
603      ])
604 fi
605
606
607 # ---------------------------------------------------
608 # Check for readline support/directory (default off)
609 # ---------------------------------------------------
610 # this allows you to turn it completely off
611 AC_ARG_ENABLE(readline,
612   [  --disable-readline      disable readline support [disable]
613                                                       ],
614   [if test x$enableval = xno; then
615     support_readline=no
616   fi])
617
618 got_readline="no"
619 READLINE_SRC=
620 if test x$support_readline = xyes; then
621    AC_ARG_WITH(readline,
622      [ --with-readline@<:@=DIR@:>@             specify readline library directory],
623      [
624         case "$with_readline" in
625         no) : ;;
626         yes|*)
627           if test -f ${with_readline}/readline.h; then
628              CONS_INC="-I${with_readline}"
629              CONS_LDFLAGS="-L$with_readline"
630           elif test -f ${with_readline}/include/readline/readline.h; then
631              CONS_INC="-I${with_readline}/include/readline"
632              CONS_LDFLAGS="-L${with_readline}/lib"
633              with_readline="${with_readline}/include/readline"
634           else
635              with_readline="/usr/include/readline" 
636           fi
637           AC_CHECK_HEADER(${with_readline}/readline.h, 
638              [ AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
639                CONS_LIBS="-lreadline -lhistory -ltermcap"
640                got_readline="yes"   
641              ],
642              [ echo " "
643                echo "readline.h not found. readline turned off ..."
644                echo " "
645              ]
646           )
647           ;;
648         esac
649      ],[
650        # check for standard readline library
651        AC_CHECK_HEADER(/usr/include/readline/readline.h, 
652          [ AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
653            got_readline="yes"
654            CONS_INC="-I/usr/include/readline"
655            CONS_LIBS="-lreadline -ltermcap"
656          ], [
657            # Did not find standard library, so try Bacula's default
658             AC_CHECK_HEADER(${TOP_DIR}/depkgs/readline/readline.h, 
659               [ AC_DEFINE(HAVE_READLINE, 1, [Set to enable readline support])
660                  got_readline="yes"   
661                  CONS_INC="-I${TOP_DIR}/depkgs/readline"
662                  CONS_LIBS="-lreadline -lhistory -ltermcap"
663                  CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
664                  PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
665               ],
666               [ echo " "
667                 echo "readline.h not found. readline turned off ..."
668                 echo " "
669               ]
670             )
671          ]
672        )
673      ]   
674    )
675 fi
676
677
678
679 AC_SUBST(CONS_INC)
680 AC_SUBST(CONS_OBJ)
681 AC_SUBST(CONS_SRC)
682 AC_SUBST(CONS_LIBS)
683 AC_SUBST(CONS_LDFLAGS)
684 AC_SUBST(READLINE_SRC)
685
686 # Minimal stuff for readline Makefile configuration
687 MAKE_SHELL=/bin/sh
688 AC_SUBST(MAKE_SHELL)
689 AC_HEADER_STAT
690 AC_HEADER_DIRENT
691 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr lstat lchown)
692 AC_CHECK_FUNCS(nanosleep nl_langinfo)
693 AC_CHECK_HEADERS(varargs.h)
694
695 # End of readline/conio stuff
696 # -----------------------------------------------------------------------
697
698 # -----------------------------------------------------------------------
699 #  Check for Python support
700 #
701 AC_MSG_CHECKING(for Python support)
702 AC_ARG_WITH(python,
703 [
704   --with-python@<:@=DIR@:>@     Include Python support.  DIR is the Python base
705                           install directory, default is to search through
706                           a number of common places for the Python files.],
707 [
708   PYTHON_INCDIR= 
709   PYTHON_LIBS=
710   if test "$withval" != "no"; then
711      if test "$withval" = "yes"; then
712         for python_root in /usr /usr/local /usr/sfw; do
713           for ver in python2.2 python2.3 python2.4 python2.5; do
714              if test -f $python_root/include/${ver}/Python.h; then
715                 PYTHON_INCDIR=-I$python_root/include/${ver}
716                 if test -d $python_root/lib64/${ver}/config; then
717                    PYTHON_LIBS="-L$python_root/lib64/${ver}/config -l${ver}"
718                 else
719                    PYTHON_LIBS="-L$python_root/lib/${ver}/config -l${ver}"
720                 fi
721                 break 
722              fi
723           done
724         done
725         if test x$PYTHON_INCDIR = x; then
726           if test -f $prefix/include/Python.h; then
727              PYTHON_INCDIR=-I$prefix/include
728              if test -d $prefix/lib64/config; then
729                 PYTHON_LIBS="-L$prefix/lib64/config -lpython"
730              else
731                 PYTHON_LIBS="-L$prefix/lib/config -lpython"
732              fi
733           else
734            AC_MSG_RESULT(no)
735            AC_MSG_ERROR(Unable to find Python.h in standard locations)
736           fi
737         fi
738      else
739         if test -f $withval/Python.h; then
740            PYTHON_INCDIR=-I$withval
741            PYTHON_LIBS="-L$withval/config -lpython"
742         elif test -f $withval/include/Python.h; then
743            PYTHON_INCDIR=-I$withval/include
744            if test -d $withval/lib64/config; then
745               PYTHON_LIBS="-L$withval/lib64/config -lpython"
746            else
747               PYTHON_LIBS="-L$withval/lib/config -lpython"
748            fi
749         elif test -f $withval/include/python/Python.h; then
750            PYTHON_INCDIR=-I$withval/include/python
751            if test -d $withval/lib64/python/config; then
752               PYTHON_LIBS="-L$withval/lib64/python/config -lpython"
753            else
754               PYTHON_LIBS="-L$withval/lib/python/config -lpython"
755            fi
756         else
757            AC_MSG_RESULT(no)
758            AC_MSG_ERROR(Invalid Python directory $withval - unable to find Python.h under $withval)
759         fi
760      fi
761      AC_DEFINE([HAVE_PYTHON], 1)
762      AC_MSG_RESULT(yes)
763      support_python=yes
764      AC_MSG_NOTICE(checking for more Python libs)
765      saved_LIBS="$LIBS"; LIBS=
766      AC_SEARCH_LIBS(shm_open, [rt])
767      AC_CHECK_LIB(util, openpty)
768      PYTHON_LIBS="$PYTHON_LIBS $LIBS"
769      LIBS="$saved_LIBS"
770   else
771      AC_MSG_RESULT(no)
772   fi
773 ],[
774   AC_MSG_RESULT(no)
775 ])
776 AC_SUBST(PYTHON_LIBS)
777 AC_SUBST(PYTHON_INCDIR)
778
779 #
780 # Find where sockets are (especially for Solaris)
781 # Do this before the TCP Wrappers test since tcp wrappers
782 # uses the socket library and some linkers are stupid.
783 #
784 AC_CHECK_FUNC(socket,
785     AC_MSG_RESULT(using libc's socket),
786     AC_CHECK_LIB(xnet,socket)
787     AC_CHECK_LIB(socket,socket)
788     AC_CHECK_LIB(inet,socket))
789
790
791 # -----------------------------------------------------------
792 # Check whether user wants TCP wrappers support (default off)
793 # -----------------------------------------------------------
794 TCPW_MSG="no" 
795 WRAPLIBS=""
796 AC_ARG_WITH(tcp-wrappers,
797   [  --with-tcp-wrappers@<:@=DIR@:>@   enable tcpwrappers support],
798   [
799     if test "x$withval" != "xno" ; then
800        saved_LIBS="$LIBS"
801        LIBS="$saved_LIBS -lwrap"
802        AC_MSG_CHECKING(for libwrap)
803        AC_SEARCH_LIBS(nanosleep, [rt])
804        AC_TRY_LINK(
805           [ #include <sys/types.h>
806             #include <tcpd.h>
807              int deny_severity = 0;
808              int allow_severity = 0;
809              struct request_info *req; ],
810           [ hosts_access(req); ],
811           [
812             AC_MSG_RESULT(yes)
813             AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
814             TCPW_MSG="yes" 
815             LIBS="$saved_LIBS"
816             WRAPLIBS="-lwrap"
817           ], [
818             LIBS="$saved_LIBS -lwrap -lnsl"
819             WRAPLIBS="$saved_LIBS -lwrap -lnsl"
820             AC_TRY_LINK(
821               [ #include <sys/types.h>
822                  #include <tcpd.h>
823                  int deny_severity = 0;
824                  int allow_severity = 0;
825                  struct request_info *req; ],
826               [ hosts_access(req); ],
827               [
828                  AC_MSG_RESULT(yes)
829                  AC_DEFINE(HAVE_LIBWRAP, 1, [Set to enable libwraper support])
830                  TCPW_MSG="yes" 
831                  LIBS="$saved_LIBS"
832                  WRAPLIBS="-lwrap"
833               ],
834               [AC_MSG_ERROR([*** libwrap missing]) ] ]
835             )
836        )
837     fi
838   ]
839 )
840
841 # -----------------------------------------------------------
842 # Check whether OpenSSL is available
843 # -----------------------------------------------------------
844 AC_MSG_CHECKING([for OpenSSL])
845 dnl The following uses quadrigraphs:
846 dnl '@<:@' = '['
847 dnl '@:>@' = ']'
848 AC_ARG_WITH(openssl,
849         AC_HELP_STRING([--with-openssl@<:@=DIR@:>@], [Include OpenSSL support. DIR is the OpenSSL base]),
850         [with_openssl_directory=${withval}])
851
852 if test "x$with_openssl_directory" != "x"; then
853         OPENSSL_LIBS="-lssl -lcrypto"
854         OPENSSL_INC=""
855
856         if test "x$with_openssl_directory" != "xyes" && test x"${with_openssl_directory}" != "x"; then
857                 OPENSSL_LIBS="-L$with_openssl_directory/lib $OPENSSL_LIBS"
858                 OPENSSL_INC="-I$with_openssl_directory/include $OPENSSL_INC"
859         fi
860
861         saved_LIBS="${LIBS}"
862         saved_CFLAGS="${CFLAGS}"
863         LIBS="${saved_LIBS} ${OPENSSL_LIBS}"
864         CFLAGS="${saved_CFLAGS} ${OPENSSL_INC}"
865
866         AC_TRY_LINK([ #include <openssl/ssl.h> ],
867                 [ CRYPTO_set_id_callback(NULL); ],
868                 [
869                         support_tls="yes"
870                         support_crypto="yes"
871                 ],
872                 [ support_tls="no" ]
873         )
874
875         AC_TRY_LINK([ #include <openssl/evp.h> ],
876                 [ EVP_sha512(); ],
877                 [ ac_cv_openssl_sha2="yes" ],
878                 [ ac_cv_openssl_sha2="no" ]
879         )
880
881         # Solaris disables greater than 128+ bit encryption in their OpenSSL
882         # implementation, presumably for export reasons. If 192bit AES
883         # is available, we assume that we're running with a 'non-export'
884         # openssl library.
885         AC_TRY_LINK([ #include <openssl/evp.h> ],
886                 [ EVP_aes_192_cbc(); ],
887                 [ ac_cv_openssl_export="no" ],
888                 [ ac_cv_openssl_export="yes" ]
889         )
890
891         LIBS="${saved_LIBS}"
892         CFLAGS="${saved_CFLAGS}"
893
894         if test "$support_tls" = "yes"; then
895                 AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL library is available])
896                 AC_DEFINE(HAVE_TLS, 1, [Define if TLS support should be enabled])
897                 AC_DEFINE(HAVE_CRYPTO, 1, [Define if encryption support should be enabled])
898         fi
899
900         if test "$ac_cv_openssl_sha2" = "yes"; then
901                 AC_DEFINE(HAVE_SHA2, 1, [Define if the SHA-2 family of digest algorithms is available])
902         fi
903
904         if test "$ac_cv_openssl_export" = "yes"; then
905                 AC_DEFINE(HAVE_OPENSSL_EXPORT_LIBRARY, 1, [Define if the OpenSSL library is export-contrained to 128bit ciphers])
906         fi
907 else
908         support_tls="no"
909         support_crypto="no"
910         OPENSSL_LIBS=""
911         OPENSSL_INC=""
912 fi
913
914 AC_MSG_RESULT([$support_tls])
915 AC_SUBST(OPENSSL_LIBS)
916 AC_SUBST(OPENSSL_INC)
917
918
919 # -----------------------------------------------------------
920 # Python and OpenSSL are using dlopen
921 # -----------------------------------------------------------
922
923 if test "$support_python" = "yes" -o "$support_tls" = "yes"; then
924    AC_SEARCH_LIBS(dlopen, [dl])
925 fi
926
927 # ------------------------------------------
928 # Where to place working dir
929 # ------------------------------------------
930 working_dir=`eval echo ${prefix}/var/bacula/working`
931 AC_ARG_WITH(working-dir,
932    [  --with-working-dir=PATH    specify path of Bacula working directory],
933    [
934        if test "x$withval" != "xno" ; then     
935               working_dir=$withval
936        fi
937    ]
938 )
939
940 AC_SUBST(working_dir)
941
942
943 # ------------------------------------------
944 # Where to place scriptdir (script files)
945 # ------------------------------------------
946 scriptdir=`eval echo ${sysconfdir}`
947 AC_ARG_WITH(scriptdir,
948    [  --with-scriptdir=PATH    specify path of Bacula scripts directory],
949    [
950        if test "x$withval" != "xno" ; then     
951               scriptdir=$withval
952        fi
953    ]
954 )
955
956 AC_SUBST(scriptdir)
957
958
959 # ------------------------------------------
960 # Where to send dump email
961 # ------------------------------------------
962 dump_email=root@localhost
963 AC_ARG_WITH(dump-email,
964    [  --with-dump-email=EMAIL    dump email address],
965    [
966        if test "x$withval" != "xno" ; then     
967               dump_email=$withval
968        fi
969    ]
970 )
971
972 AC_SUBST(dump_email)
973
974 # ------------------------------------------
975 # Where to send job email
976 # ------------------------------------------
977 job_email=root@localhost
978 AC_ARG_WITH(job-email,
979    [  --with-job-email=EMAIL     job output email address],
980    [
981        if test "x$withval" != "xno" ; then     
982               job_email=$withval
983        fi
984    ]
985 )
986
987 AC_SUBST(job_email)
988
989 # ------------------------------------------
990 # Where to find smtp host
991 # ------------------------------------------
992 smtp_host=localhost
993 AC_ARG_WITH(smtp_host,
994    [  --with-smtp-host=HOST              SMTP mail host address],
995    [
996        if test "x$withval" != "xno" ; then     
997               smtp_host=$withval
998        fi
999    ]
1000 )
1001
1002 AC_SUBST(smtp_host)
1003
1004
1005 # ------------------------------------
1006 # Where to place pid files
1007 # ------------------------------------
1008 piddir=/var/run
1009 AC_ARG_WITH(pid-dir,
1010     [  --with-pid-dir=PATH               specify location of Bacula pid files],
1011     [
1012         if test "x$withval" != "xno" ; then     
1013             piddir=$withval
1014         fi
1015     ]
1016 )
1017
1018 AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
1019 AC_SUBST(piddir)
1020
1021
1022 # ------------------------------------
1023 # Where to place subsys "lock file"
1024 # ------------------------------------
1025 subsysdir=/var/run/subsys
1026 if test -d /var/run/subsys; then
1027    subsysdir=/var/run/subsys
1028 elif test -d /var/lock/subsys; then
1029    subsysdir=/var/lock/subsys
1030 else
1031    subsysdir=/var/run/subsys
1032 fi
1033 AC_ARG_WITH(subsys-dir,
1034     [  --with-subsys-dir=PATH    specify location of Bacula subsys file],
1035     [
1036         if test "x$withval" != "xno" ; then     
1037             subsysdir=$withval
1038         fi
1039     ]
1040 )
1041
1042 AC_SUBST(subsysdir)
1043
1044
1045
1046 # ------------------------------------
1047 # Where to start assigning ports
1048 # ------------------------------------
1049 baseport=9101
1050 AC_ARG_WITH(baseport,
1051     [  --with-baseport=PORT              specify base port address for daemons],
1052     [
1053         if test "x$withval" != "xno" ; then     
1054              baseport=$withval
1055         fi
1056     ]
1057 )
1058
1059 AC_SUBST(baseport)
1060 dir_port=`expr $baseport`
1061 fd_port=`expr $baseport + 1`
1062 sd_port=`expr $fd_port + 1`
1063
1064 AC_SUBST(dir_port)
1065 AC_SUBST(fd_port)
1066 AC_SUBST(sd_port)
1067
1068
1069 # ------------------------------------------
1070 # Generate passwords
1071 # ------------------------------------------
1072 dir_password=
1073 AC_ARG_WITH(dir-password,
1074    [  --with-dir-password=PASSWORD   specify Director's password],
1075    [
1076        if test "x$withval" != "xno" ; then     
1077            dir_password=$withval
1078        fi
1079    ]
1080 )
1081
1082 if test "x$dir_password" = "x" ; then
1083    if test "x$OPENSSL" = "xnone" ; then
1084       key=`autoconf/randpass 33`
1085    else
1086       key=`openssl rand -base64 33`
1087    fi
1088    dir_password=$key
1089 fi
1090
1091 fd_password=
1092 AC_ARG_WITH(fd-password,
1093    [  --with-fd-password=PASSWORD    specify Client's password],
1094    [
1095        if test "x$withval" != "xno" ; then     
1096            fd_password=$withval
1097        fi
1098    ]
1099 )
1100
1101 if test "x$fd_password" = "x" ; then
1102    if test "x$OPENSSL" = "xnone" ; then
1103       key=`autoconf/randpass 37`
1104    else
1105       key=`openssl rand -base64 33`
1106    fi
1107    fd_password=$key
1108 fi
1109
1110 sd_password=
1111 AC_ARG_WITH(sd-password,
1112    [  --with-sd-password=PASSWORD    specify Storage daemon's password],
1113    [
1114        if test "x$withval" != "xno" ; then     
1115            sd_password=$withval
1116        fi
1117    ]
1118 )
1119
1120 if test "x$sd_password" = "x" ; then
1121    if test "x$OPENSSL" = "xnone" ; then
1122       key=`autoconf/randpass 41`
1123    else
1124       key=`openssl rand -base64 33`
1125    fi
1126    sd_password=$key
1127 fi
1128
1129 mon_dir_password=
1130 AC_ARG_WITH(mon-dir-password,
1131    [  --with-mon-dir-password=PASSWORD   specify Director's password used by the monitor],
1132    [
1133        if test "x$withval" != "xno" ; then     
1134            mon_dir_password=$withval
1135        fi
1136    ]
1137 )
1138
1139 if test "x$mon_dir_password" = "x" ; then
1140    if test "x$OPENSSL" = "xnone" ; then
1141       key=`autoconf/randpass 33`
1142    else
1143       key=`openssl rand -base64 33`
1144    fi
1145    mon_dir_password=$key
1146 fi
1147
1148 mon_fd_password=
1149 AC_ARG_WITH(mon-fd-password,
1150    [  --with-mon-fd-password=PASSWORD    specify Client's password used by the monitor],
1151    [
1152        if test "x$withval" != "xno" ; then     
1153            mon_fd_password=$withval
1154        fi
1155    ]
1156 )
1157
1158 if test "x$mon_fd_password" = "x" ; then
1159    if test "x$OPENSSL" = "xnone" ; then
1160       key=`autoconf/randpass 37`
1161    else
1162       key=`openssl rand -base64 33`
1163    fi
1164    mon_fd_password=$key
1165 fi
1166
1167 mon_sd_password=
1168 AC_ARG_WITH(mon-sd-password,
1169    [  --with-mon-sd-password=PASSWORD    specify Storage daemon's password used by the monitor],
1170    [
1171        if test "x$withval" != "xno" ; then     
1172            mon_sd_password=$withval
1173        fi
1174    ]
1175 )
1176
1177 if test "x$mon_sd_password" = "x" ; then
1178    if test "x$OPENSSL" = "xnone" ; then
1179       key=`autoconf/randpass 41`
1180    else
1181       key=`openssl rand -base64 33`
1182    fi
1183    mon_sd_password=$key
1184 fi
1185
1186 AC_SUBST(dir_password)
1187 AC_SUBST(fd_password)
1188 AC_SUBST(sd_password)
1189 AC_SUBST(mon_dir_password)
1190 AC_SUBST(mon_fd_password)
1191 AC_SUBST(mon_sd_password)
1192
1193 #
1194 # Pickup any database name
1195 #
1196 db_name=bacula
1197 AC_ARG_WITH(db_name,
1198     [  --with-db-name=DBNAME           specify database name (default bacula)],
1199     [
1200         if test "x$withval" != "x" ; then       
1201              db_name=$withval
1202         fi
1203     ]
1204 )
1205 AC_SUBST(db_name)
1206
1207 db_user=bacula
1208 AC_ARG_WITH(db_user,
1209     [  --with-db-user=UNAME            specify database user (default bacula)],
1210     [
1211         if test "x$withval" != "x" ; then       
1212              db_user=$withval
1213         fi
1214     ]
1215 )
1216 AC_SUBST(db_user)
1217
1218
1219 #
1220 # Handle users and groups for each daemon
1221 #
1222 dir_user=
1223 AC_ARG_WITH(dir_user,
1224     [  --with-dir-user=USER              specify user for Director daemon],
1225     [
1226         if test "x$withval" != "x" ; then       
1227              dir_user=$withval
1228         fi
1229     ]
1230 )
1231
1232 dir_group=
1233 AC_ARG_WITH(dir_group,
1234     [  --with-dir-group=GROUP            specify group for Director daemon],
1235     [
1236         if test "x$withval" != "x" ; then       
1237              dir_group=$withval
1238         fi
1239     ]
1240 )
1241
1242 sd_user=
1243 AC_ARG_WITH(sd_user,
1244     [  --with-sd-user=USER               specify user for Storage daemon],
1245     [
1246         if test "x$withval" != "x" ; then       
1247              sd_user=$withval
1248         fi
1249     ]
1250 )
1251
1252 sd_group=
1253 AC_ARG_WITH(sd_group,
1254     [  --with-sd-group=GROUP             specify group for Storage daemon],
1255     [
1256         if test "x$withval" != "x" ; then       
1257              sd_group=$withval
1258         fi
1259     ]
1260 )
1261
1262 fd_user=
1263 AC_ARG_WITH(fd_user,
1264     [  --with-fd-user=USER               specify user for File daemon],
1265     [
1266         if test "x$withval" != "x" ; then       
1267              fd_user=$withval
1268         fi
1269     ]
1270 )
1271
1272 fd_group=
1273 AC_ARG_WITH(fd_group,
1274     [  --with-fd-group=GROUP             specify group for File daemon],
1275     [
1276         if test "x$withval" != "x" ; then       
1277              fd_group=$withval
1278         fi
1279     ]
1280 )
1281
1282 AC_SUBST(dir_user)
1283 AC_SUBST(dir_group)
1284 AC_SUBST(sd_user)
1285 AC_SUBST(sd_group)
1286 AC_SUBST(fd_user)
1287 AC_SUBST(fd_group)
1288
1289 #
1290 # allow setting default executable permissions
1291 #
1292 SBINPERM=0754
1293 AC_ARG_WITH(sbin-perm,
1294     [  --with-sbin-perm=MODE             specify permissions for sbin binaries (0754)],
1295     [
1296         if test "x$withval" != "x" ; then       
1297             SBINPERM=$withval
1298         fi
1299     ]
1300 )
1301
1302 AC_SUBST(SBINPERM)
1303
1304 # ------------------------------------------------
1305 # Bacula check for various SQL database engines
1306 # ------------------------------------------------
1307 SQL_LIB=
1308 BA_CHECK_POSTGRESQL_DB
1309
1310 BA_CHECK_MYSQL_DB
1311
1312 BA_CHECK_SQLITE3_DB
1313
1314 BA_CHECK_SQLITE_DB
1315
1316 AC_SUBST(cats)
1317 AC_SUBST(DB_TYPE)
1318
1319 # -------------------------------------------
1320 # enable batch attribute DB insert (default on)
1321 # -------------------------------------------
1322 support_batch_insert=no
1323 A=`nm $SQL_LIB | grep pthread_mutex_lock`
1324 pkg=$?
1325 if test $pkg = 0; then
1326    support_batch_insert=yes
1327    AC_ARG_ENABLE(batch-insert,
1328      [  --enable-batch-insert       enable the DB batch insert code [disabled]],
1329      [if test x$enableval = xno; then
1330        support_batch_insert=no
1331       else
1332        support_batch_insert=yes
1333      fi])
1334 fi
1335         
1336 # Check if postgresql support batch mode        
1337 if test x$DB_TYPE = xpostgresql; then
1338    A=`nm $SQL_LIB | grep PQputCopyData`
1339    pkg=$?
1340    if test $pkg != 0; then
1341       support_batch_insert=no
1342    fi
1343 fi
1344
1345 if test $support_batch_insert = yes ; then
1346    AC_DEFINE(HAVE_BATCH_FILE_INSERT, 1, [Set if DB batch insert code enabled])
1347 fi
1348
1349
1350 AC_DEFINE(PROTOTYPES)
1351
1352 dnl# --------------------------------------------------------------------------
1353 dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
1354 dnl#
1355 if test -z "$CFLAGS" -o "$CFLAGS" = "-g -O2"; then
1356     if test -z "$CCOPTS"; then
1357         CCOPTS='-g -O2 -Wall'
1358     fi
1359     CFLAGS="$CCOPTS"
1360 fi
1361
1362
1363 dnl A few others 
1364 AC_EXEEXT
1365
1366 dnl See if we can use 64 bit file addresses
1367 largefile_support="no"
1368 AC_BAC_LARGEFILE
1369
1370
1371 AC_PATH_XTRA
1372
1373 dnl# --------------------------------------------------------------------------
1374 dnl# CHECKING FOR HEADER FILES
1375 dnl# --------------------------------------------------------------------------
1376 AC_CHECK_HEADERS( \
1377         assert.h \
1378         fcntl.h \
1379         grp.h \
1380         pwd.h \
1381         libc.h \
1382         limits.h \
1383         stdarg.h \
1384         stdlib.h \
1385         stdint.h \
1386         string.h \
1387         termios.h \
1388         termcap.h \
1389         term.h \
1390         unistd.h \
1391         sys/bitypes.h \
1392         sys/byteorder.h \
1393         sys/ioctl.h \
1394         sys/select.h \
1395         sys/sockio.h \
1396         sys/time.h \
1397         sys/socket.h \
1398         arpa/nameser.h \
1399         resolv.h \
1400         mtio.h \
1401         sys/mtio.h \
1402         sys/tape.h \
1403         regex.h \
1404 )
1405 AC_HEADER_STDC
1406 AC_HEADER_MAJOR
1407 AC_HEADER_DIRENT
1408 AC_HEADER_STAT
1409 AC_HEADER_SYS_WAIT
1410 AC_HEADER_TIME
1411 AC_STRUCT_ST_BLKSIZE
1412 AC_STRUCT_ST_BLOCKS
1413 AC_STRUCT_TIMEZONE
1414
1415 dnl# --------------------------------------------------------------------------
1416 dnl# Check for utime.h structure 
1417 dnl# --------------------------------------------------------------------------
1418 AC_CACHE_CHECK(for utime.h, ba_cv_header_utime_h,
1419   [AC_TRY_COMPILE([
1420 #include <sys/types.h>
1421 #include <utime.h>], [struct utimbuf foo],
1422   ba_cv_header_utime_h=yes, ba_cv_header_utime_h=no)])
1423 test $ba_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H, 1, [Set if utime.h exists])
1424
1425 dnl# --------------------------------------------------------------------------
1426 dnl# Check for socklen_t
1427 dnl# --------------------------------------------------------------------------
1428 AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
1429   [AC_TRY_COMPILE([
1430 #include <sys/types.h>
1431 #include <sys/socket.h>],
1432   [socklen_t x],
1433   ba_cv_header_socklen_t=yes, ba_cv_header_socklen_t=no)])
1434 test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T)
1435
1436 dnl# --------------------------------------------------------------------------
1437 dnl# Check for bigendian
1438 dnl# --------------------------------------------------------------------------
1439 AC_CACHE_CHECK([for bigendian], ba_cv_bigendian,
1440   [AC_TRY_RUN(
1441     [main(){long a=1L; char *p=(char *)&a; exit(*p);}],
1442     [ba_cv_bigendian=yes], 
1443     [ba_cv_bigendian=no], 
1444     [ba_cv_bigendian=no])])
1445 test $ba_cv_bigendian = yes && AC_DEFINE(HAVE_BIGENDIAN)
1446
1447 dnl# --------------------------------------------------------------------------
1448 dnl# Check for typeof()
1449 dnl# --------------------------------------------------------------------------
1450 AC_LANG_PUSH(C++)
1451 AC_CACHE_CHECK(for typeof, ba_cv_have_typeof,
1452   [AC_TRY_RUN(
1453     [main(){char *a = 0; a = (typeof a)a;}],
1454     [ba_cv_have_typeof=yes],
1455     [ba_cv_have_typeof=no],
1456     [ba_cv_have_typeof=no])])
1457 test $ba_cv_have_typeof = yes && AC_DEFINE([HAVE_TYPEOF], 1, [Defind to 1 if compiler has typeof])
1458 AC_LANG_POP(C++)
1459
1460 AC_C_CONST
1461
1462
1463 dnl# --------------------------------------------------------------------------
1464 dnl# CHECKING FOR FILESYSTEM TYPE
1465 dnl# --------------------------------------------------------------------------
1466 AC_MSG_CHECKING(how to get filesystem type)
1467 fstype=no
1468 # The order of these tests is important.
1469 AC_TRY_CPP([#include <sys/statvfs.h>
1470 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
1471 if test $fstype = no; then
1472 AC_TRY_CPP([#include <sys/statfs.h>
1473 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
1474 fi
1475 if test $fstype = no; then
1476 AC_TRY_CPP([#include <sys/statfs.h>
1477 #include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
1478 fi
1479 if test $fstype = no; then  
1480 AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
1481 fi
1482 if test $fstype = no; then  
1483 AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
1484 fi
1485 if test $fstype = no; then  
1486 AC_TRY_CPP([#include <sys/mount.h>
1487 #include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
1488 fi
1489 AC_MSG_RESULT($fstype)
1490
1491 AC_CHECK_HEADER(sys/statvfs.h, [ AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Defines if your system have the sys/statvfs.h header file])] , )
1492
1493 dnl# --------------------------------------------------------------------------
1494 dnl# CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
1495 dnl# --------------------------------------------------------------------------
1496 AC_TYPE_SIGNAL
1497 SIGNAL_CHECK
1498 AC_TYPE_MODE_T
1499 AC_TYPE_UID_T
1500 AC_TYPE_SIZE_T
1501 AC_TYPE_PID_T
1502 AC_TYPE_OFF_T
1503 AC_CHECK_TYPE(ino_t, unsigned long)
1504 AC_CHECK_TYPE(dev_t, unsigned long)
1505 AC_CHECK_TYPE(daddr_t, long)
1506 AC_CHECK_TYPE(major_t, int)
1507 AC_CHECK_TYPE(minor_t, int)
1508 AC_CHECK_TYPE(ssize_t, int)
1509 AC_STRUCT_ST_BLOCKS
1510 AC_STRUCT_ST_RDEV
1511 AC_STRUCT_TM
1512 AC_C_CONST
1513
1514
1515 AC_CHECK_SIZEOF(char, 1)
1516 AC_CHECK_SIZEOF(short int, 2)
1517 AC_CHECK_SIZEOF(int, 4)
1518 AC_CHECK_SIZEOF(long int, 4)
1519 AC_CHECK_SIZEOF(long long int, 8)
1520 AC_CHECK_SIZEOF(int *, 4)
1521
1522 # Check for sys/types.h types
1523 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1524     AC_TRY_COMPILE(
1525         [ #include <sys/types.h> ], 
1526         [ u_int a; a = 1;], 
1527         [ ac_cv_have_u_int="yes" ],
1528         [ ac_cv_have_u_int="no" ]
1529     )
1530 ])
1531 if test "x$ac_cv_have_u_int" = "xyes" ; then
1532    AC_DEFINE(HAVE_U_INT)
1533    have_u_int=1
1534 fi
1535
1536 AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t, [
1537    AC_TRY_COMPILE(
1538       [ #include <sys/types.h> ], 
1539       [ intmax_t a; a = 1;], 
1540       [ ac_cv_have_intmax_t="yes" ],
1541       [ 
1542          AC_TRY_COMPILE(
1543             [ #include <stdint.h> ], 
1544             [ intmax_t a; a = 1;], 
1545             [ ac_cv_have_intmax_t="yes" ],
1546             [ ac_cv_have_intmax_t="no" ]
1547          )
1548       ]
1549    )        
1550
1551 ])
1552 if test "x$ac_cv_have_intmax_t" = "xyes" ; then
1553    AC_DEFINE(HAVE_INTMAX_T)
1554    have_intmax_t=1
1555 fi
1556
1557
1558 AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t, [
1559    AC_TRY_COMPILE(
1560       [ #include <sys/types.h> ], 
1561       [ u_intmax_t a; a = 1;], 
1562       [ ac_cv_have_u_intmax_t="yes" ],
1563       [ 
1564          AC_TRY_COMPILE(
1565             [ #include <stdint.h> ], 
1566             [ u_intmax_t a; a = 1;], 
1567             [ ac_cv_have_u_intmax_t="yes" ],
1568             [ ac_cv_have_u_intmax_t="no" ]
1569          )
1570       ]
1571    )
1572 ])
1573 if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
1574    AC_DEFINE(HAVE_U_INTMAX_T)
1575    have_u_intmax_t=1
1576 fi
1577
1578
1579 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1580    AC_TRY_COMPILE(
1581       [ #include <sys/types.h> ], 
1582       [ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
1583       [ ac_cv_have_intxx_t="yes" ],
1584       [ ac_cv_have_intxx_t="no" ]
1585    )
1586 ])
1587 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1588    AC_DEFINE(HAVE_INTXX_T)
1589    have_intxx_t=1
1590 fi
1591         
1592 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1593    AC_TRY_COMPILE(
1594       [ #include <sys/types.h> ], 
1595       [ int64_t a; a = 1;], 
1596       [ ac_cv_have_int64_t="yes" ],
1597       [ ac_cv_have_int64_t="no" ]
1598    )
1599 ])
1600 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1601    AC_DEFINE(HAVE_INT64_T)
1602    have_int64_t=1
1603 fi
1604         
1605 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1606    AC_TRY_COMPILE(
1607       [ #include <sys/types.h> ], 
1608       [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
1609       [ ac_cv_have_u_intxx_t="yes" ],
1610       [ ac_cv_have_u_intxx_t="no" ]
1611    )
1612 ])
1613 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1614    AC_DEFINE(HAVE_U_INTXX_T)
1615    have_u_intxx_t=1
1616 fi
1617
1618 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1619    AC_TRY_COMPILE(
1620       [ #include <sys/types.h> ], 
1621       [ u_int64_t a; a = 1;], 
1622       [ ac_cv_have_u_int64_t="yes" ],
1623       [ ac_cv_have_u_int64_t="no" ]
1624    )
1625 ])
1626 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1627    AC_DEFINE(HAVE_U_INT64_T)
1628    have_u_int64_t=1
1629 fi
1630
1631 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1632            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1633 then
1634    AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1635    AC_TRY_COMPILE(
1636       [ #include <sys/bitypes.h>  ], 
1637       [ int8_t a; int16_t b; int32_t c;
1638         u_int8_t e; u_int16_t f; u_int32_t g;
1639         a = b = c = e = f = g = 1;  ], 
1640       [ AC_DEFINE(HAVE_U_INTXX_T)
1641         AC_DEFINE(HAVE_INTXX_T)
1642         AC_DEFINE(HAVE_SYS_BITYPES_H)
1643         AC_MSG_RESULT(yes) ],
1644       [ AC_MSG_RESULT(no)]
1645    ) 
1646 fi
1647
1648 if test -z "$have_u_intxx_t" ; then
1649    AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1650       AC_TRY_COMPILE(
1651          [ #include <sys/types.h> ], 
1652          [ uint8_t a; uint16_t b; 
1653            uint32_t c; a = b = c = 1; ], 
1654          [ ac_cv_have_uintxx_t="yes" ],
1655          [ ac_cv_have_uintxx_t="no" ]
1656       )
1657    ])
1658    if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1659       AC_DEFINE(HAVE_UINTXX_T)
1660    fi
1661 fi
1662
1663 if (test -z "$have_u_int64_t" || test -z "$have_int64_t" && \
1664           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1665 then
1666    AC_MSG_CHECKING([for int64_t and u_int64_t types in sys/bitypes.h])
1667    AC_TRY_COMPILE(
1668       [ #include <sys/bitypes.h>  ], 
1669       [ int64_t a; u_int64_t b; 
1670        a = b = 1;  ], 
1671       [ AC_DEFINE(HAVE_U_INT64_T)
1672        AC_DEFINE(HAVE_INT64_T)
1673        AC_MSG_RESULT(yes) ],
1674       [ AC_MSG_RESULT(no)]
1675    ) 
1676 fi
1677
1678 if (test -z "$have_uintxx_t" && \
1679           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1680 then
1681    AC_MSG_CHECKING([for uintXX_t types in sys/bitypes.h])
1682    AC_TRY_COMPILE(
1683       [ #include <sys/bitypes.h>  ], 
1684         [ uint8_t a; uint16_t b; 
1685           uint32_t c; a = b = c = 1; ], 
1686       [ AC_DEFINE(HAVE_UINTXX_T)
1687        AC_MSG_RESULT(yes) ],
1688       [ AC_MSG_RESULT(no)]
1689    ) 
1690
1691 fi
1692
1693
1694
1695
1696 dnl# --------------------------------------------------------------------------
1697 dnl# CHECKING FOR REQUIRED LIBRARY FUNCTIONS
1698 dnl# --------------------------------------------------------------------------
1699 AC_CHECK_FUNCS( \
1700         fork \
1701         getcwd \
1702         gethostname \
1703         getpid \
1704         gettimeofday \
1705         setpgid \
1706         setpgrp \
1707         setsid \
1708         signal \
1709         strerror \
1710         strncmp \
1711         strncpy \
1712         vfprintf \
1713         ,,
1714         [echo 'configure: cannot find needed function.'; exit 1]
1715 )
1716
1717 AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
1718 AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)])
1719 AC_CHECK_FUNCS(posix_fadvise)
1720 AC_CHECK_FUNCS(fdatasync)
1721
1722 AC_CHECK_FUNCS(chflags) 
1723
1724 AC_CHECK_FUNCS(snprintf vsnprintf gethostid fseeko)
1725
1726 AC_CACHE_CHECK(for va_copy, ba_cv_va_copy,
1727   [AC_TRY_LINK([
1728 #include <stdarg.h>
1729 void use_va_copy(va_list args){va_list args2; va_copy(args2,args); va_end(args2);}
1730 void call_use_va_copy(int junk,...){va_list args; va_start(args,junk); use_va_copy(args); va_end(args);}
1731 ],
1732   [call_use_va_copy(1,2,3)],
1733   ba_cv_va_copy=yes, ba_cv_va_copy=no)])
1734 test $ba_cv_va_copy = yes && AC_DEFINE(HAVE_VA_COPY, 1, [Set if va_copy exists])
1735
1736
1737 dnl# --------------------------------------------------------------------------
1738 dnl# CHECKING FOR THREAD SAFE FUNCTIONS
1739 dnl# --------------------------------------------------------------------------
1740 AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
1741
1742 # If resolver functions are not in libc check for -lnsl or -lresolv.
1743 AC_CHECK_FUNC(gethostbyname_r,
1744     AC_MSG_RESULT(using libc's resolver),
1745     AC_CHECK_LIB(nsl,gethostbyname_r)
1746     AC_CHECK_LIB(resolv,gethostbyname_r))
1747
1748
1749
1750 AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
1751 AC_CHECK_FUNCS(inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
1752 AC_CHECK_FUNCS(gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2)])
1753
1754 dnl ----------------------------
1755 dnl check sa_len of sockaddr
1756 dnl ----------------------------
1757 AC_CACHE_CHECK(for struct sockaddr has a sa_len field, ac_cv_struct_sockaddr_sa_len,
1758   [AC_TRY_COMPILE([#include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
1759   ac_cv_struct_sockaddr_sa_len=yes, ac_cv_struct_sockaddr_sa_len=no)])
1760
1761  if test $ac_cv_struct_sockaddr_sa_len = yes; then
1762   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
1763  fi
1764
1765
1766
1767
1768 AC_FUNC_STRFTIME
1769 AC_FUNC_VPRINTF
1770 AC_FUNC_ALLOCA
1771 AC_FUNC_GETMNTENT
1772 AC_FUNC_CLOSEDIR_VOID
1773 AC_FUNC_SETPGRP                       dnl check for BSD setpgrp.
1774 # AC_FUNC_FNMATCH    dnl use local version
1775
1776
1777 AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"])
1778
1779
1780 AC_CHECK_LIB(sun, getpwnam)
1781
1782 AC_CHECK_HEADERS(zlib.h)
1783 AC_CHECK_LIB(z, deflate, [FDLIBS="-lz"])
1784 have_zlib=no
1785 if test x$FDLIBS = x-lz; then
1786   AC_DEFINE(HAVE_LIBZ)
1787   have_zlib=yes
1788 fi
1789
1790 #
1791 # Check for ACL libraries
1792 #
1793 have_acl=no
1794 AC_CHECK_HEADER(sys/acl.h)
1795 AC_CHECK_FUNC(acl_get_file, [have_acl=yes],
1796    [AC_CHECK_LIB(acl, acl_get_file, [have_acl=yes; FDLIBS="-lacl $FDLIBS"], 
1797       [AC_CHECK_LIB(sec, acltotext, [have_acl=yes; FDLIBS="-lsec $FDLIBS"])]
1798     )]
1799 )
1800 if test $have_acl = yes; then
1801    AC_DEFINE(HAVE_ACL)
1802 fi
1803
1804 dnl Check for pthread libraries
1805 PTHREAD_LIB=""
1806 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
1807    [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
1808       [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
1809             [AC_CHECK_FUNC(pthread_create)]
1810        )]
1811     )]
1812 )
1813
1814 AC_SUBST(FDLIBS)
1815 AC_DEFINE(FDLIBS)
1816
1817
1818 CFLAGS=${CFLAGS--O}
1819
1820 if test x$have_gcc = xyes ; then
1821    CPPFLAGS="$CPPFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
1822    CFLAGS="$CFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
1823 fi
1824 LDFLAGS=${LDFLAGS--O}
1825 DB_LIBS="${SQL_LFLAGS}"
1826 CPPFLAGS="$CPPFLAGS"
1827 CFLAGS="$CFLAGS"
1828 AC_SUBST(DEBUG)
1829 AC_SUBST(DINCLUDE)
1830 AC_SUBST(CFLAGS)
1831 AC_SUBST(CPPFLAGS)
1832 AC_SUBST(LDFLAGS)
1833 AC_SUBST(X_CFLAGS)
1834 AC_SUBST(DEFS)
1835 AC_SUBST(LIBS)
1836 AC_SUBST(DLIB)
1837 AC_SUBST(DB_LIBS)
1838 AC_SUBST(X_LIBS)
1839 AC_SUBST(X_EXTRA_LIBS)
1840 AC_SUBST(WCFLAGS)
1841 AC_SUBST(WLDFLAGS)
1842 AC_SUBST(WRAPLIBS)
1843
1844 dnl# extra configurable objects
1845 OBJLIST=
1846 AC_SUBST(OBJLIST)
1847
1848 lld="lld"
1849 llu="llu"
1850
1851 WCFLAGS=
1852 WLDFLAGS=
1853
1854 #
1855 # Finally we set appropriate distribution specific
1856 #  variables and defaults
1857 #
1858 # PFILES are platform specific files
1859 PFILES="platforms/Makefile"
1860 PSCMD="ps -e"
1861 WIN32=
1862 MACOSX=
1863 hostname=`uname -n | cut -d '.' -f 1`
1864 if test x${hostname} = x ; then
1865   hostname="localhost"
1866 fi
1867 case "$DISTNAME" in
1868 aix)
1869         DISTVER=`uname -r`
1870         PSCMD="ps -e -o pid,comm"
1871         PFILES="${PFILES} \
1872            platforms/aix/Makefile"
1873         TAPEDRIVE="/dev/rmt0.1" 
1874   ;;      
1875 alpha)
1876         DISTVER=`uname -r`
1877         PTHREAD_LIB="-lpthread -lexc"
1878         if test "${CC}" = "gcc" ; then
1879            lld="lld"
1880            llu="llu"
1881         else
1882            lld="ld"
1883            llu="lu"
1884         fi
1885         TAPEDRIVE="/dev/nrmt0"
1886   ;;
1887 bsdi)
1888         DISTVER=`uname -a |awk '{print $3}'`
1889         TAPEDRIVE="/dev/nrmt0"
1890         PTHREAD_LIB="-pthread"
1891         CFLAGS="${CFLAGS} -pthread"
1892         PSCMD="ps -ax -o pid,command"
1893         lld="qd"
1894         llu="qu"
1895         PFILES="${PFILES} \
1896             platforms/bsdi/Makefile \
1897             platforms/bsdi/bacula-fd \
1898             platforms/bsdi/bacula-sd \
1899             platforms/bsdi/bacula-dir"
1900         largefile_support="yes"
1901   ;;
1902 cygwin)
1903         DISTVER=`uname -a |awk '{print $3}'`
1904         TAPEDRIVE="/dev/nrst0"
1905         WIN32=win32
1906         WCFLAGS="-mwindows"
1907         WLDFLAGS="-mwindows"
1908   ;;
1909 darwin)
1910         DISTVER=`uname -r`
1911         TAPEDRIVE="/dev/nst0"
1912         PSCMD="ps -e -o pid,command"
1913         MACOSX=macosx
1914         PFILES="${PFILES} \
1915            platforms/darwin/Makefile"
1916   ;;
1917 debian)
1918         DISTVER=`cat /etc/debian_version`
1919         TAPEDRIVE="/dev/nrst0"
1920         PSCMD="ps -e -o pid,command"
1921   ;;
1922 freebsd)
1923         DISTVER=`uname -a |awk '{print $3}'`
1924         VER=`echo $DISTVER | cut -c 1`
1925         if test x$VER = x4 ; then
1926            PTHREAD_LIB="${PTHREAD_LIBS:--pthread}"
1927            CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS:--pthread}"
1928         fi
1929         lld="qd"
1930         llu="qu"
1931         TAPEDRIVE="/dev/nrsa0"
1932         PSCMD="ps -ax -o pid,command"
1933         PFILES="${PFILES} \
1934             platforms/freebsd/Makefile \
1935             platforms/freebsd/bacula-fd \
1936             platforms/freebsd/bacula-sd \
1937             platforms/freebsd/bacula-dir"
1938         largefile_support="yes"
1939   ;;
1940 hpux)
1941         PSCMD="UNIX95=1; ps -e -o pid,comm"
1942         CFLAGS="${CFLAGS} -D_XOPEN_SOURCE_EXTENDED=1"
1943         DISTVER=`uname -r`
1944         TAPEDRIVE="/dev/rmt/0hnb"
1945         PTHREAD_LIB="-lpthread"
1946         AC_DEFINE([_INCLUDE_LONGLONG])
1947   ;;
1948 irix)
1949         DISTVER=`uname -r`
1950         TAPEDRIVE="/dev/rmt/0cbn"
1951         PSCMD="ps -e -o pid,comm"
1952         PFILES="${PFILES} \
1953             platforms/irix/Makefile \
1954             platforms/irix/bacula-fd \
1955             platforms/irix/bacula-sd \
1956             platforms/irix/bacula-dir"
1957   ;;
1958 netbsd)
1959         DISTVER=`uname -a |awk '{print $3}'`
1960         lld="qd"
1961         llu="qu"
1962         TAPEDRIVE="/dev/nrst0"
1963         PSCMD="ps -ax -o pid,command"
1964         PTHREAD_LIB="-pthread"
1965         CFLAGS="${CFLAGS} -pthread"
1966   ;;
1967 openbsd)
1968         DISTVER=`uname -a |awk '{print $3}'`
1969         lld="qd"
1970         llu="qu"
1971         TAPEDRIVE="/dev/nrst0"
1972         PSCMD="ps -ax -o pid,command"
1973         PTHREAD_LIB="-pthread"
1974         CFLAGS="${CFLAGS} -pthread"
1975         PFILES="${PFILES} \
1976             platforms/openbsd/Makefile \
1977             platforms/openbsd/bacula-fd \
1978             platforms/openbsd/bacula-sd \
1979             platforms/openbsd/bacula-dir"
1980   ;;
1981 redhat)
1982         if test -f /etc/whitebox-release ; then
1983            f=/etc/whitebox-release
1984         else
1985            f=/etc/redhat-release
1986         fi
1987         if test `cat $f | grep release |\
1988                    cut -f 3 -d ' '`x = "Enterprise"x ; then
1989            DISTVER="Enterprise "`cat $f | grep release |\
1990                     cut -f 6 -d ' '`
1991         else
1992             DISTVER=`cat /etc/redhat-release | grep release |\
1993                      cut -f 5 -d ' '`
1994         fi
1995         TAPEDRIVE="/dev/nst0"
1996         PSCMD="ps -e -o pid,command"
1997         PFILES="${PFILES} \
1998             platforms/redhat/Makefile \
1999             platforms/redhat/bacula-fd \
2000             platforms/redhat/bacula-sd \
2001             platforms/redhat/bacula-dir \
2002             platforms/redhat/bacula.spec \
2003             "
2004   ;;
2005 mandrake)
2006         DISTVER=`cat /etc/mandrake-release | grep release |\
2007            cut -f 5 -d ' '`
2008         TAPEDRIVE="/dev/nst0"
2009         PSCMD="ps -e -o pid,command"
2010         PFILES="${PFILES} \
2011             platforms/mandrake/Makefile \
2012             platforms/mandrake/bacula-fd \
2013             platforms/mandrake/bacula-sd \
2014             platforms/mandrake/bacula-dir \
2015             platforms/mandrake/bacula.spec \
2016             "
2017   ;;
2018 gentoo)
2019         DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
2020         TAPEDRIVE="/dev/nst0"
2021         PSCMD="ps -e -o pid,command"
2022         PFILES="${PFILES} \
2023             platforms/gentoo/Makefile \
2024          platforms/gentoo/bacula-init \
2025             platforms/gentoo/bacula-fd \
2026             platforms/gentoo/bacula-sd \
2027             platforms/gentoo/bacula-dir"
2028   ;;
2029 slackware)
2030         DISTVER=`cat /etc/slackware-version`
2031         TAPEDRIVE="/dev/nst0"
2032         PSCMD="ps -e -o pid,command"
2033         PFILES="${PFILES} \
2034             platforms/slackware/Makefile \
2035             platforms/slackware/rc.bacula-fd \
2036             platforms/slackware/rc.bacula-sd \
2037             platforms/slackware/rc.bacula-dir\
2038             platforms/slackware/functions.bacula"
2039   ;;
2040 solaris)
2041         DISTVER=`uname -r`
2042         TAPEDRIVE="/dev/rmt/0cbn"
2043         PSCMD="ps -e -o pid,comm"
2044         PFILES="${PFILES} \
2045             platforms/solaris/Makefile \
2046             platforms/solaris/bacula-fd \
2047             platforms/solaris/bacula-sd \
2048             platforms/solaris/bacula-dir"
2049         if test x$DISTVER = x5.6 ; then
2050             AC_DEFINE(HAVE_OLD_SOCKOPT)
2051         fi
2052         LIBS="$LIBS -lresolv"
2053   ;;
2054 suse)
2055         DISTVER=`cat /etc/SuSE-release |grep VERSION|\
2056             cut -f 3 -d ' '`
2057         TAPEDRIVE="/dev/nst0"
2058         PSCMD="ps -e -o pid,command"
2059         PFILES="${PFILES} \
2060             platforms/suse/Makefile \
2061             platforms/suse/bacula-fd \
2062             platforms/suse/bacula-sd \
2063             platforms/suse/bacula-dir \
2064             platforms/suse/bacula \
2065             platforms/suse/bacula.spec"
2066   ;;
2067 suse5)
2068         DISTNAME=suse
2069         DISTVER=5.x
2070         TAPEDRIVE="/dev/nst0"
2071         PSCMD="ps -e -o pid,command"
2072         PFILES="${PFILES} \
2073             platforms/suse/Makefile \
2074             platforms/suse/bacula-fd \
2075             platforms/suse/bacula-sd \
2076             platforms/suse/bacula-dir"
2077   ;;
2078 unknown)
2079         DISTVER=unknown
2080         TAPEDRIVE="/dev/nst0"
2081   ;;
2082 *)
2083   echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
2084   ;;
2085 esac  
2086
2087 AC_SUBST(hostname)
2088
2089 LIBS="$PTHREAD_LIB $LIBS"
2090
2091 AC_DEFINE_UNQUOTED(lld, "$lld")
2092 AC_DEFINE_UNQUOTED(llu, "$llu")
2093 AC_SUBST(TAPEDRIVE)
2094 AC_SUBST(PSCMD)
2095 AC_SUBST(WIN32)
2096 AC_SUBST(MACOSX)
2097 AC_SUBST(DISTNAME)
2098 AC_SUBST(DISTVER)
2099
2100 dnl# common parts of the Makefile
2101 MCOMMON=./autoconf/Make.common
2102 AC_SUBST_FILE(MCOMMON)
2103
2104 dnl# Insanity check
2105 if test "x${subsysdir}" = "x${sbindir}" ; then
2106    echo " "
2107    echo " "
2108    echo "You have set both --sbindir and --with-subsys-dir"
2109    echo "  equal to: ${subsysdir} "
2110    echo "This is not permitted. Please reconfigure."
2111    echo " "
2112    echo "Aborting configuration ..."
2113    echo " "
2114    echo " "
2115    exit 1
2116 fi 
2117
2118 AC_OUTPUT([autoconf/Make.common \
2119            Makefile \
2120            manpages/Makefile \
2121            scripts/startmysql \
2122            scripts/stopmysql \
2123            scripts/btraceback \
2124            scripts/startit \
2125            scripts/stopit \
2126            scripts/bconsole \
2127            scripts/gconsole \
2128            scripts/bacula \
2129            scripts/bacula-ctl-dir \
2130            scripts/bacula-ctl-fd \
2131            scripts/bacula-ctl-sd \
2132            scripts/devel_bacula \
2133            scripts/Makefile \
2134            scripts/logrotate \
2135            scripts/bacula.desktop.gnome1 \
2136            scripts/bacula.desktop.gnome2 \
2137            scripts/bacula.desktop.gnome1.consolehelper \
2138            scripts/bacula.desktop.gnome2.consolehelper \
2139            scripts/bacula.desktop.gnome1.xsu \
2140            scripts/bacula.desktop.gnome2.xsu \
2141            scripts/bgnome-console.console_apps \
2142            scripts/mtx-changer \
2143            scripts/disk-changer \
2144            scripts/dvd-handler \
2145            scripts/dvd-simulator \
2146            scripts/bacula-tray-monitor.desktop \
2147            scripts/logwatch/Makefile \
2148            scripts/logwatch/logfile.bacula.conf \
2149            scripts/wxconsole.console_apps \
2150            scripts/wxconsole.desktop.consolehelper \
2151            scripts/wxconsole.desktop.xsu \
2152            scripts/bat.desktop \
2153            scripts/bat.desktop.xsu \
2154            scripts/bat.desktop.consolehelper \
2155            scripts/bat.console_apps \
2156            src/Makefile \
2157            src/host.h \
2158            src/console/Makefile \
2159            src/console/bconsole.conf \
2160            src/gnome2-console/Makefile \
2161            src/gnome2-console/bgnome-console.conf \
2162            src/qt-console/bat.conf \
2163            src/qt-console/bat.pro \
2164            src/qt-console/install_conf_file \
2165            src/wx-console/Makefile \
2166            src/wx-console/bwx-console.conf \
2167            src/tray-monitor/Makefile \
2168            src/tray-monitor/tray-monitor.conf \
2169            src/dird/Makefile \
2170            src/dird/bacula-dir.conf \
2171            src/lib/Makefile \
2172            src/stored/Makefile \
2173            src/stored/bacula-sd.conf \
2174            src/filed/Makefile \
2175            src/filed/bacula-fd.conf \
2176            src/cats/Makefile \
2177            src/cats/make_catalog_backup \
2178            src/cats/delete_catalog_backup \
2179            src/cats/create_postgresql_database \
2180            src/cats/update_postgresql_tables \
2181            src/cats/make_postgresql_tables \
2182            src/cats/grant_postgresql_privileges \
2183            src/cats/drop_postgresql_tables \
2184            src/cats/drop_postgresql_database \
2185            src/cats/create_mysql_database \
2186            src/cats/update_mysql_tables \
2187            src/cats/make_mysql_tables \
2188            src/cats/grant_mysql_privileges \
2189            src/cats/drop_mysql_tables \
2190            src/cats/drop_mysql_database \
2191            src/cats/create_sqlite_database \
2192            src/cats/update_sqlite_tables \
2193            src/cats/make_sqlite_tables \
2194            src/cats/grant_sqlite_privileges \
2195            src/cats/drop_sqlite_tables \
2196            src/cats/drop_sqlite_database \
2197            src/cats/create_sqlite3_database \
2198            src/cats/update_sqlite3_tables \
2199            src/cats/make_sqlite3_tables \
2200            src/cats/grant_sqlite3_privileges \
2201            src/cats/drop_sqlite3_tables \
2202            src/cats/drop_sqlite3_database \
2203            src/cats/sqlite \
2204            src/cats/mysql \
2205            src/cats/create_bdb_database \
2206            src/cats/update_bdb_tables \
2207            src/cats/make_bdb_tables \
2208            src/cats/grant_bdb_privileges \
2209            src/cats/drop_bdb_tables \
2210            src/cats/drop_bdb_database \
2211            src/cats/create_bacula_database \
2212            src/cats/update_bacula_tables \
2213            src/cats/grant_bacula_privileges \
2214            src/cats/make_bacula_tables \
2215            src/cats/drop_bacula_tables \
2216            src/cats/drop_bacula_database \
2217            src/findlib/Makefile \
2218            src/tools/Makefile \
2219            po/Makefile.in \
2220            $PFILES ],  
2221           [ ]
2222 )
2223
2224 if test "${support_bat}" = "yes" ; then
2225   cd src/qt-console
2226   chmod 755 install_conf_file build-depkgs-qt-console
2227   echo "Creating bat Makefile"  
2228   qmake
2229   cd ${BUILD_DIR}
2230 fi
2231
2232 echo "Doing make of dependencies"
2233 ${MAKE:-make} depend
2234
2235 cd scripts
2236 chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
2237 chmod 755 dvd-handler dvd-simulator
2238 chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate
2239 cd ..
2240
2241 c=src/cats
2242
2243 chmod 755 $c/create_bacula_database   $c/update_bacula_tables  $c/make_bacula_tables
2244 chmod 755 $c/grant_bacula_privileges  $c/drop_bacula_tables    $c/drop_bacula_database
2245
2246 chmod 755 $c/create_bdb_database      $c/update_bdb_tables     $c/make_bdb_tables
2247 chmod 755 $c/grant_bdb_privileges     $c/drop_bdb_tables       $c/drop_bdb_database
2248
2249 chmod 755 $c/create_mysql_database    $c/update_mysql_tables   $c/make_mysql_tables
2250 chmod 755 $c/grant_mysql_privileges   $c/drop_mysql_tables     $c/drop_mysql_database
2251
2252 chmod 755 $c/create_sqlite_database   $c/update_sqlite_tables  $c/make_sqlite_tables
2253 chmod 755 $c/grant_sqlite_privileges  $c/drop_sqlite_tables    $c/drop_sqlite_database
2254
2255 chmod 755 $c/create_sqlite3_database   $c/update_sqlite3_tables  $c/make_sqlite3_tables
2256 chmod 755 $c/grant_sqlite3_privileges  $c/drop_sqlite3_tables    $c/drop_sqlite3_database
2257
2258 chmod 755 $c/create_postgresql_database  $c/update_postgresql_tables $c/make_postgresql_tables
2259 chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables   $c/drop_postgresql_database
2260
2261 chmod 755 $c/make_catalog_backup $c/delete_catalog_backup
2262 chmod 755 $c/sqlite
2263 chmod 755 $c/mysql
2264
2265 chmod 755 src/win32/build-depkgs-mingw32
2266
2267
2268
2269 if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
2270    largefile_support="yes"
2271 fi
2272
2273 #
2274 # A whole lot of hand springs to get the compiler version.
2275 #  This is because gcc changed the output in version 3.0
2276 #
2277 CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 3 -d ' '`
2278 if test "x${CCVERSION}" = "x" ; then
2279   CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 1 -d ' '`
2280 fi
2281 CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
2282 if test x"${CXXVERSION}" = x ; then
2283   CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
2284 fi
2285
2286 if test "x${subsysdir}" = "x${sbindir}" ; then
2287    echo " "
2288    echo " "
2289    echo "You have set --sbindir and --with-subsys-dir"
2290    echo "  both equal to: ${subsysdir} "
2291    echo "  This is not permitted. Please reconfigure."
2292    echo " "
2293    echo "Aborting configuration ..."
2294    echo " "
2295    echo " "
2296    exit 1
2297 fi 
2298
2299 if test "x${db_type}" = "xInternal" ; then
2300    echo " "
2301    echo " "
2302    echo "You have not specified either --enable-client-only or one of the"
2303    echo "  supported databases: MySQL, PostgreSQL, SQLite3 or SQLite."
2304    echo "  This is not permitted. Please reconfigure."
2305    echo " "
2306    echo "Aborting the configuration ..."
2307    echo " "
2308    echo " "
2309    exit 1
2310 fi
2311
2312 echo "
2313 Configuration on `date`:
2314
2315   Host:                       $host -- ${DISTNAME} ${DISTVER}
2316   Bacula version:             ${VERSION} (${DATE})
2317   Source code location:       ${srcdir}
2318   Install binaries:           ${sbindir}
2319   Install config files:       ${sysconfdir}
2320   Scripts directory:          ${scriptdir}
2321   Working directory:          ${working_dir}
2322   PID directory:              ${piddir}
2323   Subsys directory:           ${subsysdir}
2324   Man directory:              ${mandir}
2325   Data directory:             ${datadir}
2326   C Compiler:                 ${CC} ${CCVERSION}
2327   C++ Compiler:               ${CXX} ${CXXVERSION}
2328   Compiler flags:             ${WCFLAGS} ${CFLAGS} 
2329   Linker flags:               ${WLDFLAGS} ${LDFLAGS}
2330   Libraries:                  ${LIBS}
2331   Statically Linked Tools:    ${support_static_tools}
2332   Statically Linked FD:       ${support_static_fd}
2333   Statically Linked SD:       ${support_static_sd}
2334   Statically Linked DIR:      ${support_static_dir}
2335   Statically Linked CONS:     ${support_static_cons}
2336   Database type:              ${db_type}
2337   Database lib:               ${DB_LIBS}
2338   Database name:              ${db_name}
2339   Database user:              ${db_user}
2340
2341   Job Output Email:           ${job_email}
2342   Traceback Email:            ${dump_email}
2343   SMTP Host Address:          ${smtp_host}
2344
2345   Director Port:              ${dir_port}
2346   File daemon Port:           ${fd_port}
2347   Storage daemon Port:        ${sd_port}
2348
2349   Director User:              ${dir_user}
2350   Director Group:             ${dir_group}
2351   Storage Daemon User:        ${sd_user}
2352   Storage DaemonGroup:        ${sd_group}
2353   File Daemon User:           ${fd_user}
2354   File Daemon Group:          ${fd_group}
2355
2356   SQL binaries Directory      ${SQL_BINDIR}
2357
2358   Large file support:         $largefile_support
2359   Bacula conio support:       ${got_conio} ${CONS_LIBS}
2360   readline support:           ${got_readline} ${PRTREADLINE_SRC}
2361   TCP Wrappers support:       ${TCPW_MSG} ${WRAPLIBS}
2362   TLS support:                ${support_tls}
2363   Encryption support:         ${support_crypto} 
2364   ZLIB support:               ${have_zlib}
2365   enable-smartalloc:          ${support_smartalloc} 
2366   bat support:                ${support_bat} ${QWT_LDFLAGS}
2367   enable-gnome:               ${support_gnome} ${gnome_version}
2368   enable-bwx-console:         ${support_wx_console} ${wx_version}
2369   enable-tray-monitor:        ${support_tray_monitor}
2370   client-only:                ${build_client_only}
2371   build-dird:                 ${build_dird}
2372   build-stored:               ${build_stored}
2373   ACL support:                ${have_acl}
2374   Python support:             ${support_python} ${PYTHON_LIBS}
2375   Batch insert enabled:       ${support_batch_insert}
2376
2377   " > config.out
2378
2379 cat config.out