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