]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/configure.in
Add src/tray-monitor directory
[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_CONFIG_AUX_DIR(${BUILD_DIR}/autoconf)
12 AC_CONFIG_HEADER(src/config.h:autoconf/config.h.in)
13
14 dnl require a recent autoconf
15 AC_PREREQ(2.13)
16
17
18 dnl search for true and false programs.
19 AC_PATH_PROGS(TRUEPRG, true, :)
20 AC_PATH_PROGS(FALSEPRG, false, :)
21
22 #AC_CANONICAL_HOST
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 if test x$CC = xgcc
44 then
45    AC_DEFINE(HAVE_GCC)
46 fi
47
48 dnl -------------------------------------------------------
49 dnl# Check for programs.
50 dnl ------------------------------------------------------
51 AC_PROG_INSTALL
52 AC_PROG_RANLIB
53 AC_PATH_PROG(MV, mv, mv)
54 AC_PATH_PROG(RM, rm, rm)
55 AC_PATH_PROG(CP, cp, cp)
56 AC_PATH_PROG(SED, sed, sed)
57 AC_PATH_PROG(AWK, awk, awk)
58 AC_PATH_PROG(ECHO, echo, echo)
59 AC_PATH_PROG(CMP, cmp, cmp)
60 AC_PATH_PROG(TBL, tbl, tbl)
61 AC_PATH_PROG(AR, ar, ar)
62 dnl AC_PATH_PROG(RANLIB, ranlib, ranlib)
63 AC_PATH_PROG(OPENSSL, openssl, none)
64 AC_PATH_PROG(MTX, mtx, mtx)
65 AC_PATH_PROG(PKGCONFIG, pkg-config, pkg-config)
66 AC_PATH_PROG(WXCONFIG, wx-config, wx-config)
67
68 test -n "$ARFLAG" || ARFLAGS="cr"
69 AC_SUBST(ARFLAGS)
70
71 MAKE_SHELL=/bin/sh
72 AC_SUBST(MAKE_SHELL)
73
74 AC_SUBST(LOCAL_LIBS)
75 AC_SUBST(LOCAL_CFLAGS)
76 AC_SUBST(LOCAL_LDFLAGS)
77 AC_SUBST(LOCAL_DEFS)
78
79
80
81 dnl --------------------------------------------------
82 dnl Bacula OP Sys determination (see aclocal.m4)
83 dnl --------------------------------------------------
84 BA_CHECK_OPSYS
85
86 # -----------------------------------------------------------
87 dnl Bacula OPSys Distribution determination (see aclocal.m4)
88 # ----------------------------------------------------------
89 BA_CHECK_OPSYS_DISTNAME
90
91 # -----------------------------------------------------------
92 dnl Check for gnome stuff for gnome-console
93 # ----------------------------------------------------------
94 AM_ACLOCAL_INCLUDE(gnome-macros)
95
96 # ------------------------------------------------------------------
97 #  If the user has not set --prefix, we set our default to nothing.
98 #  In this case, if the user has not set --sysconfdir, we set it
99 #  to the package default of /etc/bacula.  If either --prefix or
100 #  --sysconfdir is set, we leave sysconfdir alone except to eval it.
101 # ------------------------------------------------------------------
102 if test x${prefix} = xNONE ; then
103     if test `eval echo ${sysconfdir}` = NONE/etc ; then
104         sysconfdir=/etc/bacula
105     fi
106     prefix=
107 fi
108 sysconfdir=`eval echo ${sysconfdir}`
109
110 # -------------------------------------------------------------------------
111 #  If the user has not set --exec-prefix, we default to ${prefix}
112 # -------------------------------------------------------------------------
113 if test x${exec_prefix} = xNONE ; then
114     exec_prefix=${prefix}
115 fi
116
117 # ------------------------------------------------------------------
118 # If the user has not set --sbindir, we set our default as /sbin
119 # ------------------------------------------------------------------
120 if test x$sbindir = x'${exec_prefix}/sbin' ; then
121     sbindir=${exec_prefix}/sbin
122 fi
123 sbindir=`eval echo ${sbindir}`
124                       
125 # ------------------------------------------------------------------
126 # All list of languages for which a translation exist. Each
127 #  language is separated by a space.
128 # ------------------------------------------------------------------
129 ALL_LINGUAS=""
130
131 AC_PATH_PROGS(MSGFMT, msgfmt, no)
132 if test "$MSGFMT" = "no"
133 then
134    echo 'msgfmt program not found, disabling NLS !'
135    USE_NLS=no
136    USE_INCLUDED_LIBINTL=no
137 #else
138 #   AM_GNU_GETTEXT
139 fi
140
141
142 support_mysql=no
143 support_sqlite=no
144 support_postgresql=no
145 support_smartalloc=yes
146 support_readline=yes
147 support_conio=yes
148 support_gnome=no
149 support_wx_console=no
150 gnome_version=
151 support_static_tools=no
152 support_static_fd=no
153 support_static_sd=no
154 support_static_dir=no
155 support_static_cons=no
156 build_client_only=no
157 cats=
158 db_name=Internal
159 DB_NAME=bdb
160
161 dnl# --------------------------------------------------------------------------
162 dnl# CHECKING COMMAND LINE OPTIONS
163 dnl# --------------------------------------------------------------------------
164
165 # -------------------------------------------
166 # gnome (default off)
167 # -------------------------------------------
168 AC_ARG_ENABLE(gnome,
169   [  --enable-gnome       enable build of gnome-console GUI [disabled]],
170   [if test x$enableval = xyes; then
171     support_gnome=yes
172   fi])
173
174 GNOME_DIR=
175 if test x$support_gnome = xyes; then
176   abc=`$PKGCONFIG --exists libgnomeui-2.0`
177   pkg=$?
178   if test $pkg = 0; then
179      GNOME_INCLUDEDIR=`$PKGCONFIG --cflags-only-I libgnomeui-2.0`
180      GNOMEUI_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
181      GNOME_LIBDIR=`$PKGCONFIG --libs libgnomeui-2.0`
182      GNOME_LIBS=`$PKGCONFIG --libs-only-l libgnomeui-2.0`
183      AC_SUBST(GNOME_INCLUDEDIR)
184      AC_SUBST(GNOMEUI_LIBS)
185      AC_SUBST(GNOME_LIBDIR)
186      AC_SUBST(GNOME_LIBS)
187      GNOME_DIR=src/gnome2-console
188      gnome_version="Version 2.x"
189   else
190 dnl do 1.4 stuff
191      GNOME_INIT
192      GNOME_DIR=src/gnome-console
193      gnome_version="Version 1.4"
194   fi
195 fi
196 AC_SUBST(GNOME_DIR)
197
198
199 # -------------------------------------------
200 # wx-console (default off)
201 # -------------------------------------------
202 AC_ARG_ENABLE(wx-console,
203   [  --enable-wx-console     enable build of wxWidgets console [disabled]],
204   [if test x$enableval = xyes; then
205     support_wx_console=yes
206   fi])
207
208 WX_DIR=
209 if test x$support_wx_console = xyes; then
210   abc=`$WXCONFIG --cppflags`
211   pkg=$?
212   if test $pkg = 0; then
213      WXCONS_CPPFLAGS=`$WXCONFIG --cppflags`
214      WXCONS_LDFLAGS=`$WXCONFIG --libs`
215      AC_SUBST(WXCONS_CPPFLAGS)
216      AC_SUBST(WXCONS_LDFLAGS)
217      WX_DIR=src/wx-console
218   else
219      echo " "
220      echo "wx-config program not found. wx-console disabled."
221      echo " "
222      support_wx_console=no
223   fi
224 fi
225 AC_SUBST(WX_DIR)
226
227
228 # -------------------------------------------
229 # tray-monitor (default off)
230 # -------------------------------------------
231 AC_ARG_ENABLE(tray-monitor,
232   [  --enable-tray-monitor   enable build of Gnome tray monitor (compatible with KDE) [disabled]],
233   [if test x$enableval = xyes; then
234     support_tray_monitor=yes
235   fi])
236
237 TRAY_MONITOR_DIR=
238 if test x$support_tray_monitor = xyes; then
239 # TODO: Check for GTK+ presence
240   TRAY_MONITOR_DIR=src/tray-monitor
241 fi
242 AC_SUBST(TRAY_MONITOR_DIR)
243
244 # -------------------------------------------
245 # smartalloc (default off)
246 # -------------------------------------------
247 AC_ARG_ENABLE(smartalloc,
248   [  --enable-smartalloc     enable smartalloc debugging support [disabled]],
249   [if test x$enableval = xno; then
250     support_smartalloc=no
251   fi])
252
253 if test x$support_smartalloc = xyes; then
254    AC_DEFINE(SMARTALLOC)
255 fi
256
257 # -------------------------------------------
258 # static-tools (default off)
259 # -------------------------------------------
260 AC_ARG_ENABLE(static-tools,
261    [  --enable-static-tools   enable static tape tools [disabled]],
262    [if test x$enableval = xyes; then
263      support_static_tools=yes
264    fi])
265
266 TTOOL_LDFLAGS=
267 if test x$support_static_tools = xyes; then
268    TTOOL_LDFLAGS="-static"
269 fi
270 AC_SUBST(TTOOL_LDFLAGS)
271
272 # -------------------------------------------
273 # static-fd    (default off)
274 # -------------------------------------------
275 AC_ARG_ENABLE(static-fd,
276    [  --enable-static-fd      enable static File daemon [disabled]],
277    [if test x$enableval = xyes; then
278      support_static_fd=yes
279    fi])
280
281 STATIC_FD=
282 if test x$support_static_fd = xyes; then
283    STATIC_FD="static-bacula-fd"
284 fi
285 AC_SUBST(STATIC_FD)
286
287 # -------------------------------------------
288 # static-sd    (default off)
289 # -------------------------------------------
290 AC_ARG_ENABLE(static-sd,
291    [  --enable-static-sd      enable static Storage daemon [disabled]],
292    [if test x$enableval = xyes; then
293      support_static_sd=yes
294    fi])
295
296 STATIC_SD=
297 if test x$support_static_sd = xyes; then
298    STATIC_SD="static-bacula-sd"
299 fi
300 AC_SUBST(STATIC_SD)
301
302 # -------------------------------------------
303 # static-dir   (default off)
304 # -------------------------------------------
305 AC_ARG_ENABLE(static-dir,
306    [  --enable-static-dir     enable static Director [disabled]],
307    [if test x$enableval = xyes; then
308      support_static_dir=yes
309    fi])
310
311 STATIC_DIR=
312 if test x$support_static_dir = xyes; then
313    STATIC_DIR="static-bacula-dir"
314 fi
315 AC_SUBST(STATIC_DIR)
316
317 # -------------------------------------------
318 # static-cons  (default off)
319 # -------------------------------------------
320 AC_ARG_ENABLE(static-cons,
321    [  --enable-static-cons    enable static Console [disabled]],
322    [if test x$enableval = xyes; then
323      support_static_cons=yes
324    fi])
325
326 STATIC_CONS=
327 STATIC_GNOME_CONS=
328 STATIC_WX_CONS=
329 if test x$support_static_cons = xyes; then
330    STATIC_CONS="static-bconsole"
331    STATIC_GNOME_CONS="static-gnome-console"
332    STATIC_WX_CONS="static-wx-console"
333 fi
334 AC_SUBST(STATIC_CONS)
335 AC_SUBST(STATIC_GNOME_CONS)
336 AC_SUBST(STATIC_WX_CONS)
337
338 # -------------------------------------------
339 # client_only  (default off)
340 # -------------------------------------------
341 AC_ARG_ENABLE(client-only,
342    [  --enable-client-only    build client (File daemon) only [disabled]],
343    [if test x$enableval = xyes; then
344      build_client_only=yes
345     db_name=None
346     DB_NAME=none
347    fi])
348 if test x$build_client_only = xno; then
349    ALL_DIRS="subdirs"
350 else
351    ALL_DIRS=""
352 fi
353 AC_SUBST(ALL_DIRS)
354
355 # ---------------------------------------------------
356 # Check for conio (Bacula readline substitute)(
357 # ---------------------------------------------------
358 # this allows you to turn it completely off
359 AC_ARG_ENABLE(conio,   
360   [  --disable-conio         disable conio support [enabled]
361                                                       ],
362   [if test x$enableval = xno; then
363     support_conio=no
364   fi])
365
366 got_conio="no"
367 if test x$support_conio = xyes; then
368    AC_CHECK_HEADER(termcap.h, 
369      [ AC_CHECK_LIB(termcap, tgetent, 
370        [ CONS_LIBS="-ltermcap"
371          CONS_OBJ="conio.o"
372          CONS_SRC="conio.c"
373          got_conio="yes"
374          support_readline=no
375          AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
376        ],   
377        [ AC_CHECK_LIB(ncurses, tgetent,
378          [ CONS_LIBS="-lncurses"
379            CONS_OBJ="conio.o"
380            CONS_SRC="conio.c"
381            got_conio="yes"
382            support_readline=no
383            AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
384          ],   
385          [ echo " "; echo "Neither termcap nor ncurses library found. CONIO turned off ..."; echo " "])
386        ])
387     ],[echo " "; echo "termcap.h not found. CONIO turned off ..."; echo " "])
388 fi
389
390
391 # ---------------------------------------------------
392 # Check for readline support/directory (default off)
393 # ---------------------------------------------------
394 # this allows you to turn it completely off
395 AC_ARG_ENABLE(readline,
396   [  --disable-readline      disable readline support [disable]
397                                                       ],
398   [if test x$enableval = xno; then
399     support_readline=no
400   fi])
401
402 got_readline="no"
403 READLINE_SRC=
404 if test x$support_readline = xyes; then
405    AC_ARG_WITH(readline,
406      [ --with-readline=DIR               specify readline library directory],
407      [
408         case "$with_readline" in
409         no) : ;;
410         yes|*)
411           if test "$with_readline" != "yes"; then
412             CONS_INC="-I${with_readline}"
413             CONS_LDFLAGS="-L$with_readline"
414           else
415              with_readline="/usr/include/readline" 
416           fi
417           AC_CHECK_HEADER(${with_readline}/readline.h, 
418              [ AC_DEFINE(HAVE_READLINE) 
419                CONS_LIBS="-lreadline -ltermcap"
420                got_readline="yes"   
421              ],
422              [ echo " "
423                echo "readline.h not found. readline turned off ..."
424                echo " "
425              ]
426           )
427           ;;
428         esac
429      ],[
430        # check for standard readline library
431        AC_CHECK_HEADER(/usr/include/readline/readline.h, 
432          [ AC_DEFINE(HAVE_READLINE)
433            got_readline="yes"
434            CONS_INC="-I/usr/include/readline"
435            CONS_LIBS="-lreadline -ltermcap"
436          ], [
437            # Did not find standard library, so try Bacula's default
438             AC_CHECK_HEADER(${TOP_DIR}/depkgs/readline/readline.h, 
439               [ AC_DEFINE(HAVE_READLINE) 
440                  got_readline="yes"   
441                  CONS_INC="-I${TOP_DIR}/depkgs/readline"
442                  CONS_LIBS="-lreadline -lhistory -ltermcap"
443                  CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
444                  PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
445               ],
446               [ echo " "
447                 echo "readline.h not found. readline turned off ..."
448                 echo " "
449               ]
450             )
451          ]
452        )
453      ]   
454    )
455 fi
456
457
458
459 AC_SUBST(CONS_INC)
460 AC_SUBST(CONS_OBJ)
461 AC_SUBST(CONS_SRC)
462 AC_SUBST(CONS_LIBS)
463 AC_SUBST(CONS_LDFLAGS)
464 AC_SUBST(READLINE_SRC)
465
466 # Minimal stuff for readline Makefile configuration
467 MAKE_SHELL=/bin/sh
468 AC_SUBST(MAKE_SHELL)
469 AC_HEADER_STAT
470 AC_HEADER_DIRENT
471 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat lchown)
472 AC_CHECK_FUNCS(nanosleep nl_langinfo)
473 AC_CHECK_HEADERS(varargs.h)
474
475 # End of readline/conio stuff
476 # -----------------------------------------------------------------------
477
478
479 # ---------------------------------------------------
480 # Check for GMP support/directory
481 # ---------------------------------------------------
482 #GMP_SRC=
483 #local_gmp="no"
484 #AC_ARG_WITH(gmp,
485 #  [  --with-gmp[=DIR]   Specify gmp library directory],
486 #  [
487 #     case "$with_gmp" in
488 #     no) : ;;
489 #     yes|*)
490 #       if test "$with_gmp" != "yes"; then
491 #         GMP_INC="-I$with_gmp"
492 #         GMP_LIBS="-lgmp"
493 #         GMP_LDFLAGS="-L$with_gmp"
494 #       else
495 #          with_gmp="/usr/include" 
496 #       fi
497 #       AC_CHECK_HEADER($with_gmp/gmp.h, 
498 #          [ AC_MSG_RESULT(yes)
499 #            AC_DEFINE(HAVE_GMP) 
500 #            GMP_LIBS="-lgmp"
501 #            got_gmp="yes"   
502 #          ],
503 #          [ AC_MSG_ERROR([*** gmp library missing]) 
504 #          ]
505 #       )
506 #       ;;
507 #     esac
508 #  ],[
509 #    # check for standard gmp library
510 #    AC_CHECK_HEADER(/usr/include/gmp.h,
511 #    [ AC_MSG_RESULT(yes)
512 #      AC_DEFINE(HAVE_GMP)
513 #      got_gmp="yes"
514 #      GMP_INC=
515 #      GMP_LIBS="-lgmp"
516 #    ], [
517 #      # Did not find standard library, so use our own
518 #      AC_MSG_RESULT(yes)
519 #      AC_DEFINE(HAVE_GMP)
520 #      got_gmp="yes"
521 #      local_gmp="yes"
522 #      GMP_INC="-I${TOP_DIR}/depkgs/gmp"
523 #      GMP_LIBS="-lgmp"
524 #      GMP_LDFLAGS="-L${TOP_DIR}/depkgs/gmp"
525 #      GMP_SRC="${TOP_DIR}/depkgs/gmp"
526 #    ])
527 #  ]   
528 #)
529 #AC_SUBST(GMP_INC)
530 #AC_SUBST(GMP_LIBS)
531 #AC_SUBST(GMP_LDFLAGS)
532 #AC_SUBST(GMP_SRC)
533
534 # End of GMP stuff
535 # -----------------------------------------------------------------------
536
537
538 # ---------------------------------------------------
539 # Check for CWEB support/directory
540 # ---------------------------------------------------
541 #CWEB_SRC=
542 #CWEB=/bin
543 #local_cweb="no"
544 #AC_ARG_WITH(cweb,
545 #  [  --with-cweb[=DIR]   Specify cweb library directory],
546 #  [
547 #     case "$with_cweb" in
548 #     no) : ;;
549 #     yes|*)
550 #       if test "$with_cweb" != "yes"; then
551 #         CWEB_INC="-I$with_cweb"
552 #         CWEB_LIBS="-lcweb"
553 #         CWEB_LDFLAGS="-L$with_cweb"
554 #       else
555 #          with_cweb="/usr/include" 
556 #       fi
557 #       AC_CHECK_HEADER($with_cweb/cweb.h, 
558 #          [ AC_MSG_RESULT(yes)
559 #            AC_DEFINE(HAVE_CWEB) 
560 #            CWEB_LIBS="-lcweb"
561 #            got_cweb="yes"   
562 #          ],
563 #          [ AC_MSG_ERROR([*** cweb library missing]) 
564 #          ]
565 #       )
566 #       ;;
567 #     esac
568 #  ],[
569 #    # check for standard cweb library
570 #    AC_CHECK_HEADER(/usr/include/cweb.h,
571 #    [ AC_MSG_RESULT(yes)
572 #      AC_DEFINE(HAVE_CWEB)
573 #      got_cweb="yes"
574 #      CWEB_INC=
575 #      CWEB_LIBS="-lcweb"
576 #    ], [
577 #      # Did not find starndard library, so use our own
578 #      AC_MSG_RESULT(yes)
579 #      AC_DEFINE(HAVE_CWEB)
580 #      got_cweb="yes"
581 #      local_cweb="yes"
582 #      CWEB=${TOP_DIR}/depkgs/cweb
583 #      CWEB_INC="-I${TOP_DIR}/depkgs/cweb"
584 #      CWEB_LIBS="-lcweb"
585 #      CWEB_LDFLAGS="-L${TOP_DIR}/depkgs/cweb"
586 #      CWEB_SRC="${TOP_DIR}/depkgs/cweb"
587 #    ])
588 #  ]   
589 #)
590 #AC_SUBST(CWEB)
591 #AC_SUBST(CWEB_INC)
592 #AC_SUBST(CWEB_LIBS)
593 #AC_SUBST(CWEB_LDFLAGS)
594 #AC_SUBST(CWEB_SRC)
595
596 # End of CWEB stuff
597 # -----------------------------------------------------------------------
598
599
600
601 # -----------------------------------------------------------
602 # Check whether user wants TCP wrappers support (default off)
603 # -----------------------------------------------------------
604 TCPW_MSG="no" 
605 AC_ARG_WITH(tcp-wrappers,
606   [  --with-tcp-wrappers=DIR     enable tcpwrappers support],
607   [
608     if test "x$withval" != "xno" ; then
609        saved_LIBS="$LIBS"
610        LIBS="$saved_LIBS -lwrap"
611        AC_MSG_CHECKING(for libwrap)
612        AC_TRY_LINK(
613           [ #include <tcpd.h>
614              int deny_severity = 0;
615              int allow_severity = 0;
616              struct request_info *req; ],
617           [ hosts_access(req); ],
618           [
619             AC_MSG_RESULT(yes)
620             AC_DEFINE(HAVE_LIBWRAP)
621             TCPW_MSG="yes" 
622           ], [
623             LIBS="$saved_LIBS -lwrap -lnsl"
624             AC_TRY_LINK(
625               [ #include <tcpd.h>
626                  int deny_severity = 0;
627                  int allow_severity = 0;
628                  struct request_info *req; ],
629               [ hosts_access(req); ],
630               [
631                  AC_MSG_RESULT(yes)
632                  AC_DEFINE(HAVE_LIBWRAP)
633                  TCPW_MSG="yes" 
634               ],
635               [AC_MSG_ERROR([*** libwrap missing]) ] ]
636             )
637        )
638     fi
639   ]
640 )
641
642 # ------------------------------------------
643 # Where to place working dir
644 # ------------------------------------------
645 working_dir=`eval echo ${prefix}/var/bacula/working`
646 AC_ARG_WITH(working-dir,
647    [  --with-working-dir=PATH    specify path of Bacula working directory],
648    [
649        if test "x$withval" != "xno" ; then     
650               working_dir=$withval
651        fi
652    ]
653 )
654
655 AC_SUBST(working_dir)
656
657
658 # ------------------------------------------
659 # Where to place scriptdir (script files)
660 # ------------------------------------------
661 scriptdir=`eval echo ${sysconfdir}`
662 AC_ARG_WITH(scriptdir,
663    [  --with-scriptdir=PATH    specify path of Bacula scripts directory],
664    [
665        if test "x$withval" != "xno" ; then     
666               scriptdir=$withval
667        fi
668    ]
669 )
670
671 AC_SUBST(scriptdir)
672
673
674 # ------------------------------------------
675 # Where to send dump email
676 # ------------------------------------------
677 dump_email=root@localhost
678 AC_ARG_WITH(dump-email,
679    [  --with-dump-email=EMAIL    dump email address],
680    [
681        if test "x$withval" != "xno" ; then     
682               dump_email=$withval
683        fi
684    ]
685 )
686
687 AC_SUBST(dump_email)
688
689 # ------------------------------------------
690 # Where to send job email
691 # ------------------------------------------
692 job_email=root@localhost
693 AC_ARG_WITH(job-email,
694    [  --with-job-email=EMAIL     job output email address],
695    [
696        if test "x$withval" != "xno" ; then     
697               job_email=$withval
698        fi
699    ]
700 )
701
702 AC_SUBST(job_email)
703
704 # ------------------------------------------
705 # Where to find smtp host
706 # ------------------------------------------
707 smtp_host=localhost
708 AC_ARG_WITH(smtp_host,
709    [  --with-smtp-host=HOST              SMTP mail host address],
710    [
711        if test "x$withval" != "xno" ; then     
712               smtp_host=$withval
713        fi
714    ]
715 )
716
717 AC_SUBST(smtp_host)
718
719
720 # ------------------------------------
721 # Where to place pid files
722 # ------------------------------------
723 piddir=/var/run
724 AC_ARG_WITH(pid-dir,
725     [  --with-pid-dir=PATH               specify location of Bacula pid files],
726     [
727         if test "x$withval" != "xno" ; then     
728             piddir=$withval
729         fi
730     ]
731 )
732
733 AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
734 AC_SUBST(piddir)
735
736
737 # ------------------------------------
738 # Where to place subsys "lock file"
739 # ------------------------------------
740 subsysdir=/var/run/subsys
741 AC_ARG_WITH(subsys-dir,
742     [  --with-subsys-dir=PATH    specify location of Bacula subsys file],
743     [
744         if test "x$withval" != "xno" ; then     
745             subsysdir=$withval
746         fi
747     ]
748 )
749
750 AC_SUBST(subsysdir)
751
752
753
754 # ------------------------------------
755 # Where to start assigning ports
756 # ------------------------------------
757 baseport=9101
758 AC_ARG_WITH(baseport,
759     [  --with-baseport=PORT              specify base port address for daemons],
760     [
761         if test "x$withval" != "xno" ; then     
762              baseport=$withval
763         fi
764     ]
765 )
766
767 AC_SUBST(baseport)
768 dir_port=`expr $baseport`
769 fd_port=`expr $baseport + 1`
770 sd_port=`expr $fd_port + 1`
771
772 AC_SUBST(dir_port)
773 AC_SUBST(fd_port)
774 AC_SUBST(sd_port)
775
776
777 # ------------------------------------------
778 # Generate passwords
779 # ------------------------------------------
780 dir_password=
781 AC_ARG_WITH(dir-password,
782    [  --with-dir-password=PASSWORD   specify Director's password],
783    [
784        if test "x$withval" != "xno" ; then     
785            dir_password=$withval
786        fi
787    ]
788 )
789
790 if test "x$dir_password" = "x" ; then
791    if test "x$OPENSSL" = "xnone" ; then
792 #     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" abcdefghijklmnopqrst | awk '{getline} {print} {exit}'`
793       key=`autoconf/randpass 33`
794    else
795       key=`openssl rand -base64 33`
796    fi
797    dir_password=$key
798 fi
799
800 fd_password=
801 AC_ARG_WITH(fd-password,
802    [  --with-fd-password=PASSWORD    specify Client's password],
803    [
804        if test "x$withval" != "xno" ; then     
805            fd_password=$withval
806        fi
807    ]
808 )
809
810 if test "x$fd_password" = "x" ; then
811    if test "x$OPENSSL" = "xnone" ; then
812 #     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" tsrqponmlkjihgfedcba | awk '{getline} {print} {exit}'`
813       key=`autoconf/randpass 37`
814    else
815       key=`openssl rand -base64 33`
816    fi
817    fd_password=$key
818 fi
819
820 sd_password=
821 AC_ARG_WITH(sd-password,
822    [  --with-sd-password=PASSWORD    specify Storage daemon's password],
823    [
824        if test "x$withval" != "xno" ; then     
825            sd_password=$withval
826        fi
827    ]
828 )
829
830 if test "x$sd_password" = "x" ; then
831    if test "x$OPENSSL" = "xnone" ; then
832 #     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" 123456789uvwxyzabcdef | awk '{getline} {print} {exit}'`
833       key=`autoconf/randpass 41`
834    else
835       key=`openssl rand -base64 33`
836    fi
837    sd_password=$key
838 fi
839
840
841 AC_SUBST(dir_password)
842 AC_SUBST(fd_password)
843 AC_SUBST(sd_password)
844
845
846 #
847 # Handle users and groups for each daemon
848 #
849 dir_user=
850 AC_ARG_WITH(dir_user,
851     [  --with-dir-user=USER              specify user for Director daemon],
852     [
853         if test "x$withval" != "x" ; then       
854              dir_user=$withval
855         fi
856     ]
857 )
858
859 dir_group=
860 AC_ARG_WITH(dir_group,
861     [  --with-dir-group=GROUP            specify group for Director daemon],
862     [
863         if test "x$withval" != "x" ; then       
864              dir_group=$withval
865         fi
866     ]
867 )
868
869 sd_user=
870 AC_ARG_WITH(sd_user,
871     [  --with-sd-user=USER               specify user for Storage daemon],
872     [
873         if test "x$withval" != "x" ; then       
874              sd_user=$withval
875         fi
876     ]
877 )
878
879 sd_group=
880 AC_ARG_WITH(sd_group,
881     [  --with-sd-group=GROUP             specify group for Storage daemon],
882     [
883         if test "x$withval" != "x" ; then       
884              sd_group=$withval
885         fi
886     ]
887 )
888
889 fd_user=
890 AC_ARG_WITH(fd_user,
891     [  --with-fd-user=USER               specify user for File daemon],
892     [
893         if test "x$withval" != "x" ; then       
894              fd_user=$withval
895         fi
896     ]
897 )
898
899 fd_group=
900 AC_ARG_WITH(fd_group,
901     [  --with-fd-group=GROUP             specify group for File daemon],
902     [
903         if test "x$withval" != "x" ; then       
904              fd_group=$withval
905         fi
906     ]
907 )
908
909
910
911
912 AC_SUBST(dir_user)
913 AC_SUBST(dir_group)
914 AC_SUBST(sd_user)
915 AC_SUBST(sd_group)
916 AC_SUBST(fd_user)
917 AC_SUBST(fd_group)
918
919 #
920 # allow setting default executable permissions
921 #
922 SBINPERM=0754
923 AC_ARG_WITH(sbin-perm,
924     [  --with-sbin-perm=MODE             specify permissions for sbin binaries (0754)],
925     [
926         if test "x$withval" != "x" ; then       
927             SBINPERM=$withval
928         fi
929     ]
930 )
931
932 AC_SUBST(SBINPERM)
933
934 # ------------------------------------------------
935 # Bacula check for various SQL database engines
936 # ------------------------------------------------
937 BA_CHECK_POSTGRESQL_DB
938
939 BA_CHECK_MYSQL_DB
940
941 BA_CHECK_SQLITE_DB
942
943 AC_SUBST(cats)
944 AC_SUBST(DB_NAME)
945
946 AC_DEFINE(PROTOTYPES)
947
948 dnl# --------------------------------------------------------------------------
949 dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
950 dnl#
951 if test -z "$CFLAGS" -o "$CFLAGS" = "-g -O2"; then
952     if test -z "$CCOPTS"; then
953         CCOPTS='-g -O2 -Wall'
954     fi
955     CFLAGS="$CCOPTS"
956 fi
957
958
959 dnl A few others 
960 AC_EXEEXT
961
962 dnl See if we can use 64 bit file addresses
963 largefile_support="no"
964 AC_BAC_LARGEFILE
965
966
967 AC_PATH_XTRA
968
969 dnl# --------------------------------------------------------------------------
970 dnl# CHECKING FOR HEADER FILES
971 dnl# --------------------------------------------------------------------------
972 AC_CHECK_HEADERS( \
973         assert.h \
974         fcntl.h \
975         grp.h \
976         pwd.h \
977         libc.h \
978         limits.h \
979         stdarg.h \
980         stdlib.h \
981         stdint.h \
982         string.h \
983         termios.h \
984         unistd.h \
985         sys/bitypes.h \
986         sys/byteorder.h \
987         sys/ioctl.h \
988         sys/select.h \
989         sys/sockio.h \
990         sys/time.h \
991         sys/socket.h \
992         arpa/nameser.h \
993         resolv.h \
994         mtio.h \
995         sys/mtio.h \
996         sys/tape.h \
997         regex.h \
998 )
999 AC_HEADER_STDC
1000 AC_HEADER_MAJOR
1001 AC_HEADER_DIRENT
1002 AC_HEADER_STAT
1003 AC_HEADER_SYS_WAIT
1004 AC_HEADER_TIME
1005 AC_STRUCT_ST_BLKSIZE
1006 AC_STRUCT_ST_BLOCKS
1007 AC_STRUCT_TIMEZONE
1008
1009 dnl# --------------------------------------------------------------------------
1010 dnl# Check for utime.h structure 
1011 dnl# --------------------------------------------------------------------------
1012 AC_CACHE_CHECK(for utime.h, ba_cv_header_utime_h,
1013   [AC_TRY_COMPILE([
1014 #include <sys/types.h>
1015 #include <utime.h>], [struct utimbuf foo],
1016   ba_cv_header_utime_h=yes, ba_cv_header_utime_h=no)])
1017 test $ba_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H)
1018
1019 dnl# --------------------------------------------------------------------------
1020 dnl# Check for socklen_t
1021 dnl# --------------------------------------------------------------------------
1022 AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
1023   [AC_TRY_COMPILE([
1024 #include <sys/types.h>
1025 #include <sys/socket.h>],
1026   [socklen_t x],
1027   ba_cv_header_socklen_t=yes, ba_cv_header_socklen_t=no)])
1028 test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T)
1029
1030 dnl# --------------------------------------------------------------------------
1031 dnl# Check for bigendian
1032 dnl# --------------------------------------------------------------------------
1033 AC_CACHE_CHECK([for bigendian], ba_cv_bigendian,
1034   [AC_TRY_RUN(
1035     [main(){long a=1L; char *p=(char *)&a; exit(*p);}],
1036     [ba_cv_bigendian=yes], 
1037     [ba_cv_bigendian=no], 
1038     [ba_cv_bigendian=no])])
1039 test $ba_cv_bigendian = yes && AC_DEFINE(HAVE_BIGENDIAN)
1040
1041
1042 AC_C_CONST
1043
1044
1045 dnl# --------------------------------------------------------------------------
1046 dnl# CHECKING FOR FILESYSTEM TYPE
1047 dnl# --------------------------------------------------------------------------
1048 AC_MSG_CHECKING(how to get filesystem type)
1049 fstype=no
1050 # The order of these tests is important.
1051 AC_TRY_CPP([#include <sys/statvfs.h>
1052 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
1053 if test $fstype = no; then
1054 AC_TRY_CPP([#include <sys/statfs.h>
1055 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
1056 fi
1057 if test $fstype = no; then
1058 AC_TRY_CPP([#include <sys/statfs.h>
1059 #include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
1060 fi
1061 if test $fstype = no; then  
1062 AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
1063 fi
1064 if test $fstype = no; then  
1065 AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
1066 fi
1067 if test $fstype = no; then  
1068 AC_TRY_CPP([#include <sys/mount.h>
1069 #include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
1070 fi
1071 AC_MSG_RESULT($fstype)
1072
1073 dnl# --------------------------------------------------------------------------
1074 dnl# CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
1075 dnl# --------------------------------------------------------------------------
1076 AC_TYPE_SIGNAL
1077 SIGNAL_CHECK
1078 AC_TYPE_MODE_T
1079 AC_TYPE_UID_T
1080 AC_TYPE_SIZE_T
1081 AC_TYPE_PID_T
1082 AC_TYPE_OFF_T
1083 AC_CHECK_TYPE(ino_t, unsigned long)
1084 AC_CHECK_TYPE(dev_t, unsigned long)
1085 AC_CHECK_TYPE(daddr_t, long)
1086 AC_CHECK_TYPE(major_t, int)
1087 AC_CHECK_TYPE(minor_t, int)
1088 AC_CHECK_TYPE(ssize_t, int)
1089 AC_STRUCT_ST_BLOCKS
1090 AC_STRUCT_ST_RDEV
1091 AC_STRUCT_TM
1092 AC_C_CONST
1093
1094
1095 AC_CHECK_SIZEOF(char, 1)
1096 AC_CHECK_SIZEOF(short int, 2)
1097 AC_CHECK_SIZEOF(int, 4)
1098 AC_CHECK_SIZEOF(long int, 4)
1099 AC_CHECK_SIZEOF(long long int, 8)
1100 AC_CHECK_SIZEOF(int *, 4)
1101
1102 # Check for sys/types.h types
1103 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1104     AC_TRY_COMPILE(
1105         [ #include <sys/types.h> ], 
1106         [ u_int a; a = 1;], 
1107         [ ac_cv_have_u_int="yes" ],
1108         [ ac_cv_have_u_int="no" ]
1109     )
1110 ])
1111 if test "x$ac_cv_have_u_int" = "xyes" ; then
1112    AC_DEFINE(HAVE_U_INT)
1113    have_u_int=1
1114 fi
1115
1116 AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t, [
1117    AC_TRY_COMPILE(
1118       [ #include <sys/types.h> ], 
1119       [ intmax_t a; a = 1;], 
1120       [ ac_cv_have_intmax_t="yes" ],
1121       [ 
1122          AC_TRY_COMPILE(
1123             [ #include <stdint.h> ], 
1124             [ intmax_t a; a = 1;], 
1125             [ ac_cv_have_intmax_t="yes" ],
1126             [ ac_cv_have_intmax_t="no" ]
1127          )
1128       ]
1129    )        
1130
1131 ])
1132 if test "x$ac_cv_have_intmax_t" = "xyes" ; then
1133    AC_DEFINE(HAVE_INTMAX_T)
1134    have_intmax_t=1
1135 fi
1136
1137
1138 AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t, [
1139    AC_TRY_COMPILE(
1140       [ #include <sys/types.h> ], 
1141       [ u_intmax_t a; a = 1;], 
1142       [ ac_cv_have_u_intmax_t="yes" ],
1143       [ 
1144          AC_TRY_COMPILE(
1145             [ #include <stdint.h> ], 
1146             [ u_intmax_t a; a = 1;], 
1147             [ ac_cv_have_u_intmax_t="yes" ],
1148             [ ac_cv_have_u_intmax_t="no" ]
1149          )
1150       ]
1151    )
1152 ])
1153 if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
1154    AC_DEFINE(HAVE_U_INTMAX_T)
1155    have_u_intmax_t=1
1156 fi
1157
1158
1159 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1160    AC_TRY_COMPILE(
1161       [ #include <sys/types.h> ], 
1162       [ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
1163       [ ac_cv_have_intxx_t="yes" ],
1164       [ ac_cv_have_intxx_t="no" ]
1165    )
1166 ])
1167 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1168    AC_DEFINE(HAVE_INTXX_T)
1169    have_intxx_t=1
1170 fi
1171         
1172 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1173    AC_TRY_COMPILE(
1174       [ #include <sys/types.h> ], 
1175       [ int64_t a; a = 1;], 
1176       [ ac_cv_have_int64_t="yes" ],
1177       [ ac_cv_have_int64_t="no" ]
1178    )
1179 ])
1180 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1181    AC_DEFINE(HAVE_INT64_T)
1182    have_int64_t=1
1183 fi
1184         
1185 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1186    AC_TRY_COMPILE(
1187       [ #include <sys/types.h> ], 
1188       [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
1189       [ ac_cv_have_u_intxx_t="yes" ],
1190       [ ac_cv_have_u_intxx_t="no" ]
1191    )
1192 ])
1193 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1194    AC_DEFINE(HAVE_U_INTXX_T)
1195    have_u_intxx_t=1
1196 fi
1197
1198 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1199    AC_TRY_COMPILE(
1200       [ #include <sys/types.h> ], 
1201       [ u_int64_t a; a = 1;], 
1202       [ ac_cv_have_u_int64_t="yes" ],
1203       [ ac_cv_have_u_int64_t="no" ]
1204    )
1205 ])
1206 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1207    AC_DEFINE(HAVE_U_INT64_T)
1208    have_u_int64_t=1
1209 fi
1210
1211 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1212            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1213 then
1214    AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1215    AC_TRY_COMPILE(
1216       [ #include <sys/bitypes.h>  ], 
1217       [ int8_t a; int16_t b; int32_t c;
1218         u_int8_t e; u_int16_t f; u_int32_t g;
1219         a = b = c = e = f = g = 1;  ], 
1220       [ AC_DEFINE(HAVE_U_INTXX_T)
1221         AC_DEFINE(HAVE_INTXX_T)
1222         AC_DEFINE(HAVE_SYS_BITYPES_H)
1223         AC_MSG_RESULT(yes) ],
1224       [ AC_MSG_RESULT(no)]
1225    ) 
1226 fi
1227
1228 if test -z "$have_u_intxx_t" ; then
1229    AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1230       AC_TRY_COMPILE(
1231          [ #include <sys/types.h> ], 
1232          [ uint8_t a; uint16_t b; 
1233            uint32_t c; a = b = c = 1; ], 
1234          [ ac_cv_have_uintxx_t="yes" ],
1235          [ ac_cv_have_uintxx_t="no" ]
1236       )
1237    ])
1238    if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1239       AC_DEFINE(HAVE_UINTXX_T)
1240    fi
1241 fi
1242
1243 if (test -z "$have_u_int64_t" || test -z "$have_int64_t" && \
1244           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1245 then
1246    AC_MSG_CHECKING([for int64_t and u_int64_t types in sys/bitypes.h])
1247    AC_TRY_COMPILE(
1248       [ #include <sys/bitypes.h>  ], 
1249       [ int64_t a; u_int64_t b; 
1250        a = b = 1;  ], 
1251       [ AC_DEFINE(HAVE_U_INT64_T)
1252        AC_DEFINE(HAVE_INT64_T)
1253        AC_MSG_RESULT(yes) ],
1254       [ AC_MSG_RESULT(no)]
1255    ) 
1256 fi
1257
1258 if (test -z "$have_uintxx_t" && \
1259           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1260 then
1261    AC_MSG_CHECKING([for uintXX_t types in sys/bitypes.h])
1262    AC_TRY_COMPILE(
1263       [ #include <sys/bitypes.h>  ], 
1264         [ uint8_t a; uint16_t b; 
1265           uint32_t c; a = b = c = 1; ], 
1266       [ AC_DEFINE(HAVE_UINTXX_T)
1267        AC_MSG_RESULT(yes) ],
1268       [ AC_MSG_RESULT(no)]
1269    ) 
1270
1271 fi
1272
1273
1274
1275
1276 dnl# --------------------------------------------------------------------------
1277 dnl# CHECKING FOR REQUIRED LIBRARY FUNCTIONS
1278 dnl# --------------------------------------------------------------------------
1279 AC_CHECK_FUNCS( \
1280         fork \
1281         getcwd \
1282         gethostname \
1283         getpid \
1284         gettimeofday \
1285         setpgid \
1286         setpgrp \
1287         setsid \
1288         signal \
1289         strerror \
1290         strncmp \
1291         strncpy \
1292         vfprintf \
1293         ,,
1294         [echo 'configure: cannot find needed function.'; exit 1]
1295 )
1296
1297 AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
1298 AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)])
1299
1300 AC_CHECK_FUNCS(chflags) 
1301
1302 AC_CHECK_FUNCS(snprintf vsnprintf gethostid getdomainname)
1303
1304 dnl# --------------------------------------------------------------------------
1305 dnl# CHECKING FOR THREAD SAFE FUNCTIONS
1306 dnl# --------------------------------------------------------------------------
1307 AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
1308
1309 # If resolver functions are not in libc check for -lnsl or -lresolv.
1310 AC_CHECK_FUNC(gethostbyname_r,
1311     AC_MSG_RESULT(using libc's resolver),
1312     AC_CHECK_LIB(nsl,gethostbyname_r)
1313     AC_CHECK_LIB(resolv,gethostbyname_r))
1314
1315
1316 # Find where sockets are (especially for Solaris)
1317 AC_CHECK_FUNC(socket,
1318     AC_MSG_RESULT(using libc's socket),
1319     AC_CHECK_LIB(xnet,socket)
1320     AC_CHECK_LIB(socket,socket)
1321     AC_CHECK_LIB(inet,socket))
1322
1323 AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
1324 AC_CHECK_FUNCS(inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
1325 AC_CHECK_FUNCS(gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2)])
1326
1327 dnl ----------------------------
1328 dnl check sa_len of sockaddr
1329 dnl ----------------------------
1330 AC_CACHE_CHECK(for struct sockaddr has a sa_len field, ac_cv_struct_sockaddr_sa_len,
1331   [AC_TRY_COMPILE([#include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
1332   ac_cv_struct_sockaddr_sa_len=yes, ac_cv_struct_sockaddr_sa_len=no)])
1333
1334  if test $ac_cv_struct_sockaddr_sa_len = yes; then
1335   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
1336  fi
1337
1338
1339 dnl Check for IPv6 support
1340 AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
1341 [AC_TRY_LINK([ #include <sys/types.h>
1342 #include <sys/socket.h>
1343 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] =
1344  0;],
1345   [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
1346
1347 if test "$ac_cv_ipv6_support" = yes; then
1348   AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
1349 fi
1350
1351
1352
1353 AC_FUNC_STRFTIME
1354 AC_FUNC_VPRINTF
1355 AC_FUNC_ALLOCA
1356 AC_FUNC_GETMNTENT
1357 AC_FUNC_CLOSEDIR_VOID
1358 AC_FUNC_SETPGRP                       dnl check for BSD setpgrp.
1359 AC_FUNC_FNMATCH
1360
1361
1362 dnl# FreeBSD needs to link libxpg4
1363 AC_CHECK_LIB(xpg4, setlocale, [LIBS="$LIBS -lxpg4"])
1364
1365
1366 AC_CHECK_LIB(sun, getpwnam)
1367
1368 AC_CHECK_HEADERS(zlib.h)
1369 AC_CHECK_LIB(z, deflate, [FDLIBS="-lz"])
1370 have_zlib=no
1371 if test x$FDLIBS = x-lz; then
1372   AC_DEFINE(HAVE_LIBZ)
1373   have_zlib=yes
1374 fi
1375
1376 AC_CHECK_HEADER(sys/acl.h)
1377 AC_CHECK_LIB(acl, acl_get_file, [FDLIBS="-lacl $FDLIBS"])
1378 have_acl=no
1379 if test $ac_cv_lib_acl_acl_get_file = yes; then
1380    AC_DEFINE(HAVE_ACL)
1381    have_acl=yes
1382 fi
1383
1384 dnl Check for pthread libraries
1385 PTHREAD_LIB=""
1386 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
1387         [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
1388             [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
1389                 [AC_CHECK_FUNC(pthread_create)]
1390             )]
1391         )]
1392 )
1393
1394 AC_SUBST(FDLIBS)
1395 AC_DEFINE(FDLIBS)
1396
1397
1398 CFLAGS=${CFLAGS--O}
1399 LDFLAGS=${LDFLAGS--O}
1400 DB_LIBS="${SQL_LFLAGS}"
1401
1402 CPPFLAGS="$CPPFLAGS"
1403 AC_SUBST(DEBUG)
1404 AC_SUBST(DINCLUDE)
1405 AC_SUBST(CFLAGS)
1406 AC_SUBST(CPPFLAGS)
1407 AC_SUBST(LDFLAGS)
1408 AC_SUBST(X_CFLAGS)
1409 AC_SUBST(LIBS)
1410 AC_SUBST(DLIB)
1411 AC_SUBST(DB_LIBS)
1412 AC_SUBST(X_LIBS)
1413 AC_SUBST(X_EXTRA_LIBS)
1414 AC_SUBST(WCFLAGS)
1415 AC_SUBST(WLDFLAGS)
1416
1417 dnl# extra configurable objects
1418 OBJLIST=
1419 AC_SUBST(OBJLIST)
1420
1421 lld="lld"
1422 llu="llu"
1423
1424 WCFLAGS=
1425 WLDFLAGS=
1426
1427 #
1428 # Finally we set appropriate distribution specific
1429 #  variables and defaults
1430 #
1431 # PFILES are platform specific files
1432 PFILES="platforms/Makefile"
1433 PSCMD="ps -e"
1434 WIN32=
1435 MACOSX=
1436 hostname=`uname -n | cut -d '.' -f 1`
1437 case "$DISTNAME" in
1438 aix)
1439         DISTVER=`uname -r`
1440         PSCMD="ps -e -o pid,comm"
1441         PFILES="${PFILES} \
1442            platforms/aix/Makefile"
1443         TAPEDRIVE="/dev/rmt0.1" 
1444   ;;      
1445 alpha)
1446         DISTVER=`uname -r`
1447         PTHREAD_LIB="-lpthread -lexc"
1448         if test "${CC}" = "gcc" ; then
1449            lld="lld"
1450            llu="llu"
1451         else
1452            lld="ld"
1453            llu="lu"
1454         fi
1455         TAPEDRIVE="/dev/nrmt0"
1456   ;;
1457 bsdi)
1458         DISTVER=`uname -a |awk '{print $3}'`
1459         TAPEDRIVE="/dev/nrmt0"
1460         PTHREAD_LIB="-pthread"
1461         CFLAGS="${CFLAGS} -pthread"
1462         PSCMD="ps -x -o pid,command"
1463         lld="qd"
1464         llu="qu"
1465         PFILES="${PFILES} \
1466             platforms/bsdi/Makefile \
1467             platforms/bsdi/bacula-fd \
1468             platforms/bsdi/bacula-sd \
1469             platforms/bsdi/bacula-dir"
1470         largefile_support="yes"
1471   ;;
1472 cygwin)
1473         DISTVER=`uname -a |awk '{print $3}'`
1474         TAPEDRIVE="/dev/nrst0"
1475         WIN32=win32
1476         WCFLAGS="-mwindows"
1477         WLDFLAGS="-mwindows"
1478   ;;
1479 darwin)
1480         DISTVER=`uname -r`
1481         TAPEDRIVE="/dev/nst0"
1482         PSCMD="ps -e -o pid,command"
1483         MACOSX=macosx
1484         PFILES="${PFILES} \
1485            platforms/darwin/Makefile"
1486   ;;
1487 debian)
1488         DISTVER=`cat /etc/debian_version`
1489         TAPEDRIVE="/dev/nrst0"
1490         PSCMD="ps -e -o pid,command"
1491   ;;
1492 freebsd)
1493         DISTVER=`uname -a |awk '{print $3}'`
1494         VER=`echo $DISTVER | cut -c 1`
1495         if test x$VER = x4 ; then
1496            PTHREAD_LIB="-pthread"
1497            CFLAGS="${CFLAGS} -pthread"
1498         fi
1499         lld="qd"
1500         llu="qu"
1501         TAPEDRIVE="/dev/nrsa0"
1502         PSCMD="ps -x -o pid,command"
1503         PFILES="${PFILES} \
1504             platforms/freebsd/Makefile \
1505             platforms/freebsd/bacula-fd \
1506             platforms/freebsd/bacula-sd \
1507             platforms/freebsd/bacula-dir"
1508         largefile_support="yes"
1509   ;;
1510 hpux)
1511         PSCMD="UNIX95=1 ps -e -o pid,comm"
1512         CFLAGS="$(CFLAGS) -D_XOPEN_SOURCE_EXTENDED=1"
1513         DISTVER=`uname -r`
1514         TAPEDRIVE="/dev/rmt/0hnb"
1515   ;;
1516 irix)
1517         DISTVER=`uname -r`
1518         TAPEDRIVE="/dev/rmt/0cbn"
1519         PSCMD="ps -e -o pid,comm"
1520         PFILES="${PFILES} \
1521             platforms/irix/Makefile \
1522             platforms/irix/bacula-fd \
1523             platforms/irix/bacula-sd \
1524             platforms/irix/bacula-dir"
1525   ;;
1526 netbsd)
1527         DISTVER=`uname -a |awk '{print $3}'`
1528         lld="qd"
1529         llu="qu"
1530         TAPEDRIVE="/dev/nrst0"
1531         PSCMD="ps -a -o pid,command"
1532         PTHREAD_LIB="-pthread"
1533         CFLAGS="${CFLAGS} -pthread"
1534   ;;
1535 openbsd)
1536         DISTVER=`uname -a |awk '{print $3}'`
1537         lld="qd"
1538         llu="qu"
1539         TAPEDRIVE="/dev/nrst0"
1540         PSCMD="ps -a -o pid,command"
1541         PTHREAD_LIB="-pthread"
1542         CFLAGS="${CFLAGS} -pthread"
1543         PFILES="${PFILES} \
1544             platforms/openbsd/Makefile \
1545             platforms/openbsd/bacula-fd \
1546             platforms/openbsd/bacula-sd \
1547             platforms/openbsd/bacula-dir"
1548   ;;
1549 redhat)
1550         if test -f /etc/whitebox-release ; then
1551            f=/etc/whitebox-release
1552         else
1553            f=/etc/redhat-release
1554         fi
1555         if test `cat $f | grep release |\
1556                    cut -f 3 -d ' '`x = "Enterprise"x ; then
1557            DISTVER="Enterprise "`cat $f | grep release |\
1558                     cut -f 6 -d ' '`
1559         else
1560             DISTVER=`cat /etc/redhat-release | grep release |\
1561                      cut -f 5 -d ' '`
1562         fi
1563         TAPEDRIVE="/dev/nst0"
1564         PSCMD="ps -e -o pid,command"
1565         PFILES="${PFILES} \
1566             platforms/redhat/Makefile \
1567             platforms/redhat/bacula-fd \
1568             platforms/redhat/bacula-sd \
1569             platforms/redhat/bacula-dir \
1570             platforms/redhat/bacula.spec \
1571             "
1572         hostname=`hostname -s`
1573   ;;
1574 mandrake)
1575         DISTVER=`cat /etc/mandrake-release | grep release |\
1576            cut -f 5 -d ' '`
1577         TAPEDRIVE="/dev/nst0"
1578         PSCMD="ps -e -o pid,command"
1579         PFILES="${PFILES} \
1580             platforms/mandrake/Makefile \
1581             platforms/mandrake/bacula-fd \
1582             platforms/mandrake/bacula-sd \
1583             platforms/mandrake/bacula-dir \
1584             platforms/mandrake/bacula.spec \
1585             "
1586   ;;
1587 gentoo)
1588         DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
1589         TAPEDRIVE="/dev/nst0"
1590         PSCMD="ps -e -o pid,command"
1591         PFILES="${PFILES} \
1592             platforms/gentoo/Makefile \
1593             platforms/gentoo/bacula-fd \
1594             platforms/gentoo/bacula-sd \
1595             platforms/gentoo/bacula-dir"
1596   ;;
1597 slackware)
1598         DISTVER=`cat /etc/slackware-version`
1599         TAPEDRIVE="/dev/nst0"
1600         PSCMD="ps -e -o pid,command"
1601         PFILES="${PFILES} \
1602             platforms/slackware/Makefile \
1603             platforms/slackware/rc.bacula-fd \
1604             platforms/slackware/rc.bacula-sd \
1605             platforms/slackware/rc.bacula-dir\
1606             platforms/slackware/functions.bacula"
1607   ;;
1608 solaris)
1609         DISTVER=`uname -r`
1610         TAPEDRIVE="/dev/rmt/0cbn"
1611         PSCMD="ps -e -o pid,comm"
1612         PFILES="${PFILES} \
1613             platforms/solaris/Makefile \
1614             platforms/solaris/bacula-fd \
1615             platforms/solaris/bacula-sd \
1616             platforms/solaris/bacula-dir"
1617         if test x$DISTVER = x5.6 ; then
1618             AC_DEFINE(HAVE_OLD_SOCKOPT)
1619         fi
1620   ;;
1621 suse)
1622         DISTVER=`cat /etc/SuSE-release |grep VERSION|\
1623             cut -f 3 -d ' '`
1624         TAPEDRIVE="/dev/nst0"
1625         PSCMD="ps -e -o pid,command"
1626         PFILES="${PFILES} \
1627             platforms/suse/Makefile \
1628             platforms/suse/bacula-fd \
1629             platforms/suse/bacula-sd \
1630             platforms/suse/bacula-dir \
1631             platforms/suse/bacula \
1632             platforms/suse/bacula.spec"
1633   ;;
1634 suse5)
1635         DISTNAME=suse
1636         DISTVER=5.x
1637         TAPEDRIVE="/dev/nst0"
1638         PSCMD="ps -e -o pid,command"
1639         PFILES="${PFILES} \
1640             platforms/suse/Makefile \
1641             platforms/suse/bacula-fd \
1642             platforms/suse/bacula-sd \
1643             platforms/suse/bacula-dir"
1644   ;;
1645 unknown)
1646         DISTVER=unknown
1647         TAPEDRIVE="/dev/nst0"
1648   ;;
1649 *)
1650   echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
1651   ;;
1652 esac  
1653
1654 AC_SUBST(hostname)
1655
1656 LIBS="$PTHREAD_LIB $LIBS"
1657
1658 AC_DEFINE_UNQUOTED(lld, "$lld")
1659 AC_DEFINE_UNQUOTED(llu, "$llu")
1660 AC_SUBST(TAPEDRIVE)
1661 AC_SUBST(PSCMD)
1662 AC_SUBST(WIN32)
1663 AC_SUBST(MACOSX)
1664 AC_SUBST(DISTNAME)
1665 AC_SUBST(DISTVER)
1666
1667 dnl# common parts of the Makefile
1668 MCOMMON=./autoconf/Make.common
1669 AC_SUBST_FILE(MCOMMON)
1670
1671 dnl# Insanity check
1672 if test "x${subsysdir}" = "x${sbindir}" ; then
1673    echo " "
1674    echo " "
1675    echo "You have set both --sbindir and --with-subsys-dir"
1676    echo "  equal to: ${subsysdir} "
1677    echo "This is not permitted. Please reconfigure."
1678    echo " "
1679    echo "Aborting configuration ..."
1680    echo " "
1681    echo " "
1682    exit 1
1683 fi 
1684
1685 AC_OUTPUT([autoconf/Make.common \
1686            Makefile \
1687            rescue/Makefile \
1688            rescue/linux/Makefile \
1689            rescue/freebsd/Makefile \
1690            rescue/solaris/Makefile \
1691            scripts/startmysql \
1692            scripts/stopmysql \
1693            scripts/btraceback \
1694            scripts/startit \
1695            scripts/stopit \
1696            scripts/bconsole \
1697            scripts/gconsole \
1698            scripts/bacula \
1699            scripts/devel_bacula \
1700            scripts/Makefile \
1701            scripts/logrotate \
1702            scripts/bacula.desktop.gnome1 \
1703            scripts/bacula.desktop.gnome2 \
1704            scripts/bacula.desktop.gnome1.consolehelper \
1705            scripts/bacula.desktop.gnome2.consolehelper \
1706            scripts/bacula.desktop.gnome1.xsu \
1707            scripts/bacula.desktop.gnome2.xsu \
1708            scripts/gnome-console.console_apps \
1709            scripts/mtx-changer \
1710            doc/Makefile \
1711            src/Makefile \
1712            src/host.h \
1713            src/console/Makefile \
1714            src/console/bconsole.conf \
1715            src/gnome-console/Makefile \
1716            src/gnome-console/gnome-console.conf \
1717            src/gnome2-console/Makefile \
1718            src/gnome2-console/gnome-console.conf \
1719            src/wx-console/Makefile \
1720            src/wx-console/wx-console.conf \
1721            src/tray-monitor/Makefile \
1722            src/tray-monitor/tray-monitor.conf \
1723            src/dird/Makefile \
1724            src/dird/bacula-dir.conf \
1725            src/lib/Makefile \
1726            src/stored/Makefile \
1727            src/stored/bacula-sd.conf \
1728            src/filed/Makefile \
1729            src/filed/bacula-fd.conf \
1730            src/filed/win32/Makefile \
1731            src/cats/Makefile \
1732            src/cats/make_catalog_backup \
1733            src/cats/delete_catalog_backup \
1734            src/cats/create_postgresql_database \
1735            src/cats/update_postgresql_tables \
1736            src/cats/make_postgresql_tables \
1737            src/cats/grant_postgresql_privileges \
1738            src/cats/drop_postgresql_tables \
1739            src/cats/drop_postgresql_database \
1740            src/cats/create_mysql_database \
1741            src/cats/update_mysql_tables \
1742            src/cats/make_mysql_tables \
1743            src/cats/grant_mysql_privileges \
1744            src/cats/drop_mysql_tables \
1745            src/cats/drop_mysql_database \
1746            src/cats/create_sqlite_database \
1747            src/cats/update_sqlite_tables \
1748            src/cats/make_sqlite_tables \
1749            src/cats/grant_sqlite_privileges \
1750            src/cats/drop_sqlite_tables \
1751            src/cats/drop_sqlite_database \
1752            src/cats/sqlite \
1753            src/cats/mysql \
1754            src/cats/create_bdb_database \
1755            src/cats/update_bdb_tables \
1756            src/cats/make_bdb_tables \
1757            src/cats/grant_bdb_privileges \
1758            src/cats/drop_bdb_tables \
1759            src/cats/drop_bdb_database \
1760            src/cats/create_bacula_database \
1761            src/cats/update_bacula_tables \
1762            src/cats/grant_bacula_privileges \
1763            src/cats/make_bacula_tables \
1764            src/cats/drop_bacula_tables \
1765            src/cats/drop_bacula_database \
1766            src/findlib/Makefile \
1767            src/tools/Makefile \
1768            src/win32/winbacula.nsi \
1769            src/win32/baculafd/bacula-fd.conf \
1770            src/win32/Makefile \
1771            src/win32/console/bconsole.conf \
1772            src/win32/wx-console/wx-console.conf \
1773            $PFILES ],  
1774           [(echo "Doing make of dependencies"; ${MAKE:-make} depend;) ]
1775 )
1776
1777 cd scripts
1778 chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
1779 chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate
1780 cd ..
1781
1782 c=src/cats
1783
1784 chmod 755 $c/create_bacula_database   $c/update_bacula_tables  $c/make_bacula_tables
1785 chmod 755 $c/grant_bacula_privileges  $c/drop_bacula_tables    $c/drop_bacula_database
1786
1787 chmod 755 $c/create_bdb_database      $c/update_bdb_tables     $c/make_bdb_tables
1788 chmod 755 $c/grant_bdb_privileges     $c/drop_bdb_tables       $c/drop_bdb_database
1789
1790 chmod 755 $c/create_mysql_database    $c/update_mysql_tables   $c/make_mysql_tables
1791 chmod 755 $c/grant_mysql_privileges   $c/drop_mysql_tables     $c/drop_mysql_database
1792
1793 chmod 755 $c/create_sqlite_database   $c/update_sqlite_tables  $c/make_sqlite_tables
1794 chmod 755 $c/grant_sqlite_privileges  $c/drop_sqlite_tables    $c/drop_sqlite_database
1795
1796 chmod 755 $c/create_postgresql_database  $c/update_postgresql_tables $c/make_postgresql_tables
1797 chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables   $c/drop_postgresql_database
1798
1799 chmod 755 $c/make_catalog_backup $c/delete_catalog_backup
1800 chmod 755 $c/sqlite
1801 chmod 755 $c/mysql
1802
1803 if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
1804    largefile_support="yes"
1805 fi
1806
1807 #
1808 # A whole lot of hand springs to get the compiler version.
1809 #  This is because gcc changed the output in version 3.0
1810 #
1811 CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 3 -d ' '`
1812 if test "x${CCVERSION}" = "x" ; then
1813   CCVERSION=`${CC} --version | tr '\n' ' ' | cut -f 1 -d ' '`
1814 fi
1815 CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
1816 if test x"${CXXVERSION}" = x ; then
1817   CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
1818 fi
1819
1820 if test "x${subsysdir}" = "x${sbindir}" ; then
1821    echo " "
1822    echo " "
1823    echo "You have set --sbindir and --with-subsys-dir"
1824    echo "  both equal to: ${subsysdir} "
1825    echo "  This is not permitted. Please reconfigure."
1826    echo " "
1827    echo "Aborting configuration ..."
1828    echo " "
1829    echo " "
1830    exit 1
1831 fi 
1832
1833 if test "x${db_name}" = "xInternal" ; then
1834    echo " "
1835    echo " "
1836    echo "You have not specified either --enable-client-only or one of the"
1837    echo "  supported databases: MySQL, PostgreSQL, or SQLite".
1838    echo "  This is not permitted. Please reconfigure."
1839    echo " "
1840    echo "Aborting the configuration ..."
1841    echo " "
1842    echo " "
1843    exit 1
1844 fi
1845
1846 echo "
1847 Configuration on `date`:
1848
1849   Host:                       $host -- ${DISTNAME} ${DISTVER}
1850   Bacula version:             ${VERSION} (${DATE})
1851   Source code location:       ${srcdir}
1852   Install binaries:           ${sbindir}
1853   Install config files:       ${sysconfdir}
1854   Scripts directory:          ${scriptdir}
1855   Working directory:          ${working_dir}
1856   PID directory:              ${piddir}
1857   Subsys directory:           ${subsysdir}
1858   C Compiler:                 ${CC} ${CCVERSION}
1859   C++ Compiler:               ${CXX} ${CXXVERSION}
1860   Compiler flags:             ${WCFLAGS} ${CFLAGS} 
1861   Linker flags:               ${WLDFLAGS} ${LDFLAGS}
1862   Libraries:                  ${LIBS}
1863   Statically Linked Tools:    ${support_static_tools}
1864   Statically Linked FD:       ${support_static_fd}
1865   Statically Linked SD:       ${support_static_sd}
1866   Statically Linked DIR:      ${support_static_dir}
1867   Statically Linked CONS:     ${support_static_cons}
1868   Database type:              ${db_name}
1869   Database lib:               ${DB_LIBS}
1870
1871   Job Output Email:           ${job_email}
1872   Traceback Email:            ${dump_email}
1873   SMTP Host Address:          ${smtp_host}
1874
1875   Director Port:              ${dir_port}
1876   File daemon Port:           ${fd_port}
1877   Storage daemon Port:        ${sd_port}
1878
1879   Director User:              ${dir_user}
1880   Director Group:             ${dir_group}
1881   Storage Daemon User:        ${sd_user}
1882   Storage DaemonGroup:        ${sd_group}
1883   File Daemon User:           ${fd_user}
1884   File Daemon Group:          ${fd_group}
1885
1886   SQL binaries Directory      ${SQL_BINDIR}
1887
1888   Large file support:         $largefile_support
1889   Bacula conio support:       ${got_conio} ${CONS_LIBS}
1890   readline support:           ${got_readline} ${PRTREADLINE_SRC}
1891   TCP Wrappers support:       ${TCPW_MSG}
1892   ZLIB support:               ${have_zlib}
1893   enable-smartalloc:          ${support_smartalloc} 
1894   enable-gnome:               ${support_gnome} ${gnome_version}
1895   enable-wx-console:          ${support_wx_console}
1896   enable-tray-monitor:        ${support_tray_monitor}
1897   client-only:                ${build_client_only}
1898   ACL support:                ${have_acl}
1899
1900   " > config.out
1901
1902 cat config.out
1903
1904 # old stuff
1905 # cweb support:               ${got_cweb} ${CWEB_SRC}
1906   # gmp support:                      ${got_gmp} ${GMP_SRC}