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