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