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