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