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