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