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