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