]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/configure.in
SQLite performance + misc -- see kes20Jul02
[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.12)
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]*DATE.*"\(.*\)"$/\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
65 test -n "$ARFLAG" || ARFLAGS="cr"
66 AC_SUBST(ARFLAGS)
67
68 MAKE_SHELL=/bin/sh
69 AC_SUBST(MAKE_SHELL)
70
71 AC_SUBST(LOCAL_LIBS)
72 AC_SUBST(LOCAL_CFLAGS)
73 AC_SUBST(LOCAL_LDFLAGS)
74 AC_SUBST(LOCAL_DEFS)
75
76
77
78 dnl --------------------------------------------------
79 dnl Bacula OP Sys determination (see aclocal.m4)
80 dnl --------------------------------------------------
81 BA_CHECK_OPSYS
82
83 # -----------------------------------------------------------
84 dnl Bacula OPSys Distribution determination (see aclocal.m4)
85 # ----------------------------------------------------------
86 BA_CHECK_OPSYS_DISTNAME
87
88 # -----------------------------------------------------------
89 dnl Check for gnome stuff for gnome-console
90 # ----------------------------------------------------------
91 AM_ACLOCAL_INCLUDE(gnome-macros)
92
93 # ------------------------------------------------------------------
94 #  If the user has not set --prefix, we set our default to nothing.
95 #  In this case, if the user has not set --sysconfdir, we set it
96 #  to the package default of /etc/bacula.  If either --prefix or
97 #  --sysconfdir is set, we leave sysconfdir alone except to eval it.
98 # ------------------------------------------------------------------
99 if test x${prefix} = xNONE ; then
100     if test `eval echo ${sysconfdir}` = NONE/etc ; then
101         sysconfdir=/etc/bacula
102     fi
103     prefix=
104 fi
105 sysconfdir=`eval echo ${sysconfdir}`
106
107 # -------------------------------------------------------------------------
108 #  If the user has not set --exec-prefix, we default to ${prefix}
109 # -------------------------------------------------------------------------
110 if test x${exec_prefix} = xNONE ; then
111     exec_prefix=${prefix}
112 fi
113
114 # ------------------------------------------------------------------
115 # If the user has not set --sbindir, we set our default as /sbin
116 # ------------------------------------------------------------------
117 if test x$sbindir = x'${exec_prefix}/sbin' ; then
118     sbindir=${exec_prefix}/sbin
119 fi
120 sbindir=`eval echo ${sbindir}`
121                       
122 # ------------------------------------------------------------------
123 # All list of languages for which a translation exist. Each
124 #  language is separated by a space.
125 # ------------------------------------------------------------------
126 ALL_LINGUAS=""
127
128 AC_PATH_PROGS(MSGFMT, msgfmt, no)
129 if test "$MSGFMT" = "no"
130 then
131    echo 'msgfmt program not found, disabling NLS !'
132    USE_NLS=no
133    USE_INCLUDED_LIBINTL=no
134 #else
135 #   AM_GNU_GETTEXT
136 fi
137
138
139 support_mysql=no
140 support_sqlite=no
141 support_smartalloc=yes
142 cats=
143 db_name=Internal
144 DB_NAME=bdb
145
146 dnl# --------------------------------------------------------------------------
147 dnl# CHECKING COMMAND LINE OPTIONS
148 dnl# --------------------------------------------------------------------------
149 AC_ARG_ENABLE(everything,
150   [  --enable-everything     enable standard non-multichoice features: marked *],
151   [if test x$enableval = xyes; then
152     support_smartalloc=yes
153   fi])
154
155 # -------------------------------------------
156 # gnome (default off)
157 # -------------------------------------------
158 support_gnome=no
159 AC_ARG_ENABLE(gnome,
160   [  --enable-gnome     enable build of gnome-console GUI                     *],
161   [if test x$enableval = xyes; then
162     support_gnome=yes
163   fi])
164
165 GNOME_DIR=
166 if test x$support_gnome = xyes; then
167     GNOME_INIT
168     GNOME_DIR=src/gnome-console
169 fi
170 AC_SUBST(GNOME_DIR)
171
172
173 # -------------------------------------------
174 # smartalloc (default off)
175 # -------------------------------------------
176 AC_ARG_ENABLE(smartalloc,
177   [  --enable-smartalloc     enable smartalloc debugging support                   *],
178   [if test x$enableval = xno; then
179     support_smartalloc=no
180   fi])
181
182 if test x$support_smartalloc = xyes; then
183    AC_DEFINE(SMARTALLOC)
184 fi
185
186
187
188 # ---------------------------------------------------
189 # Check for readline support/directory (default on)
190 # ---------------------------------------------------
191 support_readline=yes
192 # this allows you to turn it completely off
193 AC_ARG_ENABLE(readline,
194   [  --disable-readline      disable readline support ],
195   [if test x$enableval = xno; then
196     support_readline=no
197   fi])
198
199 got_readline="no"
200 READLINE_SRC=
201 if test x$support_readline = xyes; then
202    AC_ARG_WITH(readline,
203      [  --with-readline[=DIR]   Specify readline library directory],
204      [
205         case "$with_readline" in
206         no) : ;;
207         yes|*)
208           if test "$with_readline" != "yes"; then
209             CONS_INC="-I$with_readline"
210             CONS_LDFLAGS="-L$with_readline"
211           else
212              with_readline="/usr/include/readline" 
213           fi
214           AC_CHECK_HEADER($with_readline/readline.h, 
215              [ AC_MSG_RESULT(yes)
216                AC_DEFINE(HAVE_READLINE) 
217                CONS_LIBS="-lreadline -ltermcap"
218                got_readline="yes"   
219              ],
220              [ AC_MSG_ERROR([*** readline library missing]) 
221              ]
222           )
223           ;;
224         esac
225      ],[
226        # check for standard readline library
227        AC_CHECK_HEADER(/usr/include/readline/readline.h, 
228        [ AC_MSG_RESULT(yes)
229          AC_DEFINE(HAVE_READLINE)
230          got_readline="yes"
231          CONS_INC="-I/usr/include/readline"
232          CONS_LIBS="-lreadline -ltermcap"
233        ], [
234          # Did not find starndard library, so user our own
235          AC_MSG_RESULT(yes)
236          AC_DEFINE(HAVE_READLINE)
237          got_readline="yes"
238          CONS_INC="-I${TOP_DIR}/depkgs"
239          CONS_LIBS="-lreadline -lhistory -ltermcap"
240          CONS_LDFLAGS="-L${TOP_DIR}/depkgs/readline"
241          PRTREADLINE_SRC="${TOP_DIR}/depkgs/readline"
242        ])
243      ]   
244    )
245 fi
246 AC_SUBST(CONS_INC)
247 AC_SUBST(CONS_LIBS)
248 AC_SUBST(CONS_LDFLAGS)
249 AC_SUBST(READLINE_SRC)
250
251 # Minimal stuff for readline Makefile configuration
252 MAKE_SHELL=/bin/sh
253 AC_SUBST(MAKE_SHELL)
254
255 AC_HEADER_STAT
256 AC_HEADER_DIRENT
257
258 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat lchown)
259
260 #AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT_LONG),
261 #   [LIBEXTRAOBJ="$LIBEXTRAOBJ getopt.o getopt1.o"
262 #    EXTRAOBJ="$EXTRAOBJ lib/getopt.o lib/getopt1.o"])
263
264 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT_LONG))
265
266
267 AC_FUNC_STRCOLL
268
269 AC_CHECK_HEADERS(varargs.h \
270                 sys/ptem.h sys/pte.h sys/stream.h) 
271
272 # End of readline stuff
273 # -----------------------------------------------------------------------
274
275
276 # ---------------------------------------------------
277 # Check for GMP support/directory
278 # ---------------------------------------------------
279 GMP_SRC=
280 local_gmp="no"
281 AC_ARG_WITH(gmp,
282   [  --with-gmp[=DIR]   Specify gmp library directory],
283   [
284      case "$with_gmp" in
285      no) : ;;
286      yes|*)
287        if test "$with_gmp" != "yes"; then
288          GMP_INC="-I$with_gmp"
289          GMP_LIBS="-lgmp"
290          GMP_LDFLAGS="-L$with_gmp"
291        else
292           with_gmp="/usr/include" 
293        fi
294        AC_CHECK_HEADER($with_gmp/gmp.h, 
295           [ AC_MSG_RESULT(yes)
296             AC_DEFINE(HAVE_GMP) 
297             GMP_LIBS="-lgmp"
298             got_gmp="yes"   
299           ],
300           [ AC_MSG_ERROR([*** gmp library missing]) 
301           ]
302        )
303        ;;
304      esac
305   ],[
306     # check for standard gmp library
307     AC_CHECK_HEADER(/usr/include/gmp.h,
308     [ AC_MSG_RESULT(yes)
309       AC_DEFINE(HAVE_GMP)
310       got_gmp="yes"
311       GMP_INC=
312       GMP_LIBS="-lgmp"
313     ], [
314       # Did not find standard library, so use our own
315       AC_MSG_RESULT(yes)
316       AC_DEFINE(HAVE_GMP)
317       got_gmp="yes"
318       local_gmp="yes"
319       GMP_INC="-I${TOP_DIR}/depkgs/gmp"
320       GMP_LIBS="-lgmp"
321       GMP_LDFLAGS="-L${TOP_DIR}/depkgs/gmp"
322       GMP_SRC="${TOP_DIR}/depkgs/gmp"
323     ])
324   ]   
325 )
326 AC_SUBST(GMP_INC)
327 AC_SUBST(GMP_LIBS)
328 AC_SUBST(GMP_LDFLAGS)
329 AC_SUBST(GMP_SRC)
330
331 # End of GMP stuff
332 # -----------------------------------------------------------------------
333
334
335 # ---------------------------------------------------
336 # Check for CWEB support/directory
337 # ---------------------------------------------------
338 CWEB_SRC=
339 CWEB=/bin
340 local_cweb="no"
341 AC_ARG_WITH(cweb,
342   [  --with-cweb[=DIR]   Specify cweb library directory],
343   [
344      case "$with_cweb" in
345      no) : ;;
346      yes|*)
347        if test "$with_cweb" != "yes"; then
348          CWEB_INC="-I$with_cweb"
349          CWEB_LIBS="-lcweb"
350          CWEB_LDFLAGS="-L$with_cweb"
351        else
352           with_cweb="/usr/include" 
353        fi
354        AC_CHECK_HEADER($with_cweb/cweb.h, 
355           [ AC_MSG_RESULT(yes)
356             AC_DEFINE(HAVE_CWEB) 
357             CWEB_LIBS="-lcweb"
358             got_cweb="yes"   
359           ],
360           [ AC_MSG_ERROR([*** cweb library missing]) 
361           ]
362        )
363        ;;
364      esac
365   ],[
366     # check for standard cweb library
367     AC_CHECK_HEADER(/usr/include/cweb.h,
368     [ AC_MSG_RESULT(yes)
369       AC_DEFINE(HAVE_CWEB)
370       got_cweb="yes"
371       CWEB_INC=
372       CWEB_LIBS="-lcweb"
373     ], [
374       # Did not find starndard library, so use our own
375       AC_MSG_RESULT(yes)
376       AC_DEFINE(HAVE_CWEB)
377       got_cweb="yes"
378       local_cweb="yes"
379       CWEB=${TOP_DIR}/depkgs/cweb
380       CWEB_INC="-I${TOP_DIR}/depkgs/cweb"
381       CWEB_LIBS="-lcweb"
382       CWEB_LDFLAGS="-L${TOP_DIR}/depkgs/cweb"
383       CWEB_SRC="${TOP_DIR}/depkgs/cweb"
384     ])
385   ]   
386 )
387 AC_SUBST(CWEB)
388 AC_SUBST(CWEB_INC)
389 AC_SUBST(CWEB_LIBS)
390 AC_SUBST(CWEB_LDFLAGS)
391 AC_SUBST(CWEB_SRC)
392
393 # End of CWEB stuff
394 # -----------------------------------------------------------------------
395
396
397
398 # -----------------------------------------------------------
399 # Check whether user wants TCP wrappers support (default off)
400 # -----------------------------------------------------------
401 TCPW_MSG="no" 
402 AC_ARG_WITH(tcp-wrappers,
403   [  --with-tcp-wrappers=DIR Enable tcpwrappers support],
404   [
405     if test "x$withval" != "xno" ; then
406        saved_LIBS="$LIBS"
407        LIBS="$LIBS -lwrap -lnsl"
408        AC_MSG_CHECKING(for libwrap)
409        AC_TRY_LINK(
410           [ #include <tcpd.h>
411              int deny_severity = 0;
412              int allow_severity = 0;
413              struct request_info *req; ],
414           [ hosts_access(req); ],
415           [
416             AC_MSG_RESULT(yes)
417             AC_DEFINE(HAVE_LIBWRAP)
418             TCPW_MSG="yes" 
419           ],
420           [AC_MSG_ERROR([*** libwrap missing]) ]
421        )
422     fi
423   ]
424 )
425
426 # ------------------------------------------
427 # Where to place working dir
428 # ------------------------------------------
429 working_dir=`eval echo ${sysconfdir}/working`
430 AC_ARG_WITH(working-dir,
431    [  --with-working-dir=PATH Specify location of Bacula working files],
432    [
433        if test "x$withval" != "xno" ; then     
434               working_dir=$withval
435        fi
436    ]
437 )
438
439 AC_SUBST(working_dir)
440
441 # ------------------------------------------
442 # Where to send dump email
443 # ------------------------------------------
444 dump_email=root@localhost
445 AC_ARG_WITH(dump-email,
446    [  --with-dump-email=Dump email address],
447    [
448        if test "x$withval" != "xno" ; then     
449               dump_email=$withval
450        fi
451    ]
452 )
453
454 AC_SUBST(dump_email)
455
456 # ------------------------------------------
457 # Where to send job email
458 # ------------------------------------------
459 job_email=root@localhost
460 AC_ARG_WITH(job-email,
461    [  --with-job-email=Job output email address],
462    [
463        if test "x$withval" != "xno" ; then     
464               job_email=$withval
465        fi
466    ]
467 )
468
469 AC_SUBST(job_email)
470
471 # ------------------------------------------
472 # Where to find smtp host
473 # ------------------------------------------
474 smtp_host=localhost
475 AC_ARG_WITH(smtp_host,
476    [  --with-smtp-host=SMTP mail host address],
477    [
478        if test "x$withval" != "xno" ; then     
479               smtp_host=$withval
480        fi
481    ]
482 )
483
484 AC_SUBST(smtp_host)
485
486
487 # ------------------------------------
488 # Where to place pid files
489 # ------------------------------------
490 piddir=/var/run
491 AC_ARG_WITH(pid-dir,
492     [  --with-pid-dir=PATH    Specify location of Bacula pid files],
493     [
494         if test "x$withval" != "xno" ; then     
495             piddir=$withval
496         fi
497     ]
498 )
499
500 # make sure the pid directory exists
501 if test ! -d $piddir ; then     
502     piddir=`eval echo ${sysconfdir}`
503     case $piddir in
504           NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
505     esac
506 fi
507
508 AC_DEFINE_UNQUOTED(_PATH_BACULA_PIDDIR, "$piddir")
509 AC_SUBST(piddir)
510
511
512 # ------------------------------------
513 # Where to place subsys "lock file"
514 # ------------------------------------
515 subsysdir=/var/run/subsys
516 AC_ARG_WITH(subsys-dir,
517     [  --with-subsys-dir=PATH    Specify location of Bacula subsys file],
518     [
519         if test "x$withval" != "xno" ; then     
520             subsysdir=$withval
521         fi
522     ]
523 )
524
525 # make sure the pid directory exists
526 if test ! -d $subsysdir ; then     
527     subsysdir=`eval echo ${sysconfdir}`
528     case $subsysdir in
529         NONE/*) subsysdir=`echo $subsysdir | sed "s~NONE~$ac_default_prefix~"` ;;
530     esac
531 fi
532
533 AC_SUBST(subsysdir)
534
535
536
537 # ------------------------------------
538 # Where to start assigning ports
539 # ------------------------------------
540 baseport=9101
541 AC_ARG_WITH(baseport,
542     [  --with-baseport=PORT    Specify base port address for daemons],
543     [
544         if test "x$withval" != "xno" ; then     
545              baseport=$withval
546         fi
547     ]
548 )
549
550 AC_SUBST(baseport)
551 dir_port=`expr $baseport`
552 fd_port=`expr $baseport + 1`
553 sd_port=`expr $fd_port + 1`
554
555 AC_SUBST(dir_port)
556 AC_SUBST(fd_port)
557 AC_SUBST(sd_port)
558
559
560 # ------------------------------------------
561 # Generate passwords
562 # ------------------------------------------
563 dir_password=
564 AC_ARG_WITH(dir-password,
565    [  --with-dir-password=PASSWORD Specify Director's password],
566    [
567        if test "x$withval" != "xno" ; then     
568            dir_password=$withval
569        fi
570    ]
571 )
572
573 if test "x$dir_password" = "x" ; then
574    if test "x$OPENSSL" = "xnone" ; then
575       key=`date | uuencode 1 | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" abcdefghijklmnopqrst | awk '{getline} {print} {exit}'`
576    else
577       key=`openssl rand -base64 33`
578    fi
579    dir_password=$key
580 fi
581
582 fd_password=
583 AC_ARG_WITH(fd-password,
584    [  --with-fd-password=PASSWORD Specify Client's password],
585    [
586        if test "x$withval" != "xno" ; then     
587            fd_password=$withval
588        fi
589    ]
590 )
591
592 if test "x$fd_password" = "x" ; then
593    if test "x$OPENSSL" = "xnone" ; then
594       key=`date | uuencode 1 | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" tsrqponmlkjihgfedcba | awk '{getline} {print} {exit}'`
595    else
596       key=`openssl rand -base64 33`
597    fi
598    fd_password=$key
599 fi
600
601 sd_password=
602 AC_ARG_WITH(sd-password,
603    [  --with-sd-password=PASSWORD Specify Storage daemon's password],
604    [
605        if test "x$withval" != "xno" ; then     
606            sd_password=$withval
607        fi
608    ]
609 )
610
611 if test "x$sd_password" = "x" ; then
612    if test "x$OPENSSL" = "xnone" ; then
613       key=`date | uuencode 1 | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" 123456789uvwxyzabcdef | awk '{getline} {print} {exit}'`
614    else
615       key=`openssl rand -base64 33`
616    fi
617    sd_password=$key
618 fi
619
620
621 AC_SUBST(dir_password)
622 AC_SUBST(fd_password)
623 AC_SUBST(sd_password)
624
625
626
627
628 # ------------------------------------------------
629 # Bacula check for various SQL database engines
630 # ------------------------------------------------
631 BA_CHECK_MYSQL_DB
632
633
634 # ------------------------------------------------
635 # Bacula check for various SQL database engines
636 # ------------------------------------------------
637 BA_CHECK_SQLITE_DB
638
639 AC_SUBST(cats)
640 AC_SUBST(DB_NAME)
641
642 AC_DEFINE(PROTOTYPES)
643
644 dnl# --------------------------------------------------------------------------
645 dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
646 dnl#
647 if test -z "$CFLAGS"; then
648     if test -z "$CCOPTS"; then
649         CCOPTS='-O'
650 dnl>    if test "x$GCC" = xyes; then
651 dnl>        if test x$system = xLinux; then
652 dnl>            CCOPTS="$CCOPTS "'-O2 -fno-strength-reduce'
653 dnl>        fi
654 dnl>    fi
655     fi
656     CFLAGS="$CCOPTS"
657 fi
658
659
660 dnl A few others 
661 AC_EXEEXT
662 dnl # AC_SYS_LARGEFILE  must modify aclocal.m4
663 dnl LARGE_FILE_SUPPORT
664   
665
666
667 AC_PATH_XTRA
668
669 dnl# --------------------------------------------------------------------------
670 dnl# CHECKING FOR HEADER FILES
671 dnl# --------------------------------------------------------------------------
672 AC_CHECK_HEADERS( \
673         assert.h \
674         fcntl.h \
675         grp.h \
676         libc.h \
677         limits.h \
678         stdarg.h \
679         stdlib.h \
680         string.h \
681         termios.h \
682         unistd.h \
683         sys/byteorder.h \
684         sys/ioctl.h \
685         sys/select.h \
686         sys/sockio.h \
687         sys/time.h \
688 )
689 AC_HEADER_STDC
690 AC_HEADER_MAJOR
691 AC_HEADER_DIRENT
692 AC_HEADER_STAT
693 AC_HEADER_SYS_WAIT
694 AC_HEADER_TIME
695 AC_STRUCT_ST_BLKSIZE
696 AC_STRUCT_ST_BLOCKS
697 AC_STRUCT_TIMEZONE
698
699 # It seems that that many machines where <utime.h> seems to be
700 # broken just require something like -D_XXX_SOURCE, where XXX might
701 # be POSIX, POSIX_C, ALL, HPUX or whatever, depending on the machine.
702
703 AC_CACHE_CHECK(for utime.h, tar_cv_header_utime_h,
704   [AC_TRY_COMPILE([
705 #include <sys/types.h>
706 #include <utime.h>], [struct utimbuf foo],
707   tar_cv_header_utime_h=yes, tar_cv_header_utime_h=no)])
708 test $tar_cv_header_utime_h = yes && AC_DEFINE(HAVE_UTIME_H)
709
710 AC_C_CONST
711
712
713 dnl# --------------------------------------------------------------------------
714 dnl# CHECKING FOR FILESYSTEM TYPE
715 dnl# --------------------------------------------------------------------------
716 AC_MSG_CHECKING(how to get filesystem type)
717 fstype=no
718 # The order of these tests is important.
719 AC_TRY_CPP([#include <sys/statvfs.h>
720 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
721 if test $fstype = no; then
722 AC_TRY_CPP([#include <sys/statfs.h>
723 #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
724 fi
725 if test $fstype = no; then
726 AC_TRY_CPP([#include <sys/statfs.h>
727 #include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
728 fi
729 if test $fstype = no; then  
730 AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
731 fi
732 if test $fstype = no; then  
733 AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
734 fi
735 if test $fstype = no; then  
736 AC_TRY_CPP([#include <sys/mount.h>
737 #include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
738 fi
739 AC_MSG_RESULT($fstype)
740
741 dnl# --------------------------------------------------------------------------
742 dnl# CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS.
743 dnl# --------------------------------------------------------------------------
744 AC_TYPE_SIGNAL
745 SIGNAL_CHECK
746 AC_TYPE_MODE_T
747 AC_TYPE_UID_T
748 AC_TYPE_SIZE_T
749 AC_TYPE_PID_T
750 AC_TYPE_OFF_T
751 AC_CHECK_TYPE(ino_t, unsigned long)
752 AC_CHECK_TYPE(dev_t, unsigned long)
753 AC_CHECK_TYPE(daddr_t, long)
754 AC_CHECK_TYPE(major_t, int)
755 AC_CHECK_TYPE(minor_t, int)
756 AC_CHECK_TYPE(ssize_t, int)
757 AC_STRUCT_ST_BLOCKS
758 AC_STRUCT_ST_RDEV
759 AC_STRUCT_TM
760 AC_C_CONST
761
762
763 AC_CHECK_SIZEOF(char, 1)
764 AC_CHECK_SIZEOF(short int, 2)
765 AC_CHECK_SIZEOF(int, 4)
766 AC_CHECK_SIZEOF(long int, 4)
767 AC_CHECK_SIZEOF(long long int, 8)
768 AC_CHECK_SIZEOF(int *, 4)
769
770 # Check for sys/types.h types
771 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
772     AC_TRY_COMPILE(
773         [ #include <sys/types.h> ], 
774         [ u_int a; a = 1;], 
775         [ ac_cv_have_u_int="yes" ],
776         [ ac_cv_have_u_int="no" ]
777     )
778 ])
779 if test "x$ac_cv_have_u_int" = "xyes" ; then
780    AC_DEFINE(HAVE_U_INT)
781    have_u_int=1
782 fi
783
784 AC_CACHE_CHECK([for intmax_t type], ac_cv_have_intmax_t, [
785    AC_TRY_COMPILE(
786       [ #include <sys/types.h> ], 
787       [ intmax_t a; a = 1;], 
788       [ ac_cv_have_intmax_t="yes" ],
789       [ 
790          AC_TRY_COMPILE(
791             [ #include <stdint.h> ], 
792             [ intmax_t a; a = 1;], 
793             [ ac_cv_have_intmax_t="yes" ],
794             [ ac_cv_have_intmax_t="no" ]
795          )
796       ]
797    )        
798
799 ])
800 if test "x$ac_cv_have_intmax_t" = "xyes" ; then
801    AC_DEFINE(HAVE_INTMAX_T)
802    have_intmax_t=1
803 fi
804
805
806 AC_CACHE_CHECK([for u_intmax_t type], ac_cv_have_u_intmax_t, [
807    AC_TRY_COMPILE(
808       [ #include <sys/types.h> ], 
809       [ u_intmax_t a; a = 1;], 
810       [ ac_cv_have_u_intmax_t="yes" ],
811       [ 
812          AC_TRY_COMPILE(
813             [ #include <stdint.h> ], 
814             [ u_intmax_t a; a = 1;], 
815             [ ac_cv_have_u_intmax_t="yes" ],
816             [ ac_cv_have_u_intmax_t="no" ]
817          )
818       ]
819    )
820 ])
821 if test "x$ac_cv_have_u_intmax_t" = "xyes" ; then
822    AC_DEFINE(HAVE_U_INTMAX_T)
823    have_u_intmax_t=1
824 fi
825
826
827 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
828    AC_TRY_COMPILE(
829       [ #include <sys/types.h> ], 
830       [ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
831       [ ac_cv_have_intxx_t="yes" ],
832       [ ac_cv_have_intxx_t="no" ]
833    )
834 ])
835 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
836    AC_DEFINE(HAVE_INTXX_T)
837    have_intxx_t=1
838 fi
839         
840 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
841    AC_TRY_COMPILE(
842       [ #include <sys/types.h> ], 
843       [ int64_t a; a = 1;], 
844       [ ac_cv_have_int64_t="yes" ],
845       [ ac_cv_have_int64_t="no" ]
846    )
847 ])
848 if test "x$ac_cv_have_int64_t" = "xyes" ; then
849    AC_DEFINE(HAVE_INT64_T)
850    have_int64_t=1
851 fi
852         
853 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
854    AC_TRY_COMPILE(
855       [ #include <sys/types.h> ], 
856       [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
857       [ ac_cv_have_u_intxx_t="yes" ],
858       [ ac_cv_have_u_intxx_t="no" ]
859    )
860 ])
861 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
862    AC_DEFINE(HAVE_U_INTXX_T)
863    have_u_intxx_t=1
864 fi
865
866 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
867    AC_TRY_COMPILE(
868       [ #include <sys/types.h> ], 
869       [ u_int64_t a; a = 1;], 
870       [ ac_cv_have_u_int64_t="yes" ],
871       [ ac_cv_have_u_int64_t="no" ]
872    )
873 ])
874 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
875    AC_DEFINE(HAVE_U_INT64_T)
876    have_u_int64_t=1
877 fi
878
879 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
880            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
881 then
882    AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
883    AC_TRY_COMPILE(
884       [ #include <sys/bitypes.h>  ], 
885       [ int8_t a; int16_t b; int32_t c;
886         u_int8_t e; u_int16_t f; u_int32_t g;
887         a = b = c = e = f = g = 1;  ], 
888       [ AC_DEFINE(HAVE_U_INTXX_T)
889         AC_DEFINE(HAVE_INTXX_T)
890         AC_DEFINE(HAVE_SYS_BITYPES_H)
891         AC_MSG_RESULT(yes) ],
892       [ AC_MSG_RESULT(no)]
893    ) 
894 fi
895
896 if test -z "$have_u_intxx_t" ; then
897    AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
898       AC_TRY_COMPILE(
899          [ #include <sys/types.h> ], 
900          [ uint8_t a; uint16_t b; 
901            uint32_t c; a = b = c = 1; ], 
902          [ ac_cv_have_uintxx_t="yes" ],
903          [ ac_cv_have_uintxx_t="no" ]
904       )
905    ])
906    if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
907       AC_DEFINE(HAVE_UINTXX_T)
908    fi
909 fi
910
911
912 dnl# --------------------------------------------------------------------------
913 dnl# CHECKING FOR LIBRARY FUNCTIONS
914 dnl# --------------------------------------------------------------------------
915 AC_CHECK_FUNCS( \
916         fork \
917         getcwd \
918         gethostname \
919         getpid \
920         setpgid \
921         setpgrp \
922         setsid \
923         signal \
924         strerror \
925         strncmp \
926         strncpy \
927         vfprintf \
928         ,,
929         [echo 'configure: cannot find needed function.'; exit 1]
930 )
931
932 AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)])
933
934 AC_CHECK_FUNCS(snprintf vsnprintf)
935
936 dnl# --------------------------------------------------------------------------
937 dnl# CHECKING FOR THREAD SAFE FUNCTIONS
938 dnl# --------------------------------------------------------------------------
939 AC_CHECK_FUNCS(localtime_r readdir_r strerror_r gethostbyname_r)
940
941 # If resolver functions are not in libc check for -lnsl or -lresolv.
942 AC_CHECK_FUNC(gethostbyname_r,
943     AC_MSG_RESULT(using libc's resolver),
944     AC_CHECK_LIB(nsl,gethostbyname_r)
945     AC_CHECK_LIB(resolv,gethostbyname_r))
946
947
948 # Find where sockets are (especially for Solaris)
949 AC_CHECK_FUNC(socket,
950     AC_MSG_RESULT(using libc's socket),
951     AC_CHECK_LIB(xnet,socket)
952     AC_CHECK_LIB(socket,socket)
953     AC_CHECK_LIB(inet,socket))
954
955
956 AC_FUNC_STRFTIME
957 AC_FUNC_VPRINTF
958 AC_FUNC_ALLOCA
959 AC_FUNC_GETMNTENT
960 AC_FUNC_CLOSEDIR_VOID
961 AC_FUNC_SETPGRP                       dnl check for BSD setpgrp.
962 AC_FUNC_FNMATCH
963
964
965 dnl# FreeBSD needs to link libxpg4
966 AC_CHECK_LIB(xpg4, setlocale, [LIBS="$LIBS -lxpg4"])
967
968
969 AC_CHECK_LIB(sun, getpwnam)
970 AC_CHECK_LIB(z, deflate, [FDLIBS="-lz"])
971 have_zlib=no
972 if test x$FDLIBS = x-lz; then
973   AC_DEFINE(HAVE_LIBZ)
974   have_zlib=yes
975 fi
976
977 dnl Check for pthread libraries
978 PTHREAD_LIB=""
979 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
980         [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
981             [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
982                 [AC_CHECK_FUNC(pthread_create)]
983             )]
984         )]
985 )
986
987 AC_SUBST(FDLIBS)
988 AC_DEFINE(FDLIBS)
989
990
991 CFLAGS=${CFLAGS--O}
992 LDFLAGS=${LDFLAGS--O}
993 LIBS="${LIBS} ${SQL_LFLAGS}"
994
995 CPPFLAGS="$CPPFLAGS"
996 AC_SUBST(DEBUG)
997 AC_SUBST(DINCLUDE)
998 AC_SUBST(CFLAGS)
999 AC_SUBST(CPPFLAGS)
1000 AC_SUBST(LDFLAGS)
1001 AC_SUBST(X_CFLAGS)
1002 AC_SUBST(LIBS)
1003 AC_SUBST(DLIB)
1004 AC_SUBST(X_LIBS)
1005 AC_SUBST(X_EXTRA_LIBS)
1006
1007 dnl# extra configurable objects
1008 OBJLIST=
1009 AC_SUBST(OBJLIST)
1010
1011 lld="lld"
1012 llu="llu"
1013
1014 #
1015 # Finally we set appropriate distribution specific
1016 #  variables and defaults
1017 #
1018 # PFILES are platform specific files
1019 PFILES="platforms/Makefile"
1020 PSCMD="ps -e"
1021 WIN32=
1022 hostname=`hostname`
1023 case "$DISTNAME" in
1024 alpha)
1025         DISTVER=`uname -r`
1026         PTHREAD_LIB="-lpthread -lexc"
1027         if test "${CC}" = "gcc" ; then
1028            lld="lld"
1029            llu="llu"
1030         else
1031            lld="ld"
1032            llu="lu"
1033         fi
1034         TAPEDRIVE="/dev/nrmt0"
1035   ;;
1036 bsdi)
1037         DISTVER=`uname -a |awk '{print $3}'`
1038         TAPEDRIVE="/dev/nrst0"
1039   ;;
1040 caldera)
1041         DISTVER=`cat /etc/.issue | grep Version | cut -f 2 -d ' '`
1042         TAPEDRIVE="/dev/nrst0"
1043         PSCMD="ps -e -o pid,command"
1044         hostname=`hostname -s`
1045   ;;
1046 cygwin)
1047         DISTVER=`uname -a |awk '{print $3}'`
1048         TAPEDRIVE="/dev/nrst0"
1049         WIN32=win32
1050         CFLAGS="${CFLAGS} -mwindows"
1051         LDFLAGS="${LDFLAGS} -mwindows"
1052   ;;
1053 debian)
1054         DISTVER=`cat /etc/debian_version`
1055         TAPEDRIVE="/dev/nrst0"
1056         PSCMD="ps -e -o pid,command"
1057         hostname=`hostname -s`
1058   ;;
1059 freebsd)
1060         DISTVER=`uname -a |awk '{print $3}'`
1061         PTHREAD_LIB="-pthread"
1062         CFLAGS="${CFLAGS} -pthread"
1063         lld="qd"
1064         llu="qu"
1065         TAPEDRIVE="/dev/nrst0"
1066         PSCMD="ps -x -o pid,command"
1067         PFILES="${PFILES} \
1068             platforms/freebsd/Makefile \
1069             platforms/freebsd/bacula-fd \
1070             platforms/freebsd/bacula-sd \
1071             platforms/freebsd/bacula-dir"
1072         hostname=`hostname -s`
1073   ;;
1074 hpux)
1075         DISTVER=`uname -r`
1076         TAPEDRIVE="/dev/rmt/0hnb"
1077   ;;
1078 netbsd)
1079         DISTVER=`uname -a |awk '{print $3}'`
1080         lld="qd"
1081         llu="qu"
1082         TAPEDRIVE="/dev/nrst0"
1083         PSCMD="ps -a -o pid,command"
1084   ;;
1085 openbsd)
1086         DISTVER=`uname -a |awk '{print $3}'`
1087         lld="qd"
1088         llu="qu"
1089         TAPEDRIVE="/dev/nrst0"
1090         PSCMD="ps -a -o pid,command"
1091   ;;
1092 redhat)
1093         DISTVER=`cat /etc/redhat-release | grep release |\
1094                                 cut -f 5 -d ' '`
1095         TAPEDRIVE="/dev/nst0"
1096         PSCMD="ps -e -o pid,command"
1097         PFILES="${PFILES} \
1098             platforms/redhat/Makefile \
1099             platforms/redhat/bacula-fd \
1100             platforms/redhat/bacula-sd \
1101             platforms/redhat/bacula-dir"
1102         hostname=`hostname -s`
1103   ;;
1104 slackware)
1105         DISTVER=`cat /etc/slackware-version`
1106         TAPEDRIVE="/dev/nst0"
1107         PSCMD="ps -e -o pid,command"
1108         hostname=`hostname -s`
1109   ;;
1110 solaris)
1111         DISTVER=Solaris
1112         TAPEDRIVE="/dev/rmt/0cbn"
1113         PSCMD="ps -e -o pid,comm"
1114         PFILES="${PFILES} \
1115             platforms/solaris/Makefile \
1116             platforms/solaris/bacula-fd \
1117             platforms/solaris/bacula-sd \
1118             platforms/solaris/bacula-dir"
1119   ;;
1120 suse)
1121         DISTVER=`cat /etc/SuSE-release |grep VERSION|\
1122                                 cut -f 3 -d ' '`
1123         TAPEDRIVE="/dev/nst0"
1124         PSCMD="ps -e -o pid,command"
1125         hostname=`hostname -s`
1126   ;;
1127 suse5)
1128         DISTNAME=suse
1129         DISTVER=5.x
1130         TAPEDRIVE="/dev/nst0"
1131         PSCMD="ps -e -o pid,command"
1132         hostname=`hostname -s`
1133   ;;
1134 unknown)
1135         DISTVER=unknown
1136         TAPEDRIVE="/dev/nst0"
1137   ;;
1138 *)
1139   echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
1140   ;;
1141 esac  
1142
1143 AC_SUBST(hostname)
1144
1145
1146 LIBS="$PTHREAD_LIB $LIBS"
1147
1148 AC_DEFINE_UNQUOTED(lld, "$lld")
1149 AC_DEFINE_UNQUOTED(llu, "$llu")
1150 AC_SUBST(TAPEDRIVE)
1151 AC_SUBST(PSCMD)
1152 AC_SUBST(WIN32)
1153 AC_SUBST(DISTNAME)
1154 AC_SUBST(DISTVER)
1155
1156
1157 dnl# common parts of the Makefile
1158 MCOMMON=./autoconf/Make.common
1159 AC_SUBST_FILE(MCOMMON)
1160
1161 AC_OUTPUT([autoconf/Make.common \
1162            Makefile \
1163            startmysql \
1164            stopmysql \
1165            btraceback \
1166            startit \
1167            stopit \
1168            bacula \
1169            fd \
1170            doc/Makefile \
1171            src/Makefile \
1172            src/console/Makefile \
1173            src/console/console.conf \
1174            src/gnome-console/Makefile \
1175            src/gnome-console/gnome-console.conf \
1176            src/dird/Makefile \
1177            src/dird/bacula-dir.conf \
1178            src/lib/Makefile \
1179            src/stored/Makefile \
1180            src/stored/bacula-sd.conf \
1181            src/filed/Makefile \
1182            src/filed/bacula-fd.conf \
1183            src/filed/win32/Makefile \
1184            src/cats/Makefile \
1185            src/cats/make_mysql_tables \
1186            src/cats/drop_mysql_tables \
1187            src/cats/create_mysql_database \
1188            src/cats/grant_mysql_privileges \
1189            src/cats/make_sqlite_tables \
1190            src/cats/drop_sqlite_tables \
1191            src/cats/create_sqlite_database \
1192            src/cats/sqlite \
1193            src/cats/create_bdb_database \
1194            src/cats/make_bdb_tables \
1195            src/cats/drop_bdb_tables \
1196            src/findlib/Makefile \
1197            $PFILES ],  
1198           [(echo "Doing make of dependencies"; make depend;) ]
1199 )
1200
1201 chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
1202 cp -f startit stopit btraceback btraceback.gdb src/console
1203 cp -f startit stopit btraceback btraceback.gdb src/dird
1204 cp -f startit stopit btraceback btraceback.gdb src/filed
1205 cp -f startit stopit btraceback btraceback.gdb src/lib
1206 cp -f startit stopit btraceback btraceback.gdb src/stored
1207 chmod 755 src/cats/make_mysql_tables src/cats/drop_mysql_tables
1208 chmod 755 src/cats/make_test_tables src/cats/drop_test_tables
1209 chmod 755 src/cats/create_mysql_database
1210 chmod 755 src/cats/grant_mysql_privileges
1211 chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables 
1212 chmod 755 src/cats/create_sqlite_database
1213 chmod 755 src/cats/sqlite
1214 chmod 755 src/cats/make_bdb_tables src/cats/drop_bdb_tables 
1215 chmod 755 src/cats/create_bdb_database
1216
1217 echo "
1218 Configuration on `date`:
1219
1220   Host:                       ${DISTNAME} ${DISTVER}
1221   Bacula version:             ${VERSION} (${DATE})
1222   Source code location:       ${srcdir}
1223   Install binaries:           ${sbindir}
1224   Install config files:       ${sysconfdir}
1225   C Compiler:                 ${CC}
1226   C++ Compiler:               ${CXX}
1227   Compiler flags:             ${CFLAGS} 
1228   Linker flags:               ${LDFLAGS}
1229   Libraries:                  ${LIBS}
1230   Database found:             ${have_db}
1231   Database type:              ${db_name}
1232
1233   Job Output Email:           ${job_email}
1234   Traceback Email:            ${dump_email}
1235   SMTP Host Address:          ${smtp_host}
1236   Director Port               ${dir_port}
1237   File daemon Port            ${fd_port}
1238   Storage daemon Port         ${sd_port}
1239   Working directory           ${working_dir}
1240   SQL binaries Directory      ${SQL_BINDIR}
1241
1242   readline support:           ${got_readline} ${PRTREADLINE_SRC}
1243   cweb support:               ${got_cweb} ${CWEB_SRC}
1244   TCP Wrappers support:       ${TCPW_MSG}
1245   ZLIB support:               ${have_zlib}
1246   enable-smartalloc:          ${support_smartalloc} 
1247   enable-gnome:               ${support_gnome}
1248   gmp support:                ${got_gmp} ${GMP_SRC}
1249
1250   " > config.out
1251
1252 cat config.out