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