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