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