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