2128f16e0b31056c87c0fa580a71706c03cd0acf
[debian/amanda] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT
4 AC_CONFIG_SRCDIR([common-src/amanda.h])
5 AC_CONFIG_AUX_DIR(config)
6 AC_CANONICAL_TARGET([])
7
8
9 CONFIGURE_COMMAND="'$0'"
10 for arg in "$@"; do
11   CONFIGURE_COMMAND="$CONFIGURE_COMMAND '$arg'"
12 done
13 AC_DEFINE_UNQUOTED(CONFIGURE_COMMAND,"$CONFIGURE_COMMAND",
14           [Saves the original ./configure command line arguments])
15 AC_SUBST(CONFIGURE_COMMAND)
16
17 AM_INIT_AUTOMAKE(amanda, 2.5.0p2)
18 AM_CONFIG_HEADER(config/config.h)
19
20 AC_PREREQ(2.57)         dnl Minimum Autoconf version required.
21
22 if test -f "$srcdir/SNAPSHOT"; then
23   cat < "$srcdir/SNAPSHOT"
24 changequote(,)
25   snapdate=`sed -n '/^Snapshot Date: \([0-9]*\)/ s//\1/p' < $srcdir/SNAPSHOT`
26 changequote([,])
27   test -z "$snapdate" || VERSION="$VERSION-$snapdate"
28   SNAPSHOT_STAMP=SNAPSHOT
29 else
30   SNAPSHOT_STAMP=
31 fi
32 AC_SUBST(SNAPSHOT_STAMP)
33
34 if test -f config.local; then
35     echo "running local script ./config.local"
36     . ./config.local
37 fi
38
39 dnl
40 dnl Set the version number of this release of Amanda from the VERSION
41 dnl string, which is set in AM_INIT_AUTOMAKE.
42 dnl
43 changequote(,)
44 VERSION_MAJOR=`expr "$VERSION" : '\([0-9]*\)'`
45 VERSION_MINOR=`expr "$VERSION" : '[0-9]*\.\([0-9]*\)'`
46 VERSION_PATCH=`expr "$VERSION" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
47 VERSION_COMMENT=\"`expr "$VERSION" : '[0-9]*\.[0-9]*\.[0-9]*\(.*\)'`\"
48 changequote([,])
49
50 VERSION_SUFFIX="$VERSION"
51 AC_SUBST(VERSION_MAJOR)
52 AC_SUBST(VERSION_MINOR)
53 AC_SUBST(VERSION_PATCH)
54 AC_SUBST(VERSION_COMMENT)
55 AC_SUBST(VERSION_SUFFIX)
56
57 dnl
58 dnl runtime and compile time
59 dnl
60 SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:/etc:/usr/etc"
61 LOCPATH=`(
62     test "x$prefix" = xNONE && prefix=$ac_default_prefix
63     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
64     eval echo "$libexecdir:$PATH:/usr/local/sbin:/usr/local/bin:/usr/ccs/bin"
65 )`
66 SYSLOCPATH="$SYSPATH:$LOCPATH"
67 LOCSYSPATH="$LOCPATH:$SYSPATH"
68
69 AC_ARG_WITH(cflags,
70     [  --with-cflags=CFLAGS   arguments to the c compiler (-Wall, -g, etc)],
71     [
72         case "$withval" in
73         "" | y | ye | yes | n | no)
74             AC_MSG_ERROR([*** You must supply an argument to the --with-includes option.])
75             ;;
76         esac
77         CFLAGS="$withval"
78     ])
79
80 AC_ARG_WITH(includes,
81     [  --with-includes=DIR    site header files for readline, etc in DIR],
82     [
83         case "$withval" in
84         "" | y | ye | yes | n | no)
85             AC_MSG_ERROR([*** You must supply an argument to the --with-includes option.])
86           ;;
87         esac
88         INCLUDE_DIRS="$withval"
89     ])
90
91 if test "$INCLUDE_DIRS"; then
92         for dir in $INCLUDE_DIRS; do
93             if test -d "$dir"; then
94                 AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS -I$dir"
95             else
96                 AC_MSG_WARN([*** Include directory $dir does not exist.])
97             fi
98         done
99 fi
100
101 AC_ARG_WITH(libraries,
102     [  --with-libraries=DIR   site library directories for readline, etc in DIR],
103     [
104         case "$withval" in
105         "" | y | ye | yes | n | no)
106             AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
107           ;;
108         esac
109         LIBRARY_DIRS="$withval"
110     ])
111
112 if test "$LIBRARY_DIRS"; then
113         for dir in $LIBRARY_DIRS; do
114             if test -d "$dir"; then
115                 case "$target" in
116                   *-solaris2*,*-netbsd*)
117                         AMANDA_LDFLAGS="$AMANDA_LDFLAGS -R$dir"
118                         ;;
119                 esac
120                 AMANDA_LDFLAGS="$AMANDA_LDFLAGS -L$dir"
121             else
122                 AC_MSG_WARN([*** Library directory $dir does not exist.])
123             fi
124         done
125 fi
126
127 AC_ARG_WITH(dumperdir,
128     [  --with-dumperdir=DIR   where we install the dumpers [[EPREFIX/dumper]]],
129     [
130         case "$withval" in
131         "" | y | ye | yes | n | no)
132             AC_MSG_ERROR([*** You must supply an argument to the --with-dumperdir option.])
133           ;;
134         esac
135         DUMPER_DIR="$withval"
136     ], [
137         test "x$prefix" = xNONE && prefix=$ac_default_prefix
138         test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
139         DUMPER_DIR=$exec_prefix/dumper
140     ]
141 )
142 DUMPER_DIR=`(
143     test "x$prefix" = xNONE && prefix=$ac_default_prefix
144     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
145     eval echo "$DUMPER_DIR"
146 )`
147 AC_DEFINE_UNQUOTED(DUMPER_DIR,"$DUMPER_DIR",[Directory in which dumper interfaces should be installed and searched. ])
148 AC_SUBST(DUMPER_DIR)
149
150 AC_ARG_WITH(configdir,
151     [  --with-configdir=DIR   runtime config files in DIR [[sysconfdir/amanda]]],
152     [
153         case "$withval" in
154         "" | y | ye | yes | n | no)
155             AC_MSG_ERROR([*** You must supply an argument to the --with-configdir option.])
156           ;;
157         *) CONFIG_DIR="$withval"
158           ;;
159         esac
160     ],
161     : ${CONFIG_DIR="$sysconfdir/amanda"}
162 )
163 CONFIG_DIR=`(
164     test "x$prefix" = xNONE && prefix=$ac_default_prefix
165     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
166     eval echo "$CONFIG_DIR"
167 )`
168 AC_DEFINE_UNQUOTED(CONFIG_DIR,"$CONFIG_DIR",
169   [The directory in which configuration directories should be created. ])
170 AC_SUBST(CONFIG_DIR)
171
172 AC_ARG_WITH(indexdir,
173     [  --with-indexdir        deprecated, use indexdir in amanda.conf],
174     [   AC_MSG_ERROR([*** --with-indexdir is deprecated, use indexdir in amanda.conf instead.])
175     ],)
176
177 AC_ARG_WITH(dbdir,
178     [  --with-dbdir           deprecated, use infofile in amanda.conf],
179     [   AC_MSG_ERROR([*** --with-dbdir is deprecated, use infofile in amanda.conf instead.])
180     ],)
181
182 AC_ARG_WITH(logdir,
183     [  --with-logdir          deprecated, use logfile in amanda.conf],
184     [   AC_MSG_ERROR([*** --with-logdir is deprecated, use logdir in amanda.conf instead.])
185     ],)
186
187 AC_ARG_WITH(suffixes,
188     [  --with-suffixes        install binaries with version string appended to name],
189     USE_VERSION_SUFFIXES=$withval,
190     : ${USE_VERSION_SUFFIXES=no}
191 )
192 case "$USE_VERSION_SUFFIXES" in
193 y | ye | yes)
194     AC_DEFINE(USE_VERSION_SUFFIXES, 1,
195         [Define to have programs use version suffixes when calling other programs.])
196
197     program_suffix="-$VERSION"
198     # This is from the output of configure.in.
199     if test "x$program_transform_name" = xs,x,x,; then
200         program_transform_name=
201     else
202         # Double any \ or $.  echo might interpret backslashes.
203         cat <<\EOF_SED > conftestsed
204 s,\\,\\\\,g; s,\$,$$,g
205 EOF_SED
206         program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
207         rm -f conftestsed
208     fi
209     test "x$program_prefix" != xNONE &&
210         program_transform_name="s,^,${program_prefix},; $program_transform_name"
211     # Use a double $ so make ignores it.
212     test "x$program_suffix" != xNONE &&
213         program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
214
215     # sed with no file args requires a program.
216     test "x$program_transform_name" = "" && program_transform_name="xs,x,x,"
217     # Remove empty command
218     cat <<\EOF_SED > conftestsed
219 s,\;\;,\;,g; s,\; \$,,g; s,\;$,,g
220 EOF_SED
221     program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
222     rm -f conftestsed
223   ;;
224 n | no) USE_VERSION_SUFFIXES=no
225   ;;
226 *) AC_MSG_ERROR([*** You must not supply an argument to --with-suffixes option.])
227   ;;
228 esac
229 AC_SUBST(USE_VERSION_SUFFIXES)
230
231 case "$target" in
232     *-hp-*)
233         CLIENT_SCRIPTS_OPT=amhpfixdevs
234         ;;
235     *-sni-sysv4)
236         CLIENT_SCRIPTS_OPT=amsinixfixdevs
237         ;;
238     *)
239         CLIENT_SCRIPTS_OPT=
240         ;;
241 esac
242
243 AC_SUBST(CLIENT_SCRIPTS_OPT)
244
245 AC_ARG_WITH(client-only,
246     [  --with-client-only     deprecated, use --without-server],
247     [   AC_MSG_ERROR([*** --with-client-only is deprecated, use --without-server instead.])
248     ],)
249 AC_ARG_WITH(server-only,
250     [  --with-server-only     deprecated, use --without-client],
251     [   AC_MSG_ERROR([*** --with-server-only is deprecated, use --without-client instead.])
252     ],)
253
254 AC_ARG_WITH(client,
255     [  --without-client       do not build client stuff],
256     [
257         case "$withval" in
258         y | ye | yes) NO_CLIENT_MODE=false;;
259         n | no) NO_CLIENT_MODE=true;;
260         *)
261             AC_MSG_ERROR([*** You must not supply an argument to --with-client option.])
262           ;;
263         esac
264     ]
265 )
266
267 AC_ARG_WITH(server,
268     [  --without-server       do not build server stuff (set --without-restore)],
269     [
270         case "$withval" in
271         y | ye | yes) NO_SERVER_MODE=false ;;
272         n | no) NO_SERVER_MODE=true;NO_RESTORE_MODE=true;;
273         *)
274             AC_MSG_ERROR([*** You must not supply an argument to --with-server option.  Maybe you meant --with-index-server=$withval])
275           ;;
276         esac
277     ]
278 )
279 if test "x${NO_SERVER_MODE+set}" != xset ; then
280    NO_SERVER_MODE=false
281 fi
282
283 AC_ARG_WITH(restore,
284     [  --without-restore      do not build amrestore nor amidxtaped],
285     [
286         case "$withval" in
287         y | ye | yes) NO_RESTORE_MODE=false;;
288         n | no) NO_RESTORE_MODE=true;;
289         *)
290             AC_MSG_ERROR([*** You must not supply an argument to --with-restore option.])
291           ;;
292         esac
293     ]
294 )
295 if test "x${NO_RESTORE_MODE+set}" != xset ; then
296    NO_RESTORE_MODE=${NO_SERVER_MODE-false}
297 fi
298
299 if ${NO_SERVER_MODE-false}; then
300    if ${NO_RESTORE_MODE-false}; then
301       dnl
302       dnl --without-server and --without-restore is OK
303       dnl
304       true
305    else
306       AC_MSG_ERROR([*** --without-server requires --without-restore])
307    fi
308 fi
309
310 AC_ARG_WITH(amrecover,
311     [  --without-amrecover    do not build amrecover],
312     [
313         case "$withval" in
314         y | ye | yes)
315             if ${NO_CLIENT_MODE-false}; then
316                 AC_MSG_ERROR([*** --without-client and --with-amrecover are incompatible])
317             fi
318             NO_RECOVER_MODE=false;;
319         n | no) NO_RECOVER_MODE=true;;
320         *)
321             AC_MSG_ERROR([*** You must not supply an argument to --with-amrecover option.])
322           ;;
323         esac
324     ]
325 )
326
327 AC_ARG_WITH(index-server,
328    [  --with-index-server=HOST default amanda index server [[`uname -n`]]],
329    [
330         case "$withval" in
331         "" | y | ye | yes | n | no)
332             AC_MSG_ERROR([*** You must supply an argument to the --with-index-server option.])
333           ;;
334         *) DEFAULT_SERVER="$withval"
335           ;;
336         esac
337    ],
338    : ${DEFAULT_SERVER=`uname -n`}
339 )
340 AC_DEFINE_UNQUOTED(DEFAULT_SERVER,"$DEFAULT_SERVER",
341   [This is the default Amanda index server. ])
342 AC_SUBST(DEFAULT_SERVER)
343
344 AC_ARG_WITH(force-uid,
345     [  --without-force-uid    do not force the uid to --with-user],
346     FORCE_USERID="$withval",
347     : ${FORCE_USERID=yes}
348 )
349 case "$FORCE_USERID" in
350 y | ye | yes) AC_DEFINE(FORCE_USERID, 1,
351         [Define to force to another user on client machines. ])
352   ;;
353 n | no) :
354   ;;
355 *) AC_MSG_ERROR([*** You must not supply an argument to --with-force-uid option.])
356 esac
357
358 AC_ARG_WITH(user,
359     [  --with-user=USER       force execution to USER on client systems [[required]]],
360     [
361         case "$withval" in
362         "" | y | ye | yes | n | no)
363             AC_MSG_ERROR([*** You must supply an argument to the --with-user option.])
364           ;;
365         *) CLIENT_LOGIN="$withval"
366           ;;
367         esac
368     ]
369 )
370 if test "x${CLIENT_LOGIN+set}" != xset; then
371     AC_MSG_ERROR([*** --with-user=USER is missing])
372 fi
373 AC_DEFINE_UNQUOTED(CLIENT_LOGIN,"$CLIENT_LOGIN",
374   [Define as a the user to force to on client machines. ])
375 AC_SUBST(CLIENT_LOGIN)
376
377 AC_ARG_WITH(group,
378     [  --with-group=GROUP     group allowed to execute setuid-root programs [[required]]],
379     [
380         case "$withval" in
381         "" | y | ye | yes | n | no)
382             AC_MSG_ERROR([*** You must supply an argument to the --with-group option.])
383           ;;
384         *) SETUID_GROUP="$withval"
385           ;;
386         esac
387     ]
388 )
389 if test "x${SETUID_GROUP+set}" != xset; then
390     AC_MSG_ERROR([*** --with-group=GROUP is missing])
391 fi
392 AC_SUBST(SETUID_GROUP)
393
394 AC_ARG_WITH(owner,
395     [  --with-owner=USER       force ownership of files to USER [[default == --with-user value]]],
396     [
397         case "$withval" in
398         "" | y | ye | yes | n | no)
399             AC_MSG_ERROR([*** You must supply an argument to the --with-owner option.])
400           ;;
401         *) BINARY_OWNER="$withval"
402           ;;
403         esac
404     ]
405 )
406 if test "x${BINARY_OWNER+set}" != xset ; then
407    BINARY_OWNER=$CLIENT_LOGIN
408 fi
409 AC_DEFINE_UNQUOTED(BINARY_OWNER,"$BINARY_OWNER",
410   [Define as the user who owns installed binaries. ])
411 AC_SUBST(BINARY_OWNER)
412
413 AC_ARG_WITH(rundump,
414     [  --with-rundump         use rundump (setuid-root) to invoke dump],
415     [
416     case "$withval" in
417         n | no | y | ye | yes) FORCE_USE_RUNDUMP="$withval";;
418         *) AC_MSG_ERROR([*** You must not supply an argument to --with-rundump option.]);;
419     esac
420     ]
421 )
422
423 AC_ARG_WITH(config,
424    [  --with-config=CONFIG   default configuration [[DailySet1]]],
425    [
426         case "$withval" in
427         "" | y | ye | yes | n | no)
428             AC_MSG_ERROR([*** You must supply an argument to the --with-config option.])
429           ;;
430         *) DEFAULT_CONFIG="$withval"
431           ;;
432         esac
433    ],
434    : ${DEFAULT_CONFIG=DailySet1}
435 )
436 AC_DEFINE_UNQUOTED(DEFAULT_CONFIG,"$DEFAULT_CONFIG",
437   [This is the default Amanda configuration. ])
438 AC_SUBST(DEFAULT_CONFIG)
439
440 AC_ARG_WITH(tape-server,
441     [  --with-tape-server=HOST default restoring tape server is HOST [[same as --with-index-server]]],
442     [
443         case "$withval" in
444         "" | y | ye | yes | n | no)
445             AC_MSG_ERROR([*** You must supply an argument to the --with-tape-server option.])
446           ;;
447         *) DEFAULT_TAPE_SERVER="$withval"
448           ;;
449         esac
450     ],
451     : ${DEFAULT_TAPE_SERVER=$DEFAULT_SERVER}
452 )
453 AC_DEFINE_UNQUOTED(DEFAULT_TAPE_SERVER,"$DEFAULT_TAPE_SERVER",[This is the default restoring Amanda tape server. ])
454 AC_SUBST(DEFAULT_TAPE_SERVER)
455
456 AC_ARG_WITH(tape-device,
457     [  --with-tape-device=ARG restoring tape server HOST's no rewinding tape drive],
458     [
459         case "$withval" in
460         "" | y | ye | yes | n | no)
461             AC_MSG_ERROR([*** You must supply an argument to the --with-tape-device option.])
462           ;;
463         *) DEFAULT_TAPE_DEVICE="$withval"
464           ;;
465         esac
466     ],
467     [
468         if test -z "$DEFAULT_TAPE_DEVICE"; then
469             AC_MSG_CHECKING(for non-rewinding tape device)
470             dnl Check for the /dev/rmt directory and use what's in there.
471             dnl Otherwise look for tape devices in /dev.  For the devices
472             dnl in /dev/rmt, we want to use the Berkeley behavior of
473             dnl reading the first record of the next tape file after 0
474             dnl bytes are returned upon reading to the next tape mark,
475             dnl instead of returning an error.  Look for devices that have
476             dnl a 'b' in their name.
477             tape_dev=null:
478             nr_tape_dev=null:
479             if test -d /dev/rmt; then
480
481                 dnl See if we can find two devices, one being the norewind
482                 dnl version of the other.  Devices in this directory are
483                 dnl normally a digit followed by some characters.  We also
484                 dnl want the Berkely behavior, since Amanda needs it for
485                 dnl amrestore.
486
487                 for num in 9 8 7 6 5 4 3 2 1 0; do
488                     td=/dev/rmt/${num}b
489                     ntd=/dev/rmt/${num}bn
490                     if test -r $td -a -r $ntd; then
491                         tape_dev=$td
492                         nr_tape_dev=$ntd
493                     fi
494                 done
495             else
496                 dnl Look for tape devices in /dev.
497                 for num in 9 8 7 6 5 4 3 2 1 0; do
498                     td=/dev/rst${num}
499                     ntd=/dev/nrst${num}
500                     if test -r $td -a -r $ntd; then
501                         tape_dev=$td
502                         nr_tape_dev=$ntd
503                     fi
504                 done
505             fi
506             DEFAULT_TAPE_DEVICE=$nr_tape_dev
507             AC_MSG_RESULT($DEFAULT_TAPE_DEVICE)
508         fi
509     ]
510 )
511
512 if test -z "$DEFAULT_TAPE_DEVICE"; then
513     DEFAULT_TAPE_DEVICE=/dev/null
514 fi
515
516 AC_DEFINE_UNQUOTED(DEFAULT_TAPE_DEVICE,"$DEFAULT_TAPE_DEVICE",[This is the default no-rewinding tape device. ])
517 AC_SUBST(DEFAULT_TAPE_DEVICE)
518
519 AC_ARG_WITH(ftape-raw-device,
520     [  --with-ftape-rawdevice=ARG raw device on tape server HOST's if using Linux ftape >=3.04d],
521     [
522         case "$withval" in
523         "" | y | ye | yes | n | no)
524             AC_MSG_ERROR([*** You must supply an argument to the --with-ftape-rawdevice option.])
525           ;;
526         *) DEFAULT_RAW_TAPE_DEVICE="$withval"
527           ;;
528         esac
529     ],
530     [
531         if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then
532             AC_MSG_CHECKING(for raw ftape device)
533             dnl Look for tape devices in /dev.  
534             raw_tape_dev=/dev/null
535                 dnl Look for tape devices in /dev.
536                 for num in 3 2 1 0 ; do
537                     td=/dev/rawft${num}
538                     if test -r $td; then
539                         raw_tape_dev=$td
540                     fi
541                 done
542             DEFAULT_RAW_TAPE_DEVICE=$raw_tape_dev
543             AC_MSG_RESULT($DEFAULT_RAW_TAPE_DEVICE)
544         fi
545     ]
546 )
547
548 if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then
549     DEFAULT_RAW_TAPE_DEVICE=/dev/null
550 fi
551
552 AC_DEFINE_UNQUOTED(DEFAULT_RAW_TAPE_DEVICE,"$DEFAULT_RAW_TAPE_DEVICE",[For Linux systems with floppy tapes: 
553  * QIC volume table support via raw tape device. ])
554 AC_SUBST(DEFAULT_RAW_TAPE_DEVICE)
555
556 AC_ARG_WITH(rew-tape,
557     [  --with-rew-tape        deprecated, use --with-tape-device],
558     [   AC_MSG_ERROR([*** --with-rew-tape is deprecated, use --with-tape-device instead.])
559     ],)
560
561 AC_ARG_WITH(norew-tape,
562     [  --with-norew-tape=ARG  deprecated, use --with-tape-device],
563     [   AC_MSG_ERROR([*** --with-norew-tape is deprecated, use --with-tape-device instead.])
564     ],)
565
566 AC_ARG_WITH(changer-device,
567     [  --with-changer-device=ARG default tape changer device [[/dev/ch0 if it exists]]],
568     [
569         case "$withval" in
570         "" | y | ye | yes | n | no)
571             AC_MSG_ERROR([*** You must supply an argument to the --with-changer-device option.])
572           ;;
573         *) DEFAULT_CHANGER_DEVICE="$withval"
574           ;;
575         esac
576     ],
577     [
578         if test -z "$DEFAULT_CHANGER_DEVICE" &&
579            test -f /dev/ch0; then
580             DEFAULT_CHANGER_DEVICE=/dev/ch0
581         fi
582     ]
583 )
584
585 if test -z "$DEFAULT_CHANGER_DEVICE"; then
586     DEFAULT_CHANGER_DEVICE=/dev/null
587 fi
588
589 AC_DEFINE_UNQUOTED(DEFAULT_CHANGER_DEVICE,"$DEFAULT_CHANGER_DEVICE",[This is the default changer device. ])
590 AC_SUBST(DEFAULT_CHANGER_DEVICE)
591
592 AC_ARG_WITH(fqdn,
593     [  --with-fqdn            use FQDN's to backup multiple networks],
594     USE_FQDN=$withval,
595     : ${USE_FQDN=no}
596 )
597 case "$USE_FQDN" in
598 n | no) : ;;
599 y |  ye | yes) AC_DEFINE(USE_FQDN,1,[Define for backups being done on a multiple networks and FQDNs are used. ])
600   ;;
601 *) AC_MSG_ERROR([*** You must not supply an argument to --with-fqdn option.])
602   ;;
603 esac
604
605 AC_ARG_WITH(broken-fsf,
606     [  --with-broken-fsf      only enable if tape fsf calls fail mid-file],
607     HAVE_BROKEN_FSF=$withval,
608     : ${HAVE_BROKEN_FSF=no}
609 )
610 case "$HAVE_BROKEN_FSF" in
611 n | no) : ;;
612 y |  ye | yes) AC_DEFINE(HAVE_BROKEN_FSF,1,[Define this if issuing a fsf on a tape fails when you are not at a tape
613  * mark, for instance, if amrecover gives I/O errors when skipping.
614 ])
615   ;;
616 *) AC_MSG_ERROR([*** You must not supply an argument to --with-broken-fsf option.])
617   ;;
618 esac
619
620 AC_ARG_WITH(gnutar,
621     [  --with-gnutar[[=PROG]]      use PROG as GNU tar executable [[default: looks for one]]],
622     [
623         case "$withval" in
624             /*) GNUTAR="$withval";;
625             y|ye|yes) :;;
626             n|no) GNUTAR=;;
627             *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-gnutar]);;
628         esac
629     ]
630 )
631
632 AC_ARG_WITH(smbclient,
633     [  --with-smbclient[[=PROG]]   use PROG as Samba's smbclient executable [[default: looks for one]]],
634     [
635         case "$withval" in
636             /*) SAMBA_CLIENT="$withval";;
637             y|ye|yes) :;;
638             n|no) SAMBA_CLIENT=;;
639             *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-smbclient]);;
640         esac
641     ]
642 )
643
644 AC_ARG_WITH(samba-user,
645    [  --with-samba-user was deprecated],
646    [    AC_MSG_ERROR([*** The samba-user option was deprecated, the username go in the amandapass])
647    ]
648 )
649
650 AC_ARG_WITH(gnutar-listdir,
651    [  --with-gnutar-listdir=DIR  gnutar directory lists go in DIR [[localstatedir/amanda/gnutar-lists]]],
652    [
653         case "$withval" in
654             n | no)             unset GNUTAR_LISTDIR ;;
655             y | ye | yes)       : ${GNUTAR_LISTDIR=$localstatedir/amanda/gnutar-lists} ;;
656             /*)                 GNUTAR_LISTDIR="$withval" ;;
657             *)                  AC_MSG_ERROR([*** You must supply a full pathname to --with-gnutar-listdir])
658         esac
659     ],
660     : ${GNUTAR_LISTDIR="$localstatedir/amanda/gnutar-lists"}
661 )
662 if test "$GNUTAR_LISTDIR"; then
663     GNUTAR_LISTDIR=`(
664         test "x$prefix" = xNONE && prefix=$ac_default_prefix
665         eval echo "$GNUTAR_LISTDIR"
666     )`
667     AC_DEFINE_UNQUOTED(GNUTAR_LISTED_INCREMENTAL_DIR,"$GNUTAR_LISTDIR",[The directory in which GNU tar should store directory lists for incrementals. ])
668     GNUTAR_LISTED_INCREMENTAL_DIRX=$GNUTAR_LISTDIR
669 else
670     GNUTAR_LISTED_INCREMENTAL_DIRX=
671 fi
672 AC_SUBST(GNUTAR_LISTED_INCREMENTAL_DIRX)
673
674 AC_ARG_WITH(gnutar-listed-incremental,
675    [  --with-gnutar-listed-incremental was deprecated, use --with-gnutar-listdir],
676    [    AC_MSG_ERROR([*** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead])
677    ]
678 )
679 GNUTAR_LISTED_INCREMENTAL_DIR=$GNUTAR_LISTDIR
680 AC_SUBST(GNUTAR_LISTED_INCREMENTAL_DIR)
681
682 AC_ARG_WITH(bsd-security,
683     [  --without-bsd-security do not use BSD rsh/rlogin style security],
684     BSD_SECURITY=$withval,
685     : ${BSD_SECURITY=yes}
686 )
687 case "$BSD_SECURITY" in
688 n | no) : ;;
689 y |  ye | yes) AC_DEFINE(BSD_SECURITY,1,[Define to use BSD .rhosts/.amandahosts security. ])
690   ;;
691 *) AC_MSG_ERROR([*** You must not supply an argument to --with-bsd-security option.])
692   ;;
693 esac
694
695 AC_ARG_WITH(amandahosts,
696     [  --without-amandahosts  use .rhosts instead of .amandahosts],
697     USE_AMANDAHOSTS=$withval,
698     : ${USE_AMANDAHOSTS=yes}
699 )
700 case "$USE_AMANDAHOSTS" in
701 n | no) : ;;
702 y |  ye | yes) :
703   case "$BSD_SECURITY" in
704   y | ye | yes) AC_DEFINE(USE_AMANDAHOSTS,1,[Define if you want to use the .amandahosts for BSD security. ])
705     ;;
706   esac
707   ;;
708 *) AC_MSG_ERROR([*** You must not supply an argument to --with-amandahosts option.])
709   ;;
710 esac
711
712 dnl Specify --with-dbmalloc if you desire dbmalloc to be linked in
713
714 AC_ARG_WITH(dbmalloc,
715     [  --with-dbmalloc=DIR  Location of dbmalloc libs and headers],
716     DBMALLOC="$withval",
717     : ${DBMALLOC=no}
718 )
719
720 case "$DBMALLOC" in
721 n | no)
722     DBMALLOCCFLAGS=""
723     DBMALLOCLIBS=""
724     ;;
725 *) 
726     DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC"
727     DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc"
728     ;;
729 esac
730
731 dnl Specify --with-krb4-security if Kerberos software is in somewhere
732 dnl other than the listed KRB4_SPOTS.  We only compile kerberos support in
733 dnl if the right files are there.
734
735 : ${KRB4_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
736
737 AC_ARG_WITH(krb4-security,
738     [  --with-krb4-security=DIR   Location of Kerberos software [[/usr/kerberos /usr/cygnus /usr /opt/kerberos]]],
739     KRB4_SECURITY="$withval",
740     : ${KRB4_SECURITY=no}
741 )
742
743 case "$KRB4_SECURITY" in
744 n | no) KRB4_SECURITY=no ;;
745 y | ye | yes) : ;;
746 *) KRB4_SPOTS="$KRB4_SECURITY"
747    KRB4_SECURITY=yes
748    ;;
749 esac
750
751 AC_MSG_CHECKING(for Kerberos and Amanda kerberos4 bits)
752 if test "x${KRB4_SECURITY}" = xyes -a -f  ${srcdir-.}/common-src/krb4-security.c ; then
753     for dir in $KRB4_SPOTS; do
754         if test -f ${dir}/lib/libkrb.a -a -f ${dir}/lib/libdes.a ; then
755             #
756             # This is the original Kerberos 4.
757             #
758             AC_MSG_RESULT(found in $dir)
759             KRB4_SECURITY=yes
760             AC_DEFINE(KRB4_SECURITY, 1, [Enable Kerberos security. ])
761             if test -d $dir/include/kerberosIV ; then
762                 #
763                 # This handles BSD/OS.
764                 #
765                 KRB4INCLUDES=-I$dir/include/kerberosIV
766             else
767                 KRB4INCLUDES=-I$dir/include
768             fi
769             KRB4LDFLAGS=-L$dir/lib
770             KRB4LIBS="-lkrb -ldes"
771             if test -f ${dir}/lib/libcom_err.a; then
772                 KRB4LIBS="$KRB4LIBS -lcom_err"
773             fi
774             break
775         elif test -f ${dir}/lib/libkrb4.a &&
776              test -f ${dir}/lib/libcrypto.a &&
777              test -f ${dir}/lib/libdes425.a ; then
778             #
779             # This is Kerberos 5 with Kerberos 4 back-support.
780             #
781             AC_MSG_RESULT(found in $dir)
782             KRB4_SECURITY=yes
783             AC_DEFINE(KRB4_SECURITY, 1, [Enable Kerberos security. ])
784             KRB4INCLUDES="-I$dir/include -I$dir/include/kerberosIV"
785             KRB4LDFLAGS=-L$dir/lib
786             if test -f ${dir}/lib/libkrb5.a &&
787                test -f ${dir}/lib/libcom_err.a; then
788                 KRB4LIBS="-lkrb4 -lkrb5 -lcrypto -ldes425 -lcom_err"
789             else
790                 KRB4LIBS="-lkrb4 -lcrypto -ldes425"
791             fi
792             break
793         fi
794     done
795
796     if test "x$KRB4LDFLAGS" = "x" ; then
797         AC_MSG_RESULT(no libraries found)
798     fi
799 else
800     AC_MSG_RESULT(no)
801 fi
802
803 AC_ARG_WITH(rsh-security,
804     [  --with-rsh-security use rsh as a transport],
805     RSH_SECURITY=$withval,
806     : ${RSH_SECURITY=yes}
807 )
808 case "$RSH_SECURITY" in
809 n | no) : ;;
810 y |  ye | yes) AC_DEFINE(RSH_SECURITY,1,[Define if RSH transport should be enabled. ])
811   ;;
812 *) AC_MSG_ERROR([*** You must not supply an argument the to --with-rsh-security option.])
813   ;;
814 esac
815
816 AC_ARG_WITH(ssh-security,
817     [  --with-ssh-security use ssh as a transport],
818     SSH_SECURITY=$withval,
819     : ${SSH_SECURITY=no}
820 )
821 case "$SSH_SECURITY" in
822 n | no) : ;;
823 y |  ye | yes) AC_DEFINE(SSH_SECURITY,1,[Define if SSH transport should be enabled. ])
824                SSH_SECURITY_SET=true
825   ;;
826 *) AC_MSG_ERROR([*** You must not supply an argument the to --with-ssh-security option.])
827   ;;
828 esac
829
830 AC_ARG_WITH(server-principal,
831     [    --with-server-principal=ARG    server host principal  [["amanda"]]],
832     [
833         case "$withval" in
834         "" | y | ye | yes | n | no)
835             AC_MSG_ERROR([*** You must supply an argument to the --with-server-principal option.])
836           ;;
837         *)
838             SERVER_HOST_PRINCIPLE="$withval"
839           ;;
840         esac
841     ],
842     : ${SERVER_HOST_PRINCIPLE="amanda"}
843 )
844 AC_DEFINE_UNQUOTED(SERVER_HOST_PRINCIPLE,"$SERVER_HOST_PRINCIPLE",[The Kerberos server principle. ])
845
846 AC_ARG_WITH(server-instance,
847     [    --with-server-instance=ARG     server host instance   [["amanda"]]],
848     [
849         case "$withval" in
850         "" | y | ye | yes | n | no)
851             AC_MSG_ERROR([*** You must supply an argument to the --with-server-instance option.])
852           ;;
853         *) SERVER_HOST_INSTANCE="$withval"
854           ;;
855         esac
856     ],
857     : ${SERVER_HOST_INSTANCE="amanda"}
858 )
859 AC_DEFINE_UNQUOTED(SERVER_HOST_INSTANCE,"$SERVER_HOST_INSTANCE",[The Kerberos server instance. ])
860
861 AC_ARG_WITH(server-keyfile,
862     [    --with-server-keyfile=ARG      server host key file   [["/.amanda"]]],
863     [
864         case "$withval" in
865         "" | y | ye | yes | n | no)
866             AC_MSG_ERROR([*** You must supply an argument to the --with-server-keyfile option.])
867           ;;
868         *) SERVER_HOST_KEY_FILE="$withval"
869           ;;
870         esac
871     ],
872     : ${SERVER_HOST_KEY_FILE="/.amanda"}
873 )
874 AC_DEFINE_UNQUOTED(SERVER_HOST_KEY_FILE,"$SERVER_HOST_KEY_FILE",[The Kerberos server key file. ])
875
876 AC_ARG_WITH(client-principal,
877     [    --with-client-principal=ARG    client host principal  [["rcmd"]]],
878     [
879         case "$withval" in
880         "" | y | ye | yes | n | no)
881             AC_MSG_ERROR([*** You must supply an argument to the --with-client-principal option.])
882           ;;
883         *) CLIENT_HOST_PRINCIPLE="$withval"
884           ;;
885         esac
886     ],
887     : ${CLIENT_HOST_PRINCIPLE="rcmd"}
888 )
889 AC_DEFINE_UNQUOTED(CLIENT_HOST_PRINCIPLE,"$CLIENT_HOST_PRINCIPLE",[The Kerberos client host principle. ])
890
891 AC_ARG_WITH(client-instance,
892     [    --with-client-instance=ARG     client host instance   [[HOSTNAME_INSTANCE]]],
893     [
894         case "$withval" in
895         "" | y | ye | yes | n | no)
896             AC_MSG_ERROR([*** You must supply an argument to the --with-client-instance option.])
897           ;;
898         *) CLIENT_HOST_INSTANCE="$withval"
899           ;;
900         esac
901     ],
902     : ${CLIENT_HOST_INSTANCE=HOSTNAME_INSTANCE}
903 )
904 AC_DEFINE_UNQUOTED(CLIENT_HOST_INSTANCE,$CLIENT_HOST_INSTANCE,[The Kerberos client host instance. ])
905
906 AC_ARG_WITH(client-keyfile,
907     [    --with-client-keyfile=ARG      client host key file   [[KEYFILE]]],
908     [
909         case "$withval" in
910         "" | y | ye | yes | n | no)
911             AC_MSG_ERROR([*** You must supply an argument to the --with-client-keyfile option.])
912           ;;
913         *) CLIENT_HOST_KEY_FILE="$withval"
914           ;;
915         esac
916     ],
917     : ${CLIENT_HOST_KEY_FILE=KEYFILE}
918 )
919
920 # Assume it's either KEYFILE (defined in krb.h), or a string filename...
921 if test "x$CLIENT_HOST_KEY_FILE" != "xKEYFILE"; then
922   CLIENT_HOST_KEY_FILE="\"$CLIENT_HOST_KEY_FILE\""
923 fi
924
925 AC_DEFINE_UNQUOTED(CLIENT_HOST_KEY_FILE,$CLIENT_HOST_KEY_FILE,[The Kerberos client host key file. ])
926
927 AC_ARG_WITH(ticket-lifetime,
928     [    --with-ticket-lifetime=ARG     ticket lifetime        [[128]]],
929     [
930         case "$withval" in
931         "" | y | ye | yes | n | no)
932             AC_MSG_ERROR([*** You must supply an argument to the --with-ticket-lifetime option.])
933           ;;
934         *) TICKET_LIFETIME="$withval"
935           ;;
936         esac
937     ],
938     : ${TICKET_LIFETIME=128}
939 )
940 AC_DEFINE_UNQUOTED(TICKET_LIFETIME,$TICKET_LIFETIME,[The Kerberos ticket lifetime. ])
941
942 dnl Specify --with-krb5-security if Kerberos software is in somewhere
943 dnl other than the listed KRB5_SPOTS.  We only compile kerberos support in
944 dnl if the right files are there.
945
946 : ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
947
948 AC_ARG_WITH(krb5-security,
949     [  --with-krb5-security=DIR   Location of Kerberos V software [[/usr/kerberos /usr/cygnus /usr /opt/kerberos]]],
950     KRB5_SECURITY="$withval",
951     : ${KRB5_SECURITY=no}
952 )
953
954 case "$KRB5_SECURITY" in
955 n | no) KRB5_SECURITY=no
956         KRB5_SPOTS=""
957         ;;
958 y | ye | yes) : ;;
959 *) KRB5_SPOTS="$KRB5_SECURITY"
960    KRB5_SECURITY=yes
961    ;;
962 esac
963
964 # if found, force the static versions of these libs (.a) by linking directly
965 # with the .a files.  I don't know how to get -R dependancies checked
966 # in autoconf at this time. -kashmir
967 AC_MSG_CHECKING(for Kerberos V)
968 KRB5_DIR_FOUND=""
969 KRB5_CFLAGS=""
970 for dir in $KRB5_SPOTS; do
971     k5libdir=${dir}/lib
972     if test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libgssapi_krb5.a -a -f ${k5libdir}/libcom_err.a; then
973         if test -f ${k5libdir}/libcrypto.a; then
974             K5CRYPTO=${k5libdir}/libcrypto.a
975         elif test -f ${k5libdir}/libk5crypto.a; then
976             K5CRYPTO=${k5libdir}/libk5crypto.a
977         else
978             K5CRYPTO=""
979         fi
980         KRB5_DIR_FOUND=$dir
981         KRB5LIBS="${k5libdir}/libgssapi_krb5.a ${k5libdir}/libkrb5.a $K5CRYPTO ${k5libdir}/libcom_err.a"
982         KRB5CFLAGS=""
983         break
984     elif test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libasn1.a -a -f ${k5libdir}/libgssapi.a; then
985         KRB5_DIR_FOUND=$dir
986         KRB5LIBS="${k5libdir}/libgssapi.a ${k5libdir}/libkrb5.a ${k5libdir}/libasn1.a"
987         KRB5_CFLAGS="-DKRB5_HEIMDAL_INCLUDES"
988         break
989     fi
990 done
991
992 if test "$KRB5_DIR_FOUND"; then
993         AC_MSG_RESULT(found in $KRB5_DIR_FOUND)
994         KRB5_SECURITY=yes
995         AC_DEFINE(KRB5_SECURITY,1,[Define if Kerberos 5 security is to be enabled. ])
996         #
997         # some OS's, such as NetBSD, stick krb5 includes out of the way...
998         # should probably just use autoconf to look for various include
999         # options and set them, but don't quite want to do that until I've
1000         # dug into it a bit more.
1001         #
1002         if test -d "$KRB5_DIR_FOUND/krb5" ; then
1003                 KRB5INCLUDES="-I$KRB5_DIR_FOUND/include/krb5"
1004         else
1005                 KRB5INCLUDES="-I$KRB5_DIR_FOUND/include"
1006         fi
1007         if test "$KRB5_CFLAGS" ; then
1008                 KRB5INCLUDES="$KRB5INCLUDES $KRB5_CFLAGS"
1009         fi
1010         KRB5LDFLAGS=-L$k5libdir
1011         break
1012 fi
1013
1014 if test "x$KRB5LDFLAGS" = "x" ; then
1015     AC_MSG_RESULT(no krb5 system libraries found)
1016 fi
1017
1018
1019 AC_ARG_WITH(portrange,
1020     [  --with-portrange=low,high     bind unreserved TCP server sockets to ports within this range [[unlimited]]],
1021     [
1022         TCPPORTRANGE="$withval"
1023     ]
1024 )
1025 AC_ARG_WITH(tcpportrange,
1026     [  --with-tcpportrange=low,high  bind unreserved TCP server sockets to ports within this range [[unlimited]]],
1027     [
1028         TCPPORTRANGE="$withval"
1029     ]
1030 )
1031 if test x"${TCPPORTRANGE+set}" = x"set"; then
1032     if test x`echo "$TCPPORTRANGE" | sed 's/[[0-9]][[0-9]]*,[[0-9]][[0-9]]*//'` != x""; then
1033         AC_MSG_ERROR([*** --with-tcpportrange requires two comma-separated positive numbers])
1034     fi
1035     min_tcp_port=`echo "$TCPPORTRANGE" | sed 's/,.*//'`
1036     max_tcp_port=`echo "$TCPPORTRANGE" | sed 's/.*,//'`
1037     if test $min_tcp_port -gt $max_tcp_port; then
1038         AC_MSG_ERROR([*** the second TCP port number must be greater than the first in --with-tcpportrange])
1039     fi
1040     if test $min_tcp_port -lt 1024; then
1041         AC_MSG_WARN([*** the TCP port range should be 1024 or greater in --with-tcpportrange])
1042     fi
1043     if test $max_tcp_port -ge 65536; then
1044         AC_MSG_WARN([*** the TCP port range should be less than 65536 in --with-tcpportrange])
1045     fi
1046     AC_DEFINE_UNQUOTED(TCPPORTRANGE,$TCPPORTRANGE,[A comma-separated list of two integers, determining the minimum and
1047    maximum unreserved TCP port numbers sockets should be bound to. ])
1048 fi
1049
1050 AC_ARG_WITH(udpportrange,
1051     [  --with-udpportrange=low,high  bind reserved UDP server sockets to ports within this range [[unlimited]]],
1052     [
1053         UDPPORTRANGE="$withval"
1054     ]
1055 )
1056 if test x"${UDPPORTRANGE+set}" = x"set"; then
1057     if test x`echo "$UDPPORTRANGE" | sed 's/[[0-9]][[0-9]]*,[[0-9]][[0-9]]*//'` != x""; then
1058         AC_MSG_ERROR([*** --with-udpportrange requires two comma-separated positive numbers])
1059     fi
1060     min_udp_port=`echo "$UDPPORTRANGE" | sed 's/,.*//'`
1061     max_udp_port=`echo "$UDPPORTRANGE" | sed 's/.*,//'`
1062     if test $min_udp_port -gt $max_udp_port; then
1063         AC_MSG_ERROR([*** the second UDP port number must be greater than the first in --with-udpportrange])
1064     fi
1065     if test $max_udp_port -ge 1024; then
1066         AC_MSG_WARN([*** the UDP port range should be less than 1024 in --with-udpportrange])
1067     fi
1068     if test $min_udp_port -le 0; then
1069         AC_MSG_WARN([*** the UDP port range should be greater than 0 in --with-udpportrange])
1070     fi
1071     AC_DEFINE_UNQUOTED(UDPPORTRANGE,$UDPPORTRANGE,[A comma-separated list of two integers, determining the minimum and
1072    maximum reserved UDP port numbers sockets should be bound to. ])
1073 fi
1074
1075 AC_ARG_WITH(maxtapeblocksize,
1076     [  --with-maxtapeblocksize=kb            Maximum size of a tape block],
1077     [
1078         MAXTAPEBLOCKSIZE="$withval"
1079     ],
1080     : ${MAXTAPEBLOCKSIZE=32}
1081 )
1082
1083 AC_DEFINE_UNQUOTED(MAX_TAPE_BLOCK_KB,($MAXTAPEBLOCKSIZE),[Maximum size of a tape block in KBytes.])
1084 AC_SUBST(MAXTAPEBLOCKSIZE)
1085
1086 AC_ARG_WITH(db,
1087     [  --with-db={text,db,dbm,gdbm,ndbm} use the selected database format [[text]]],
1088     [
1089         case "$withval" in
1090         "" | y | ye | yes | n | no)
1091             AC_MSG_ERROR([*** You must supply an argument to the --with-db option.])
1092           ;;
1093         *) DB_STYLE="$withval"
1094           ;;
1095         esac
1096     ]
1097 )
1098 if test "$DB_STYLE"; then
1099     case "$DB_STYLE" in
1100         db | dbm | gdbm | ndbm | text)  ;;
1101         *)
1102             AC_MSG_ERROR([*** Unknown argument $DB_STYLE given to --with-db.  Choose from db, dbm, gdbm, ndbm, text.])
1103             DB_STYLE=
1104             ;;
1105     esac
1106 fi
1107
1108 AC_ARG_WITH(mmap,
1109     [  --with-mmap            force use of mmap instead of shared memory support],
1110     FORCE_MMAP=$withval,
1111     : ${FORCE_MMAP=no}
1112 )
1113 case "$FORCE_MMAP" in
1114 y | ye | yes | n | no) : ;;
1115 *) AC_MSG_ERROR([*** You must not supply an argument to --with-mmap.])
1116   ;;
1117 esac
1118
1119 AC_ARG_WITH(buffered-dump,
1120     [  --with-buffered-dump   buffer the dumping sockets on the server for speed],
1121     DUMPER_SOCKET_BUFFERING=$withval,
1122     : ${DUMPER_SOCKET_BUFFERING=no}
1123 )
1124 case "$DUMPER_SOCKET_BUFFERING" in
1125 n | no) :
1126   ;;
1127 y | ye | yes) AC_DEFINE(DUMPER_SOCKET_BUFFERING,1,[Define if dumper should buffer the sockets for faster throughput. ])
1128   ;;
1129 *) AC_MSG_ERROR([*** You must not supply an argument to --with-buffered-dump.])
1130   ;;
1131 esac
1132
1133 AC_ARG_WITH(assertions,
1134     [  --with-assertions      compile assertions into code],
1135     ASSERTIONS="$withval",
1136     : ${ASSERTIONS=no}
1137 )
1138 case "$ASSERTIONS" in
1139 n | no) : ;;
1140 y |  ye | yes) AC_DEFINE(ASSERTIONS,1,[Define if you want assertion checking. ])
1141   ;;
1142 *) AC_MSG_ERROR([*** You must not supply an argument to --with-assertions option.])
1143   ;;
1144 esac
1145
1146 AC_ARG_WITH(tmpdir,
1147     [  --with-tmpdir[=/temp/dir] area Amanda can use for temp files [[/tmp/amanda]]],
1148     tmpdir="$withval",
1149     : ${tmpdir=yes}
1150 )
1151 tmpdir=`(
1152     test "x$prefix" = xNONE && prefix=$ac_default_prefix
1153     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1154     eval echo "$tmpdir"
1155 )`
1156 case "$tmpdir" in
1157 n | no) AC_MSG_ERROR([*** --without-tmpdir is not allowed.]);;
1158 y |  ye | yes)
1159         AMANDA_TMPDIR="/tmp/amanda";;
1160 /*)
1161         AMANDA_TMPDIR="$tmpdir";;
1162 *) AC_MSG_ERROR([*** You must supply a full pathname to --with-tmpdir option.]);;
1163 esac
1164 AC_DEFINE_UNQUOTED(AMANDA_TMPDIR,"$AMANDA_TMPDIR",[The directory in which Amanda should create temporary files. ])
1165 AC_SUBST(AMANDA_TMPDIR)
1166
1167 AC_ARG_WITH(debugging,
1168     [  --with[[out]]-debugging[[=/debug/dir]] [[do not]] record runtime debugging information in specified directory [[--with-tmpdir]]],
1169     debugging="$withval",
1170     : ${debugging=yes}
1171 )
1172 debugging=`(
1173     test "x$prefix" = xNONE && prefix=$ac_default_prefix
1174     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1175     eval echo "$debugging"
1176 )`
1177 case "$debugging" in
1178 n | no) AMANDA_DBGDIR="";;
1179 y |  ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR";;
1180 /*) AMANDA_DBGDIR="$debugging";;
1181 *) AC_MSG_ERROR([*** You must supply a full pathname to --with-debugging option.])
1182   ;;
1183 esac
1184 case "$AMANDA_DBGDIR" in
1185 "") :;;
1186 *) AC_DEFINE(DEBUG_CODE,1,[Define if you want debugging. ])
1187    AC_DEFINE_UNQUOTED(AMANDA_DBGDIR,"$AMANDA_DBGDIR",[Location of Amanda directories and files. ])
1188    AC_SUBST(AMANDA_DBGDIR);;
1189 esac
1190
1191 AC_ARG_WITH(debug_days,
1192     [  --with-debug-days=NN    number of days to keep debugging files [[default=4]]],
1193     debug_days="$withval",
1194     : ${debug_days=4}
1195 )
1196 case "$debug_days" in
1197 n | no) AMANDA_DEBUG_DAYS=0 ;;
1198 y |  ye | yes) AMANDA_DEBUG_DAYS=4 ;;
1199 [[0-9]] | [[0-9]][[0-9]] | [[0-9]][[0-9]][[0-9]]) AMANDA_DEBUG_DAYS="$debug_days" ;;
1200 *) AC_MSG_ERROR([*** --with-debug-days value not numeric or out of range.])
1201   ;;
1202 esac
1203 AC_DEFINE_UNQUOTED(AMANDA_DEBUG_DAYS,$AMANDA_DEBUG_DAYS,[Number of days to keep debugging files. ])
1204 AC_SUBST(AMANDA_DEBUG_DAYS)
1205
1206 AC_ARG_WITH(testing,
1207     [  --with-testing[[=suffix]] use alternate service names],
1208     TESTING="$withval",
1209     : ${TESTING=no}
1210 )
1211 case "$TESTING" in
1212 n | no) SERVICE_SUFFIX="";;
1213 y |  ye | yes) SERVICE_SUFFIX="-test";;
1214 *) SERVICE_SUFFIX="-$TESTING";;
1215 esac
1216 AMANDA_SERVICE_NAME="amanda$SERVICE_SUFFIX"
1217 KAMANDA_SERVICE_NAME="kamanda$SERVICE_SUFFIX"
1218 AC_SUBST(SERVICE_SUFFIX)
1219 AC_DEFINE_UNQUOTED(SERVICE_SUFFIX, "$SERVICE_SUFFIX",[A suffix that will be appended to service names.
1220  * Useful for testing in parallel with a working version. ])
1221 AC_DEFINE_UNQUOTED(AMANDA_SERVICE_NAME,  "$AMANDA_SERVICE_NAME", [The name for the Amanda service. ])
1222 AC_DEFINE_UNQUOTED(KAMANDA_SERVICE_NAME, "$KAMANDA_SERVICE_NAME", [The name for the Kerberized Amanda service. ])
1223
1224 (
1225     test "x$prefix" = xNONE && prefix=$ac_default_prefix
1226     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1227
1228     tmp=`eval echo "$bindir"`
1229     AC_DEFINE_UNQUOTED(bindir,"$tmp",[Directory in which user binaries should be installed. ])
1230
1231     tmp=`eval echo "$sbindir"`
1232     AC_DEFINE_UNQUOTED(sbindir,"$tmp",[Directory in which administrator binaries should be installed. ])
1233
1234     tmp=`eval echo "$libexecdir"`
1235     AC_DEFINE_UNQUOTED(libexecdir,"$tmp",[Directory in which internal binaries should be installed. ])
1236
1237     tmp=`eval echo $mandir`
1238     AC_DEFINE_UNQUOTED(mandir,"$tmp",[Directory in which man-pages should be installed])
1239 )
1240
1241 AC_PROG_CC
1242 AC_OBJEXT
1243 AC_EXEEXT
1244
1245 dnl Set the order of dump programs to look for.  Finding the proper file
1246 dnl system dumping program is problematic.  Some systems, notably HP-UX
1247 dnl and AIX, have both the backup and dump programs.  HP-UX can't use the
1248 dnl the backup program while AIX systems can't use the dump program.  So
1249 dnl a variable is set up here to specify the order of dump programs to
1250 dnl search for on the system.
1251 DUMP_PROGRAMS="ufsdump dump backup"
1252 GETCONF_LFS="LFS"
1253
1254 dump_returns_1=
1255 xenix_tapeio=
1256 case "$target" in
1257     *-dec-osf*)
1258                         AC_DEFINE(STATFS_OSF1,1,[Define on OSF1. ])
1259                         ;;
1260     *-dg-*)
1261                         DUMP_PROGRAMS="dump "$DUMP_PROGRAMS
1262                         : ${USE_RUNDUMP=yes}
1263                         dump_returns_1=yes
1264                         ;;
1265     *-netbsd*)
1266                         ;;
1267     *-freebsd*)
1268                         ;;
1269     *-openbsd*)
1270                         ;;
1271     *-hp-*)
1272                         MT_FILE_FLAG="-t"
1273                         GETCONF_LFS="XBS5_ILP32_OFFBIG"
1274                         case "$CC" in
1275                             *gcc*)
1276                                 AMANDA_CPPFLAGS="-D__STDC_EXT__ $AMANDA_CPPFLAGS"
1277                                 ;;
1278                             *cc*)
1279                                 AMANDA_CFLAGS="-Ae $AMANDA_CFLAGS"
1280                                 ;;
1281                         esac
1282                         ;;
1283   *-ibm-aix*)
1284                         GETCONF_LFS="XBS5_ILP32_OFFBIG"
1285                         DUMP_PROGRAMS="backup "$DUMP_PROGRAMS
1286                         AC_DEFINE(AIX_TAPEIO,1,[Define on AIX. ])
1287                         AC_DEFINE(AIX_BACKUP,1,[Define on AIX. ])
1288                         ;;
1289   m88k-motorola-sysv4)
1290                         ;;
1291   *-nextstep3)
1292                         ;;
1293   *-pc-bsdi*)
1294                         ;;
1295   *-pc-linux-*)
1296                         ;;
1297   x86_64-*-linux-*)
1298                         ;;
1299   alpha*-*-linux-*)
1300                         ;;
1301   sparc*-*-linux-*)
1302                         ;;
1303   powerpc-*-linux-*)
1304                         ;;
1305   *-sgi-irix3*)
1306                         dnl The old cc won't work!
1307                         CC=gcc
1308                         ;;
1309   *-sgi-irix4*)
1310                         ;;
1311   *-sgi-irix5*)
1312                         ;;
1313   *-sgi-irix6*)
1314                         ;;
1315   *-solaris2*)
1316                         ;;
1317   *-sun-sunos4.1*)
1318                         ;;
1319   *-ultrix*)
1320                         : ${USE_RUNDUMP=yes}
1321                         AC_DEFINE(STATFS_ULTRIX,1,[Define on Ultrix. ])
1322                         dump_returns_1=yes
1323                         ;;
1324   *-sysv4.2uw2*)
1325                         AC_DEFINE(UWARE_TAPEIO,1,[Define on UnixWare. ])
1326                         ;;
1327   *-sco3.2v4*)
1328                         DEV_PREFIX=/dev/
1329                         RDEV_PREFIX=/dev/
1330                         ;;
1331   *-sco3.2v5*)
1332                         xenix_tapeio=yes
1333                         AC_DEFINE(STATFS_SCO_OS5,1,[Define on SCO OS5. ])
1334                         ;;
1335   i386-pc-isc4*)
1336                         xenix_tapeio=yes
1337                         ;;
1338   *-sni-sysv4)
1339                         ;;
1340   *-pc-cygwin)
1341                         AC_DEFINE(IGNORE_TAR_ERRORS,1,[Define on Cygwin. ])
1342                         # Cygwin needs PATH to find cygwin1.dll
1343                         AC_DEFINE(NEED_PATH_ENV,1,[Define on Cygwin. ])
1344                         AC_DEFINE(IGNORE_UID_CHECK,1,[Define on Cygwin. ])
1345                         AC_DEFINE(IGNORE_FSTAB,1,[Define on Cygwin. ])
1346                         AC_DEFINE(DONT_SUID_ROOT,1,[Define on Cygwin. ])
1347                         NEED_SETUID_CLIENT=false
1348                         NEED_RUNTIME_PSEUDO_RELOC=true
1349                         ;;
1350   *)
1351                         cat <<END
1352
1353 *****
1354 This machine, target type $target, is not known
1355 to be fully supported by this configure script.  If the
1356 installation of Amanda on this system succeeds or needed
1357 any patches, please email amanda-hackers@amanda.org with
1358 the patches or an indication of the sucess or failure of
1359 the Amanda installation on your system.
1360 *****
1361
1362 END
1363                 ;;
1364 esac
1365
1366 if test -n "$dump_returns_1"; then
1367   AC_DEFINE(DUMP_RETURNS_1,1,[Define this if this system's dump exits with 1 as a success code. ])
1368 fi
1369
1370 if test -n "$xenix_tapeio"; then
1371   AC_DEFINE(XENIX_TAPEIO,1,[Define on XENIX/ISC. ])
1372 fi
1373
1374 AMANDA_CFLAGS="$AMANDA_CFLAGS $KRB4INCLUDES $KRB5INCLUDES $DBMALLOCCFLAGS"
1375 AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS $KRB4INCLUDES $KRB5INCLUDES $DBMALLOCINCLUDES"
1376 AMANDA_LDFLAGS="$AMANDA_LDFLAGS $KRB4LDFLAGS $KRB5LDFLAGS"
1377 AMANDA_LIBS="$KRB4LIBS $KRB5LIBS $DBMALLOCLIBS $AMANDA_LIBS"
1378 CFLAGS="$CFLAGS $AMANDA_CFLAGS"
1379 CPPFLAGS="$CPPFLAGS $AMANDA_CPPFLAGS"
1380 LDFLAGS="$LDFLAGS $AMANDA_LDFLAGS"
1381 LIBS="$AMANDA_LIBS $LIBS"
1382
1383
1384 dnl This specifies the flag for mt that tells mt the proper tape drive
1385 dnl to use.
1386 : ${MT_FILE_FLAG="-f"}
1387 AC_SUBST(MT_FILE_FLAG)
1388 AC_DEFINE_UNQUOTED(MT_FILE_FLAG, "$MT_FILE_FLAG",[Defined to the switch to be used when invoking mt to specify the
1389  * tape device. ])
1390
1391 AX_CREATE_STDINT_H(common-src/amanda-int.h)
1392
1393 dnl Check for programs.
1394 AC_PATH_PROGS(AR,ar,,$LOCSYSPATH)
1395
1396 AC_PROG_AWK
1397 AMANDA_PROG_AWK_VAR
1398 if test "x$amanda_cv_awk_var_assignment" = xno; then
1399     NO_AMPLOT_MODE=true
1400     AC_MSG_WARN([*** Your $awk cannot do command line variable assignment.  Amplot will not be installed.])
1401 fi
1402
1403 AC_PROG_YACC
1404 AC_PATH_PROGS(CAT,cat,,$LOCSYSPATH)
1405 if test -z "$CAT"; then
1406     CAT=cat
1407 fi
1408 AC_PATH_PROGS(COMPRESS,compress,,$LOCSYSPATH)
1409 AC_PATH_PROGS(DD,dd,,$LOCSYSPATH)
1410 AC_PATH_PROGS(EGREP,egrep,,$LOCSYSPATH)
1411 AC_PATH_PROGS(GETCONF,getconf,,$SYSPATH)
1412
1413 AC_PATH_PROGS(GNUPLOT,gnuplot,,$LOCSYSPATH)
1414 if test -z "$GNUPLOT"; then
1415     NO_AMPLOT_MODE=true
1416     AC_MSG_WARN([*** You do not have gnuplot.  Amplot will not be installed.])
1417 fi
1418
1419 AC_PATH_PROGS(GREP,grep,,$LOCSYSPATH)
1420 if test -z "$GREP"; then
1421     GREP=grep
1422 fi
1423 AC_DEFINE_UNQUOTED(GREP,"$GREP",[Define the location of the grep program. ])
1424
1425 AC_PATH_PROGS(GNUTAR,gtar gnutar tar,,$LOCSYSPATH)
1426 if test ! -z "$GNUTAR"; then
1427   case "`\"$GNUTAR\" --version 2>&1`" in
1428    *GNU*tar* | *Free*paxutils* )
1429                 AC_DEFINE_UNQUOTED(GNUTAR,"$GNUTAR",[Define to the location of Gnu tar. ])
1430                 ;;
1431    *)
1432                 AC_MSG_WARN([*** $GNUTAR is not GNU tar, so it will not be used.])
1433                 GNUTAR=
1434                 ;;
1435   esac
1436 fi
1437
1438 AC_PATH_PROGS(SAMBA_CLIENT,smbclient,,$LOCSYSPATH)
1439 if test ! -z "$SAMBA_CLIENT"; then
1440   case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1`" in
1441   *"Unknown host"*)
1442                 smbversion=1
1443                 ;;
1444   *"Connection to not.a.host.name failed"*)
1445                 smbversion=2
1446                 ;;
1447   *)
1448                 AC_MSG_WARN([*** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used.])
1449                 SAMBA_CLIENT=
1450                 ;;
1451   esac
1452   if test -n "$SAMBA_CLIENT"; then
1453     AC_DEFINE_UNQUOTED(SAMBA_CLIENT,"$SAMBA_CLIENT",[Define the location of smbclient for backing up Samba PC clients. ])
1454     AC_DEFINE_UNQUOTED(SAMBA_VERSION, $smbversion,
1455       [Not the actual samba version, just a number that should be increased whenever we start to rely on a new samba feature. ])
1456   fi
1457 fi
1458
1459 AC_PATH_PROGS(GZIP,gzip,,$LOCSYSPATH)
1460 if test "$GZIP"; then
1461     AC_DEFINE(HAVE_GZIP,1,[Define if Amanda is using the gzip program. ])
1462     COMPRESS_PATH="$GZIP"
1463     COMPRESS_SUFFIX=".gz"
1464     COMPRESS_FAST_OPT="--fast"
1465     COMPRESS_BEST_OPT="--best"
1466     UNCOMPRESS_PATH="$GZIP"
1467     UNCOMPRESS_OPT="-dc"
1468 else
1469     if test "$COMPRESS"; then
1470         COMPRESS_PATH="$COMPRESS"
1471         COMPRESS_SUFFIX=".Z"
1472         COMPRESS_FAST_OPT="-f"
1473         COMPRESS_BEST_OPT="-f"
1474         UNCOMPRESS_PATH="$COMPRESS"
1475         UNCOMPRESS_OPT="-dc"
1476     else
1477         dnl If we have to use cat, we don't define COMPRESS_FAST_OPT,
1478         dnl COMPRESS_BEST_OPT, or UNCOMPRESS_OPT as "" since cat will look
1479         dnl look for a file by the name of "".
1480         AC_MSG_WARN([*** Cannot find either gzip or compress.  Using cat. ***])
1481         COMPRESS_PATH="$CAT"
1482         COMPRESS_SUFFIX=""
1483         COMPRESS_FAST_OPT=""
1484         COMPRESS_BEST_OPT=""
1485         UNCOMPRESS_PATH="$CAT"
1486         UNCOMPRESS_OPT=""
1487     fi
1488 fi
1489 AC_DEFINE_UNQUOTED(COMPRESS_PATH,"$COMPRESS_PATH",[Define to the exact path to the gzip or the compress program. ])
1490 AC_DEFINE_UNQUOTED(COMPRESS_SUFFIX,"$COMPRESS_SUFFIX",[Define to the suffix for the COMPRESS_PATH compression program. ])
1491 AC_DEFINE_UNQUOTED(COMPRESS_FAST_OPT,"$COMPRESS_FAST_OPT",[Define as the command line option for fast compression. ])
1492 AC_DEFINE_UNQUOTED(COMPRESS_BEST_OPT,"$COMPRESS_BEST_OPT",[Define as the command line option for best compression. ])
1493 AC_DEFINE_UNQUOTED(UNCOMPRESS_PATH,"$UNCOMPRESS_PATH",[Define as the exact path to the gzip or compress command. ])
1494 AC_DEFINE_UNQUOTED(UNCOMPRESS_OPT,"$UNCOMPRESS_OPT",[Define as any optional arguments to get UNCOMPRESS_PATH to uncompress. ])
1495
1496 AC_PATH_PROGS(MAILER,Mail mailx mail)
1497 if test -z "$MAILER"; then
1498     if $NO_SERVER_MODE; then
1499         MAILER="NONE"
1500         AC_MSG_WARN([*** WARNING: Amanda cannot send mail reports without these programs.])
1501     else
1502         AC_MSG_ERROR([Set MAILER to some program that accepts -s subject user < message_file.])
1503     fi
1504 fi
1505 AC_DEFINE_UNQUOTED(MAILER,"$MAILER",[Define to a program that understands -s "subject" user < message_file])
1506
1507 AC_PATH_PROGS(MT,mt,mt,$LOCSYSPATH)
1508
1509 AC_PATH_PROGS(CHIO,chio,chio,$LOCSYSPATH)
1510
1511 AC_PATH_PROGS(CHS,chs,chs,$LOCSYSPATH)
1512
1513 AC_PATH_PROGS(MTX,mtx,mtx,$LOCSYSPATH)
1514
1515 AC_PATH_PROGS(MCUTIL,mcutil,mcutil,$LOCSYSPATH)
1516
1517 AC_PATH_PROGS(PRINT, lpr lp)
1518 if test ! -z "$PRINT"; then
1519     AC_DEFINE_UNQUOTED(LPRCMD, "$PRINT",[Command for starting printing jobs. ])
1520     AC_CACHE_CHECK([which flag to use to select a printer],
1521         amanda_cv_printer_flag, [
1522         amanda_cv_printer_flag=$PRINTER_FLAG
1523         case "$PRINT" in
1524         lpr|*/lpr) amanda_cv_printer_flag="-P";;
1525         lp|*/lp) amanda_cv_printer_flag="-d";;
1526         esac
1527     ])
1528     if test ! -z "$amanda_cv_printer_flag"; then
1529         AC_DEFINE_UNQUOTED(LPRFLAG, "$amanda_cv_printer_flag",[LPRCMD switch for specifying a printer name. ])
1530     else
1531         AC_MSG_WARN([*** WARNING: amanda will always print to the default printer])
1532     fi
1533 fi
1534
1535 AC_PATH_PROGS(PCAT,pcat,,$LOCSYSPATH)
1536 AC_PATH_PROGS(PERL,perl5 perl,,$LOCSYSPATH)
1537
1538 dnl AC_PATH_PROGS(MAKEINFO,makeinfo,,$LOCSYSPATH)
1539 dnl AC_PATH_PROGS(TEXI2DVI,texi2dvi,,$LOCSYSPATH)
1540
1541 AC_PATH_PROGS(DUMP,$DUMP_PROGRAMS,,$SYSLOCPATH)
1542 AC_PATH_PROGS(RESTORE,ufsrestore restore,,$SYSLOCPATH)
1543 if test "$DUMP" -a "$RESTORE"; then
1544     AC_DEFINE_UNQUOTED(DUMP,"$DUMP",[Define the location of the ufsdump, backup, or dump program. ])
1545     AC_DEFINE_UNQUOTED(RESTORE,"$RESTORE",[Define the location of the ufsrestore or restore program. ])
1546     if test -x $DUMP; then
1547         AC_CACHE_CHECK(
1548             [whether $DUMP supports -E or -S for estimates],
1549             amanda_cv_dump_estimate,
1550             [
1551                 case "$DUMP" in
1552                 *dump)
1553                     AC_TRY_COMMAND($DUMP 9Ef /dev/null /dev/null/invalid/fs 2>&1
1554                         | $GREP -v Dumping
1555                         | $GREP -v Date
1556                         | $GREP -v Label >conftest.d-E 2>&1)
1557                     cat conftest.d-E >&AS_MESSAGE_LOG_FD()
1558                     AC_TRY_COMMAND($DUMP 9Sf /dev/null /dev/null/invalid/fs 2>&1
1559                         | $GREP -v Dumping
1560                         | $GREP -v Date
1561                         | $GREP -v Label >conftest.d-S 2>&1)
1562                     cat conftest.d-S >&AS_MESSAGE_LOG_FD()
1563                     AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
1564                         | $GREP -v Dumping
1565                         | $GREP -v Date
1566                         | $GREP -v Label >conftest.d 2>&1)
1567                     cat conftest.d >&AS_MESSAGE_LOG_FD()
1568                     if AC_TRY_COMMAND(cmp conftest.d-E conftest.d 1>&2); then
1569                         amanda_cv_dump_estimate=E
1570                     elif AC_TRY_COMMAND(cmp conftest.d-S conftest.d 1>&2); then
1571                         amanda_cv_dump_estimate=S
1572                     else
1573                         amanda_cv_dump_estimate=no
1574                     fi
1575                     rm -f conftest.d conftest.d-E conftest.d-S
1576                   ;;
1577                 *) amanda_cv_dump_estimate=no
1578                   ;;
1579                 esac
1580             ])
1581     else
1582         AC_MSG_WARN([*** $DUMP is not executable, cannot run -E/-S test])
1583         amanda_cv_dump_estimate=no
1584     fi
1585     if test "x$amanda_cv_dump_estimate" != xno; then
1586         AC_DEFINE_UNQUOTED(HAVE_DUMP_ESTIMATE, "$amanda_cv_dump_estimate",[Define to the string that enables dump estimates. ])
1587     fi
1588
1589     AC_ARG_WITH(dump-honor-nodump,
1590     [  --with-dump-honor-nodump  if dump supports -h, use it for level0s too],
1591     [ if test -x $DUMP; then
1592         AC_CACHE_CHECK(
1593           [whether $DUMP supports -h (honor nodump flag)],
1594           amanda_cv_honor_nodump,
1595           [
1596             case "$DUMP" in
1597             *dump)
1598                 AC_TRY_COMMAND($DUMP 9hf 0 /dev/null /dev/null/invalid/fs 2>&1
1599                     | $GREP -v Dumping
1600                     | $GREP -v Date
1601                     | $GREP -v Label >conftest.d-h 2>&1)
1602                 cat conftest.d-h >&AS_MESSAGE_LOG_FD()
1603                 AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
1604                     | $GREP -v Dumping
1605                     | $GREP -v Date
1606                     | $GREP -v Label >conftest.d 2>&1)
1607                 cat conftest.d >&AS_MESSAGE_LOG_FD()
1608                 if AC_TRY_COMMAND(diff conftest.d-h conftest.d 1>&2); then
1609                     amanda_cv_honor_nodump=yes
1610                 else
1611                     amanda_cv_honor_nodump=no
1612                 fi
1613                 rm -f conftest.d conftest.d-h
1614               ;;
1615             *) amanda_cv_honor_nodump=no
1616               ;;
1617             esac
1618           ])
1619       else
1620         AC_MSG_WARN([*** $DUMP is not executable, cannot run -h test])
1621         amanda_cv_honor_nodump=no
1622       fi
1623       if test "x$amanda_cv_honor_nodump" = xyes; then
1624         AC_DEFINE(HAVE_HONOR_NODUMP,1,[Define this if dump accepts -h for honoring nodump. ])
1625       fi
1626     ])
1627 fi
1628
1629 AC_PATH_PROGS(XFSDUMP,xfsdump,,$SYSLOCPATH)
1630 AC_PATH_PROGS(XFSRESTORE,xfsrestore,,$SYSLOCPATH)
1631 if test "$XFSDUMP" -a "$XFSRESTORE"; then
1632     AC_DEFINE_UNQUOTED(XFSDUMP,"$XFSDUMP",[Define the location of the xfsdump program on Irix hosts. ])
1633     AC_DEFINE_UNQUOTED(XFSRESTORE,"$XFSRESTORE",[Define the location of the xfsrestore program on Irix hosts. ])
1634     AC_MSG_WARN([*** xfsdump causes the setuid-root rundump program to be enabled])
1635     AC_MSG_WARN([[*** to disable it, just #undef XFSDUMP in config/config.h]])
1636 fi
1637
1638 VXSYSLOCPATH="$SYSLOCPATH:/usr/lib/fs/vxfs"
1639 AC_PATH_PROGS(VXDUMP,vxdump,,$VXSYSLOCPATH)
1640 AC_PATH_PROGS(VXRESTORE,vxrestore,,$VXSYSLOCPATH)
1641 if test "$VXDUMP" -a "$VXRESTORE"; then
1642     AC_DEFINE_UNQUOTED(VXDUMP,"$VXDUMP",[Define the location of the vxdump program on HPUX and SINIX hosts or on
1643  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
1644     AC_DEFINE_UNQUOTED(VXRESTORE,"$VXRESTORE",[Define the location of the vxrestore program on HPUX and SINIX hosts or on
1645  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
1646 fi
1647
1648 AC_PATH_PROGS(VDUMP,vdump,,$SYSLOCPATH)
1649 AC_PATH_PROGS(VRESTORE,vrestore,,$SYSLOCPATH)
1650 if test "$VDUMP" -a "$VRESTORE"; then
1651     AC_DEFINE_UNQUOTED(VDUMP,"$VDUMP",[Define the location of the vdump program. ])
1652     AC_DEFINE_UNQUOTED(VRESTORE,"$VRESTORE",[Define the location of the vrestore program. ])
1653 fi
1654
1655 dnl Handle all of the substitutions to make amplot work.
1656 if test "$PCAT"; then
1657     AMPLOT_CAT_PACK="if(o==\"z\")print \"$PCAT\"; else"
1658 else
1659     AMPLOT_CAT_PACK=
1660 fi
1661 if test "$COMPRESS"; then
1662     AMPLOT_COMPRESS=$COMPRESS
1663     AMPLOT_CAT_COMPRESS="if(o==\"Z\")print \"$COMPRESS -dc\"; else"
1664 else
1665     AMPLOT_CAT_COMPRESS=
1666 fi
1667 if test "$GZIP"; then
1668     AMPLOT_COMPRESS=$GZIP
1669     AMPLOT_CAT_GZIP="if(o==\"gz\")print \"$GZIP -dc\"; else"
1670 else
1671     AMPLOT_CAT_GZIP=
1672 fi
1673 AC_SUBST(AMPLOT_COMPRESS)
1674 AC_SUBST(AMPLOT_CAT_GZIP)
1675 AC_SUBST(AMPLOT_CAT_COMPRESS)
1676 AC_SUBST(AMPLOT_CAT_PACK)
1677
1678 # Determine the printf format characters to use when printing
1679 # values of type long long. This will normally be "ll", but where
1680 # the compiler treats "long long" as a alias for "long" and printf
1681 # doesn't know about "long long" use "l".  Hopefully the sprintf
1682 # will produce a inconsistant result in the later case.  If the compiler
1683 # fails due to seeing "%lld" we fall back to "l".
1684 #
1685 # Win32 uses "%I64d", but that's defined elsewhere since we don't use
1686 # configure on Win32.
1687 #
1688 AC_MSG_CHECKING(printf format modifier for 64-bit integers)
1689 AC_TRY_RUN([
1690 #include <stdio.h>
1691 main() {
1692         long long int j = 0;
1693         char buf[100];
1694         buf[0] = 0;
1695         sprintf(buf, "%lld", j);
1696         exit((sizeof(long long int) != sizeof(long int))? 0 :
1697              (strcmp(buf, "0") != 0));
1698
1699 ],
1700         [AC_MSG_RESULT(ll)
1701         LL_FMT="%lld"],
1702         [AC_MSG_RESULT(l)
1703         LL_FMT="%ld"],
1704         [AC_MSG_RESULT(assuming target platform uses ll)
1705         LL_FMT="%lld"])
1706 AC_DEFINE_UNQUOTED(LL_FMT,"$LL_FMT",
1707   [Format for a long long printf. ])
1708 AC_SUBST(LL_FMT)
1709
1710 dnl Empty GZIP so that make dist works.
1711 GZIP=
1712
1713 dnl Checks for compilers, typedefs, structures, and compiler characteristics.
1714 dnl Check for large file compilation environment.
1715 need_resetofs=yes
1716 AC_CACHE_CHECK(
1717     [for large file compilation CFLAGS],
1718     amanda_cv_LFS_CFLAGS,
1719     [
1720         amanda_cv_LFS_CFLAGS=
1721         if test "$GETCONF"; then
1722             if $GETCONF ${GETCONF_LFS}_CFLAGS >/dev/null 2>&1; then
1723                 amanda_cv_LFS_CFLAGS=`$GETCONF ${GETCONF_LFS}_CFLAGS 2>/dev/null`
1724                 need_resetofs=no
1725             fi
1726         fi
1727     ]
1728 )
1729 AC_CACHE_CHECK(
1730     [for large file compilation LDFLAGS],
1731     amanda_cv_LFS_LDFLAGS,
1732     [
1733         amanda_cv_LFS_LDFLAGS=
1734         if test "$GETCONF"; then
1735             if $GETCONF ${GETCONF_LFS}_LDFLAGS >/dev/null 2>&1; then
1736                 amanda_cv_LFS_LDFLAGS=`$GETCONF ${GETCONF_LFS}_LDFLAGS 2>/dev/null`
1737                 need_resetofs=no
1738             fi
1739         fi
1740     ]
1741 )
1742 AC_CACHE_CHECK(
1743     [for large file compilation LIBS],
1744     amanda_cv_LFS_LIBS,
1745     [
1746         amanda_cv_LFS_LIBS=
1747         if test "$GETCONF"; then
1748             if $GETCONF ${GETCONF_LFS}_LIBS >/dev/null 2>&1; then
1749                 amanda_cv_LFS_LIBS=`$GETCONF ${GETCONF_LFS}_LIBS 2>/dev/null`
1750                 need_resetofs=no
1751             fi
1752         fi
1753     ]
1754 )
1755 if test "x$need_resetofs" = xyes; then
1756     AC_DEFINE(NEED_RESETOFS,1,[Define if we have to reset tape offsets when reacing 2GB. ])
1757 fi
1758 CFLAGS="$amanda_cv_LFS_CFLAGS $CFLAGS"
1759 CPPFLAGS="$amanda_cv_LFS_CFLAGS $CPPFLAGS"
1760 LDFLAGS="$amanda_cv_LFS_LDFLAGS $LDFLAGS"
1761 LIBS="$amanda_cv_LFS_LIBS $LIBS"
1762
1763 AC_CHECK_SIZEOF(int)
1764 AC_CHECK_SIZEOF(long)
1765 AC_CHECK_SIZEOF(long long)
1766 AC_CHECK_SIZEOF(intmax_t)
1767 AC_CHECK_SIZEOF(off_t)
1768
1769 AM_PROG_LIBTOOL
1770 AC_SUBST(LIBTOOL_DEPS)
1771
1772 AC_PROG_GCC_TRADITIONAL
1773 AC_C_CONST
1774 AMANDA_C_VOLATILE
1775 AMANDA_C_UNSIGNED_LONG_CONSTANTS
1776 AC_TYPE_OFF_T
1777 AC_TYPE_PID_T
1778 AC_TYPE_SIZE_T
1779
1780 AC_TYPE_UID_T
1781 AC_TYPE_SIGNAL
1782 AC_STRUCT_TM
1783 AM_PROG_LEX
1784
1785 dnl AC_CHECK_TYPE does not work for socklen_t because it does not look
1786 dnl in <sys/socket.h>, so this is a variant that adds another header.
1787 AC_DEFUN([AMANDA_CHECK_TYPE],
1788 [AC_REQUIRE([AC_HEADER_STDC])dnl
1789 AC_MSG_CHECKING(for $1)
1790 AC_CACHE_VAL(ac_cv_type_$1,
1791 [AC_EGREP_CPP(dnl
1792 changequote(<<,>>)dnl
1793 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
1794 changequote([,]), [#include <sys/types.h>
1795 #if STDC_HEADERS
1796 #include <stdlib.h>
1797 #include <stddef.h>
1798 #endif
1799 #include <$3>], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
1800 AC_MSG_RESULT($ac_cv_type_$1)
1801 if test "x$ac_cv_type_$1" = xno; then
1802   AC_DEFINE($1, $2, [Define if $1 is not a standard system type])
1803 fi
1804 ])
1805 AMANDA_CHECK_TYPE(socklen_t, int, sys/socket.h)
1806
1807 dnl Checks for header files.
1808 AC_HEADER_STDC
1809 AC_HEADER_DIRENT
1810 CF_WAIT
1811 CF_WAIT_INT
1812 AC_HEADER_TIME
1813 AC_CHECK_HEADERS(\
1814         arpa/inet.h \
1815         camlib.h \
1816         cam/cam.h \
1817         cam/scsi/scsi_message.h \
1818         chio.h \
1819         db.h \
1820         dbm.h \
1821         fcntl.h \
1822         fnmatch.h \
1823         fstab.h \
1824         grp.h \
1825         history.h \
1826         libc.h \
1827         limits.h \
1828         linux/zftape.h \
1829         mntent.h \
1830         mnttab.h \
1831         ndbm.h \
1832         netdb.h \
1833         netinet/in_systm.h \
1834         readline.h \
1835         readline/history.h \
1836         readline/readline.h \
1837         scsi/sg.h \
1838         scsi/scsi_ioctl.h \
1839         stdlib.h \
1840         string.h \
1841         strings.h \
1842         sys/chio.h \
1843         sys/dsreq.h \
1844         sys/fcntl.h \
1845         sys/file.h \
1846         sys/ioctl.h \
1847         sys/ipc.h \
1848         sys/mman.h \
1849         sys/mntent.h \
1850         sys/mtio.h \
1851         sys/param.h \
1852         sys/scarray.h \
1853         sys/gscdds.h \
1854         sys/scsiio.h \
1855         sys/scsi.h \
1856         sys/scsi/impl/uscsi.h \
1857         sys/scsi/scsi/ioctl.h \
1858         sys/select.h \
1859         sys/shm.h \
1860         sys/stat.h \
1861         sys/statfs.h \
1862         sys/statvfs.h \
1863         sys/tape.h \
1864         sys/time.h \
1865         sys/types.h \
1866         sys/uio.h \
1867         sys/vfs.h \
1868         sys/vfstab.h \
1869         syslog.h \
1870         unistd.h \
1871         vtblc.h \
1872 )
1873
1874 AC_CHECK_HEADERS(netinet/ip.h,,,
1875 [[#include <sys/socket.h>
1876 #if HAVE_SYS_TYPES_H
1877 #include <sys/types.h>
1878 #endif
1879 #ifdef HAVE_NETINET_IN_SYSTM_H
1880 #include <netinet/in_systm.h>
1881 #endif
1882 #include <netinet/in.h>
1883 ]])
1884
1885 AC_CHECK_HEADERS(sys/mount.h,,,
1886 [[#ifdef HAVE_SYS_PARAM_H
1887 #include <sys/param.h>
1888 #endif
1889 ]])
1890
1891 NO_SCSI_CHANGER_MODE=true
1892 NO_CHIO_CHANGER_MODE=true
1893
1894 AC_C_BIGENDIAN
1895
1896 dnl
1897 dnl chio support
1898 dnl
1899 if test x"$ac_cv_header_sys_scsi_h" = x"yes"; then
1900     AC_CACHE_CHECK([for HP/UX-like scsi changer support],
1901         amanda_cv_hpux_scsi_chio,
1902         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1903 #include <sys/scsi.h>
1904 ]], [[
1905         static struct element_addresses changer_info;
1906         int i = SIOC_ELEMENT_ADDRESSES;
1907         int j = SIOC_ELEMENT_STATUS;
1908         int k = SIOC_MOVE_MEDIUM;
1909 ]])],[amanda_cv_hpux_scsi_chio=yes],[amanda_cv_hpux_scsi_chio=no])])
1910     if test x"$amanda_cv_hpux_scsi_chio" = x"yes"; then
1911         AC_DEFINE(HAVE_HPUX_SCSI_CHIO,1,[Define to enable HPUX chio based changer support. ])
1912         NO_SCSI_CHANGER_MODE=false
1913     fi
1914 fi
1915
1916 dnl
1917 dnl Linux SCSI based on ioctl
1918 dnl
1919 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
1920    test x"$ac_cv_header_scsi_scsi_ioctl_h" = x"yes"; then 
1921         AC_CACHE_CHECK([for Linux like scsi support (ioctl)],
1922         amanda_cv_linux_scsi,
1923         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1924 #include <scsi/scsi_ioctl.h>
1925 #include <sys/mtio.h>
1926 ]], [[
1927         int device;
1928         char *Command;
1929         ioctl(device, SCSI_IOCTL_SEND_COMMAND, Command);
1930 ]])],[amanda_cv_linux_scsi=yes],[amanda_cv_linux_scsi=no])])
1931 fi
1932
1933 dnl
1934 dnl Linux SCSI based on sg
1935 dnl
1936 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
1937    test x"$ac_cv_header_scsi_sg_h" = x"yes"; then 
1938         AC_CACHE_CHECK([for Linux like scsi support (sg)],
1939         amanda_cv_linux_sg_scsi,
1940         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1941 #include <sys/types.h>
1942 #include <scsi/sg.h>
1943 #include <sys/mtio.h>
1944 ]], [[
1945         int device;
1946         struct sg_header *psg_header;
1947         char *buffer;
1948         write(device, buffer, 1);
1949 ]])],[amanda_cv_linux_sg_scsi=yes],[amanda_cv_linux_sg_scsi=no])])
1950 fi
1951
1952 if test x"$amanda_cv_linux_scsi" = x"yes" ||
1953  test x"$amanda_cv_linux_sg_scsi" = x"yes";then
1954         AC_DEFINE(HAVE_LINUX_LIKE_SCSI,1,[Define to enable Linux tape-changer support.])
1955         NO_SCSI_CHANGER_MODE=false
1956 fi
1957
1958 dnl
1959 dnl HP-UX SCSI
1960 dnl
1961 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
1962    test x"$ac_cv_header_sys_scsi_h" = x"yes"; then 
1963         AC_CACHE_CHECK([for HP-UX like scsi support],
1964         amanda_cv_hpux_scsi,
1965         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1966 #include <stdio.h>
1967 #include <sys/ioctl.h>
1968 #include <sys/scsi.h>
1969 #include <sys/mtio.h>
1970 ]], [[
1971         int device;
1972         char *Command;
1973         ioctl(device, SIOC_IO, Command);
1974 ]])],[amanda_cv_hpux_scsi=yes],[amanda_cv_hpux_scsi=no])])
1975         if test x"$amanda_cv_hpux_scsi" = x"yes";then
1976                 AC_DEFINE(HAVE_HPUX_LIKE_SCSI,1,[Define to enable HPUX tape-changer support. ])
1977                 NO_SCSI_CHANGER_MODE=false
1978                 NO_CHIO_CHANGER_MODE=false
1979         fi
1980 fi
1981
1982 dnl
1983 dnl IRIX SCSI
1984 dnl
1985 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
1986    test x"$ac_cv_header_sys_dsreq_h" = x"yes"; then 
1987         AC_CACHE_CHECK([for Irix like scsi support],
1988         amanda_cv_irix_scsi,
1989         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1990 #include <sys/types.h>
1991 #include <sys/dsreq.h>
1992 #include <sys/mtio.h>
1993 ]], [[
1994         int device=1;
1995         char Command;
1996         ioctl(device, DS_ENTER, &Command);
1997 ]])],[amanda_cv_irix_scsi=yes],[amanda_cv_irix_scsi=no])])
1998         if test x"$amanda_cv_irix_scsi" = x"yes";then
1999                 AC_DEFINE(HAVE_IRIX_LIKE_SCSI,1,[Define to enable IRIX tape-changer support])
2000                 NO_SCSI_CHANGER_MODE=false
2001         fi
2002 fi
2003
2004 dnl
2005 dnl Solaris  SCSI
2006 dnl
2007 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
2008    test x"$ac_cv_header_sys_scsi_impl_uscsi_h" = x"yes"; then 
2009         AC_CACHE_CHECK([for Solaris-like scsi support],
2010         amanda_cv_solaris_scsi,
2011         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2012 #include <sys/types.h>
2013 #include <sys/scsi/impl/uscsi.h>
2014 #include <sys/mtio.h>
2015 ]], [[
2016         int device;
2017         char *Command;
2018         ioctl(device, USCSICMD, Command);
2019 ]])],[amanda_cv_solaris_scsi=yes],[amanda_cv_solaris_scsi=no])])
2020         if test x"$amanda_cv_solaris_scsi" = x"yes";then
2021                 AC_DEFINE(HAVE_SOLARIS_LIKE_SCSI,1,[Define to enable Solaris tape-changer support])
2022                 NO_SCSI_CHANGER_MODE=false
2023         fi
2024 fi
2025
2026 dnl
2027 dnl AIX SCSI
2028 dnl
2029 if test x"$ac_cv_header_sys_tape_h" = x"yes" &&
2030    test x"$ac_cv_header_sys_scarray_h" = x"yes" &&
2031    test x"$ac_cv_header_sys_gscdds_h" = x"yes"; then 
2032         AC_CACHE_CHECK([for AIX like scsi support],
2033         amanda_cv_aix_scsi,
2034         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2035 #include <sys/types.h>
2036 #include <sys/scarray.h>
2037 #include <sys/tape.h>
2038 ]], [[
2039         int device;
2040         char *Command;
2041         ioctl(device, STIOCMD, Command);
2042 ]])],[amanda_cv_aix_scsi=yes],[amanda_cv_aix_scsi=no])])
2043         if test x"$amanda_cv_aix_scsi" = x"yes";then
2044                 AC_DEFINE(HAVE_AIX_LIKE_SCSI,1,[Define to enable AIX tape-changer support])
2045                 NO_SCSI_CHANGER_MODE=false
2046         fi
2047 fi
2048 dnl
2049 dnl BSD CAM SCSI
2050 dnl
2051 if test x"$ac_cv_header_cam_cam_h" = x"yes";then
2052         AC_CACHE_CHECK([for CAM like scsi support],
2053         amanda_cv_cam_scsi,
2054         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2055 #include <stdio.h>
2056 # include <fcntl.h>
2057 # include <cam/cam.h>
2058 # include <cam/cam_ccb.h>
2059 # include <cam/scsi/scsi_message.h>
2060 # include <cam/scsi/scsi_pass.h>
2061 # include <camlib.h>
2062 ]], [[
2063         struct cam_device *curdev;
2064
2065         curdev = cam_open_pass("", O_RDWR, NULL);
2066 ]])],[amanda_cv_cam_scsi=yes],[amanda_cv_cam_scsi=no])])
2067         if test x"$amanda_cv_cam_scsi" = x"yes";then
2068                 AC_DEFINE(HAVE_CAM_LIKE_SCSI,1,[Define to enable CAM tape-changer support])
2069                 NO_SCSI_CHANGER_MODE=false
2070                 AC_CHECK_LIB(cam,main)
2071         fi
2072 fi
2073
2074
2075 dnl
2076 dnl BSD SCSI
2077 dnl
2078 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
2079    test x"$ac_cv_header_sys_scsiio_h" = x"yes"; then
2080     AC_CACHE_CHECK([for BSD like scsi support],
2081     amanda_cv_bsd_scsi,
2082     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2083 #include <sys/types.h>
2084 #include <sys/scsiio.h>
2085 #include <sys/mtio.h>
2086 ]], [[
2087     int device=1;
2088     char Command;
2089     ioctl(device, SCIOCCOMMAND, &Command);
2090 ]])],[amanda_cv_bsd_scsi=yes],[amanda_cv_bsd_scsi=no])])
2091     if test x"$amanda_cv_bsd_scsi" = x"yes";then
2092        AC_DEFINE(HAVE_BSD_LIKE_SCSI,1,[Define to enable BSD tape-changer support])
2093        NO_SCSI_CHANGER_MODE=false
2094     fi
2095 fi
2096
2097 dnl Do not build chg-scsi-chio if we cannot find the needed support
2098 dnl include files for the SCSI interfaces
2099 dnl chio.h and sys/chio.h are chio based systems
2100 if test x"$ac_cv_header_chio_h" = x"yes" ||
2101    test x"$ac_cv_header_sys_chio_h" = x"yes"; then
2102    dnl chg-scsi does not support FreeBSD 3.0's chio.h; it became backward
2103    dnl incompatible with the introduction of camlib.h
2104    if test x"$ac_cv_header_camlib_h" != x"yes"; then
2105      if $NO_SCSI_CHANGER_MODE; then
2106        NO_SCSI_CHANGER_MODE=false
2107      else
2108        NO_CHIO_CHANGER_MODE=false
2109      fi
2110    fi
2111 fi
2112
2113 dnl cur_colr is on some HP's
2114 AC_CHECK_LIB(cur_colr,main)
2115
2116 AC_CHECK_LIB(intl,main)
2117
2118 dnl Make sure we don't use -lnsl and -lsun on Irix systems.
2119 case "$target" in
2120     *sgi-irix*)
2121                         AC_CHECK_LIB(socket,main)
2122                         ;;
2123     *)
2124                         AC_CHECK_LIB(resolv,main)
2125                         AC_CHECK_LIB(nsl,main)
2126                         AC_CHECK_LIB(socket,main)
2127                         AC_CHECK_LIB(sun,main)
2128                         ;;
2129 esac
2130
2131 AC_CHECK_LIB(termcap,tgetent)
2132 if test "x$ac_cv_lib_termcap_tgetent" != xyes; then
2133     AC_CHECK_LIB(curses,tgetent)
2134     if test "x$ac_cv_lib_curses_tgetent" != xyes; then
2135         AC_CHECK_LIB(ncurses,tgetent)
2136     fi
2137 fi
2138 if test "x$ac_cv_lib_termcap_tgetent" = xyes ||
2139    test "x$ac_cv_lib_curses_tgetent" = xyes ||
2140    test "x$ac_cv_lib_ncurses_tgetent" = xyes; then
2141     AC_CHECK_LIB(readline,readline,
2142         READLINE_LIBS="-lreadline"; AC_SUBST(READLINE_LIBS)
2143     )
2144     if test "x$ac_cv_lib_readline_readline" != xyes; then
2145         AC_MSG_WARN([*** No readline library, no history and command line editing in amrecover!])
2146     fi
2147 else
2148     AC_MSG_WARN([*** No terminal library, no history and command line editing in amrecover!])
2149 fi
2150
2151 if test "x$ac_cv_header_linux_zftape_h" = xyes; then
2152     if test "x$ac_cv_header_vtblc_h" = xyes; then
2153         AC_CHECK_LIB(vtblc,main)
2154         if test "x$ac_cv_lib_vtblc_main" != xyes; then
2155             AC_MSG_WARN([*** vtblc library not found - no QIC volume table support!])
2156         fi
2157     else
2158         AC_MSG_WARN([*** vtblc headers not found - no QIC volume table support!])
2159     fi
2160 fi
2161
2162 AC_CHECK_LIB(m,modf)
2163
2164 dnl Check for various "mt status" related structure elements.
2165
2166 AC_MSG_CHECKING(for mt_flags mtget structure element)
2167 mt_flags_result="found"
2168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2169 #include <stdio.h>
2170 #include <sys/types.h>
2171 #include <sys/mtio.h>
2172 ]], [[
2173     struct mtget buf;
2174     long ds;
2175
2176     ds = buf.mt_flags;
2177 ]])],[AC_DEFINE(HAVE_MT_FLAGS,1,Define if the mtget structure has an mt_flags field)],[mt_flags_result="not found"])
2178 AC_MSG_RESULT($mt_flags_result)
2179
2180 AC_MSG_CHECKING(for mt_fileno mtget structure element)
2181 mt_fileno_result="found"
2182 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2183 #include <stdio.h>
2184 #include <sys/types.h>
2185 #include <sys/mtio.h>
2186 ]], [[
2187     struct mtget buf;
2188     long ds;
2189
2190     ds = buf.mt_fileno;
2191 ]])],[AC_DEFINE(HAVE_MT_FILENO,1,Define if the mtget structure has an mt_fileno field)],[mt_fileno_result="not found"])
2192 AC_MSG_RESULT($mt_fileno_result)
2193
2194 AC_MSG_CHECKING(for mt_blkno mtget structure element)
2195 mt_blkno_result="found"
2196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2197 #include <stdio.h>
2198 #include <sys/types.h>
2199 #include <sys/mtio.h>
2200 ]], [[
2201     struct mtget buf;
2202     long ds;
2203
2204     ds = buf.mt_blkno;
2205 ]])],[AC_DEFINE(HAVE_MT_BLKNO,1,Define if the mtget structure has an mt_blkno field)],[mt_blkno_result="not found"])
2206 AC_MSG_RESULT($mt_blkno_result)
2207
2208 AC_MSG_CHECKING(for mt_dsreg mtget structure element)
2209 mt_dsreg_result="found"
2210 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2211 #include <stdio.h>
2212 #include <sys/types.h>
2213 #include <sys/mtio.h>
2214 ]], [[
2215     struct mtget buf;
2216     long ds;
2217
2218     ds = buf.mt_dsreg;
2219 ]])],[AC_DEFINE(HAVE_MT_DSREG,1,Define if the mtget structure has an mt_dsreg field)],[mt_dsreg_result="not found"])
2220 AC_MSG_RESULT($mt_dsreg_result)
2221
2222 AC_MSG_CHECKING(for mt_erreg mtget structure element)
2223 mt_erreg_result="found"
2224 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2225 #include <stdio.h>
2226 #include <sys/types.h>
2227 #include <sys/mtio.h>
2228 ]], [[
2229     struct mtget buf;
2230     long ds;
2231
2232     ds = buf.mt_erreg;
2233 ]])],[AC_DEFINE(HAVE_MT_ERREG,1,Define if the mtget structure has an mt_erreg field)],[mt_erreg_result="not found"])
2234 AC_MSG_RESULT($mt_erreg_result)
2235
2236 dnl
2237
2238 dnl Check if the system does support the user requested database library.
2239 dnl Begin by checking for the header file.  If it is not there, then do
2240 dnl not use the library.  If the header file is there, then try to link
2241 dnl against the library.   If it's not there, then try to link using
2242 dnl just the -lc library.  If the link against -lc fails, then do not
2243 dnl use this library.
2244 DB_HEADER=
2245 DB_LIB=
2246
2247 dnl Testing if libc contains the dbm_open routine is tested for a
2248 dnl lot of times below.  We do it once here now.
2249 save_LIBS="$LIBS"
2250 AC_CHECK_LIB(c,dbm_open)
2251 LIBS="$save_LIBS"
2252
2253 case "$DB_STYLE" in
2254     db)
2255         if test "x$ac_cv_header_db_h" = xyes; then
2256             AC_CHECK_LIB(db,main)
2257             if test "x$ac_cv_lib_db_main" = xyes; then
2258                 AC_CHECK_LIB(db,dbm_open)
2259                 if test "x$ac_cv_lib_db_dbm_open" = xyes; then
2260                     DB_HEADER=db.h
2261                     DB_LIB=db
2262                 else
2263                     DB_STYLE=
2264                     AC_MSG_WARN([*** db database library requested but dbm_open not found in -ldb.])
2265                 fi
2266             else
2267                 if test "x$ac_cv_lib_c_dbm_open" = xyes; then
2268                     DB_HEADER=db.h
2269                     DB_LIB=c
2270                 else
2271                     DB_STYLE=
2272                     AC_MSG_WARN([*** db library requested but -ldb doesn't exist and dbm_open cannot be found.])
2273                 fi
2274             fi
2275         else
2276             DB_STYLE=
2277             AC_MSG_WARN([*** db database library requested but db.h not found.])
2278         fi
2279         ;;
2280
2281     dbm)
2282         if test "x$ac_cv_header_dbm_h" = xyes; then
2283             AC_CHECK_LIB(dbm,main)
2284             if test "x$ac_cv_lib_dbm_main" = xyes; then
2285                 AC_CHECK_LIB(dbm,dbm_open)
2286                 if test "x$ac_cv_lib_dbm_dbm_open" = xyes; then
2287                     DB_HEADER=dbm.h
2288                     DB_LIB=dbm
2289                 else
2290                     DB_STYLE=
2291                     AC_MSG_WARN([*** dbm database library requested but dbm_open not found in -ldbm.])
2292                 fi
2293             else
2294                 if test "x$ac_cv_lib_c_dbm_open" = xyes; then
2295                     DB_HEADER=dbm.h
2296                     DB_LIB=c
2297                 else
2298                     DB_STYLE=
2299                     AC_MSG_WARN([*** dbm library requested but -ldbm doesn't exist and dbm_open cannot be found.])
2300                 fi
2301             fi
2302         else
2303             DB_STYLE=
2304             AC_MSG_WARN([*** dbm database library requested but dbm.h not found.])
2305         fi
2306         ;;
2307
2308     gdbm)
2309         if test "x$ac_cv_header_ndbm_h" = xyes; then
2310             AC_CHECK_LIB(gdbm,main)
2311             if test "x$ac_cv_lib_gdbm_main" = xyes; then
2312                 AC_CHECK_LIB(gdbm,dbm_open)
2313                 if test "x$ac_cv_lib_gdbm_dbm_open" = xyes; then
2314                     DB_HEADER=ndbm.h
2315                     DB_LIB=gdbm
2316                 else
2317                     DB_STYLE=
2318                     AC_MSG_WARN([*** gdbm database library requested but -lgdbm not found.])
2319                 fi
2320             else
2321                 if test "x$ac_cv_lib_c_dbm_open" = xyes; then
2322                     DB_HEADER=ndbm.h
2323                     DB_LIB=c
2324                 else
2325                     DB_STYLE=
2326                     AC_MSG_WARN([*** gdbm library requested but -lgdbm doesn't exist and dbm_open cannot be found.])
2327                 fi
2328             fi
2329         else
2330             DB_STYLE=
2331             AC_MSG_WARN([*** gdbm database library requested but ndbm.h not found.])
2332         fi
2333         ;;
2334
2335     ndbm)
2336         if test "x$ac_cv_header_ndbm_h" = xyes; then
2337             AC_CHECK_LIB(ndbm,main)
2338             if test "x$ac_cv_lib_ndbm_main" = xyes; then
2339                 AC_CHECK_LIB(ndbm,dbm_open)
2340                 if test "x$ac_cv_lib_ndbm_dbm_open" = xyes; then
2341                     DB_HEADER=ndbm.h
2342                     DB_LIB=ndbm
2343                 else
2344                     DB_STYLE=
2345                     AC_MSG_WARN([*** ndbm database library requested but -lndbm not found.])
2346                 fi
2347             else
2348                 if test "x$ac_cv_lib_c_dbm_open" = xyes; then
2349                     DB_HEADER=ndbm.h
2350                     DB_LIB=c
2351                 else
2352                     DB_STYLE=
2353                     AC_MSG_WARN([*** ndbm library requested but -lndbm doesn't exist and dbm_open cannot be found.])
2354                 fi
2355             fi
2356         else
2357             DB_STYLE=
2358             AC_MSG_WARN([*** ndbm database library requested but ndbm.h not found.])
2359         fi
2360         ;;
2361     text)
2362         DB_HEADER=
2363         DB_LIB=
2364         ;;
2365 esac
2366
2367 dnl If a database style was not specified select an appropriate one
2368 dnl automatically.
2369 dnl Nowadays we default to our own internal text database, but I have left
2370 dnl the code that does the testing here just in case it is needed one day.
2371
2372 if test -z "$DB_STYLE"; then
2373     DB_STYLE=text
2374     DB_HEADER=
2375     DB_LIB=
2376 fi
2377
2378 dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_ndbm_h" = xyes; then
2379 dnl     AC_CHECK_LIB(ndbm,dbm_open)
2380 dnl     if test "x$ac_cv_lib_ndbm_dbm_open" = xyes; then
2381 dnl     DB_STYLE=ndbm
2382 dnl     DB_HEADER=ndbm.h
2383 dnl     DB_LIB=ndbm
2384 dnl     elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
2385 dnl     DB_STYLE=ndbm
2386 dnl     DB_HEADER=ndbm.h
2387 dnl     DB_LIB=c
2388 dnl    fi
2389 dnl fi
2390 dnl
2391 dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_db_h" = xyes; then
2392 dnl    AC_CHECK_LIB(db,dbm_open)
2393 dnl    if test "x$ac_cv_lib_db_dbm_open" = xyes; then
2394 dnl     DB_STYLE=db
2395 dnl     DB_HEADER=db.h
2396 dnl     DB_LIB=db
2397 dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
2398 dnl     DB_STYLE=db
2399 dnl     DB_HEADER=db.h
2400 dnl     DB_LIB=c
2401 dnl    fi
2402 dnl fi
2403 dnl
2404 dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_dbm_h" = xyes; then
2405 dnl    AC_CHECK_LIB(dbm,dbm_open)
2406 dnl    if test "x$ac_cv_lib_db_dbm_open" = xyes; then
2407 dnl     DB_STYLE=dbm
2408 dnl     DB_HEADER=dbm.h
2409 dnl     DB_LIB=dbm
2410 dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
2411 dnl     DB_STYLE=dbm
2412 dnl     DB_HEADER=dbm.h
2413 dnl     DB_LIB=c
2414 dnl    fi
2415 dnl fi
2416 dnl
2417 dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_ndbm_h" = xyes; then
2418 dnl    AC_CHECK_LIB(gdbm,dbm_open)
2419 dnl    if test "x$ac_cv_lib_gdbm_dbm_open" = xyes; then
2420 dnl     DB_STYLE=gdbm
2421 dnl     DB_HEADER=ndbm.h
2422 dnl     DB_LIB=gdbm
2423 dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
2424 dnl     DB_STYLE=gdbm
2425 dnl     DB_HEADER=ndbm.h
2426 dnl     DB_LIB=c
2427 dnl    fi
2428 dnl fi
2429 dnl
2430 dnl if test -z "$DB_STYLE"; then
2431 dnl    if test "x$ac_cv_lib_c_dbm_open" = xyes; then
2432 dnl     AC_MSG_WARN([*** A dbm_open() routine was found in -lc, but no header])
2433 dnl     AC_MSG_WARN([*** files exist.  Please remedy the situation.])
2434 dnl    else
2435 dnl     AC_MSG_WARN([*** No dbm_open() routine found!])
2436 dnl    fi
2437 dnl    AC_MSG_WARN([*** You may want to install the gdbm library from])
2438 dnl    AC_MSG_WARN([*** ftp://prep.ai.mit.edu/pub/gnu/gdbm-1.7.3.tar.gz.])
2439 dnl
2440 dnl    AC_MSG_WARN([*** Using the built-in text database.])
2441 dnl    DB_STYLE=text
2442 dnl    DB_HEADER=
2443 dnl    DB_LIB=
2444 dnl fi
2445
2446 if test "x$DB_STYLE" = xtext; then
2447     AC_DEFINE(TEXTDB,1,[Define to enable the text-based database format. ])
2448 else
2449     AC_MSG_CHECKING([for database])
2450     AC_MSG_RESULT([header is $DB_HEADER, linking against -l$DB_LIB])
2451     case "$DB_STYLE" in
2452         db)     AC_DEFINE(USE_DB_H,1,[Define to enable db databases. ])   ;;
2453         dbm)    AC_DEFINE(USE_DBM_H,1,[Define to enable dbm databases. ])  ;;
2454         gdbm)   AC_DEFINE(USE_GDBM_H,1,[Define to enable gdbm databases. ]) ;;
2455         ndbm)   AC_DEFINE(USE_NDBM_H,1,[Define to enable ndbm databases. ]) ;;
2456     esac
2457
2458     AC_CACHE_CHECK(
2459         [for struct datum declared in header files],
2460         amanda_cv_struct_datum,
2461         [
2462             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2463 #if defined(USE_DB_H)
2464 #  include <db.h>
2465 #else
2466 #  if defined(USE_DBM_H)
2467 #    include <dbm.h>
2468 #  else
2469 #    if defined(USE_NDBM_H)
2470 #      include <ndbm.h>
2471 #    endif
2472 #  endif
2473 #endif
2474                 ]], [[
2475                     datum a;
2476                 ]])],[amanda_cv_struct_datum=yes],[amanda_cv_struct_datum=no
2477             ])
2478         ])
2479     if test "x$amanda_cv_struct_datum" = xyes; then
2480         AC_DEFINE(HAVE_STRUCT_DATUM,1,[Define if the database header declares struct datum. ])
2481     fi
2482 fi
2483
2484 case "$DB_STYLE" in
2485     db) DB_EXT=.db;;
2486     gdbm) DB_EXT='""';;
2487     dbm | ndbm) DB_EXT=".dir .pag";;
2488     text) DB_EXT='""';;
2489     *) DB_EXT=;;
2490 esac
2491 AC_SUBST(DB_EXT)
2492
2493 AC_CACHE_CHECK(whether _POSIX2_RE_DUP_MAX is defined,
2494     amanda_cv_have__posix2_re_dup_max,
2495     AC_EGREP_CPP(yes, [
2496 #include <limits.h>
2497 #ifdef _POSIX2_RE_DUP_MAX
2498   yes
2499 #endif
2500 ], amanda_cv_have__posix2_re_dup_max=yes, amanda_cv_have__posix2_re_dup_max=no))
2501 if test "x$amanda_cv_have__posix2_re_dup_max" = xyes; then
2502     AC_DEFINE(HAVE__POSIX2_RE_DUP_MAX,1,[Define if limits.h defines _POSIX2_RE_DUP_MAX. ])
2503 fi
2504
2505 AC_CACHE_CHECK(whether CHAR_MIN is defined,
2506     amanda_cv_have_char_min,
2507     AC_EGREP_CPP(yes, [
2508 #include <limits.h>
2509 #ifdef CHAR_MIN
2510   yes
2511 #endif
2512 ], amanda_cv_have_char_min=yes, amanda_cv_have_char_min=no))
2513 if test "x$amanda_cv_have_char_min" = xyes; then
2514     AC_DEFINE(HAVE_CHAR_MIN,1,[Define if limits.h defines CHAR_MIN. ])
2515 fi
2516
2517 AC_CACHE_CHECK(whether CHAR_MAX is defined,
2518     amanda_cv_have_char_max,
2519     AC_EGREP_CPP(yes, [
2520 #include <limits.h>
2521 #ifdef CHAR_MAX
2522   yes
2523 #endif
2524 ], amanda_cv_have_char_max=yes, amanda_cv_have_char_max=no))
2525 if test "x$amanda_cv_have_char_max" = xyes; then
2526     AC_DEFINE(HAVE_CHAR_MAX,1,[Define if limits.h defines CHAR_MAX. ])
2527 fi
2528
2529 AC_CACHE_CHECK(whether CHAR_BIT is defined,
2530     amanda_cv_have_char_bit,
2531     AC_EGREP_CPP(yes, [
2532 #include <limits.h>
2533 #ifdef CHAR_BIT
2534   yes
2535 #endif
2536 ], amanda_cv_have_char_bit=yes, amanda_cv_have_char_bit=no))
2537 if test "x$amanda_cv_have_char_bit" = xyes; then
2538     AC_DEFINE(HAVE_CHAR_BIT,1,[Define if limits.h defines CHAR_BIT. ])
2539 fi
2540
2541 dnl Checks for library functions and if the function is declared in
2542 dnl an appropriate header file.  Add some of the missing functions
2543 dnl to LIBOBJS.
2544 ICE_CHECK_DECL(accept,sys/types.h sys/socket.h)
2545 AC_FUNC_ALLOCA
2546 AC_CHECK_FUNCS(atexit)
2547 ICE_CHECK_DECL(atof,stdlib.h)
2548 AC_CHECK_FUNCS(basename)
2549 ICE_CHECK_DECL(bind,sys/types.h sys/socket.h)
2550 ICE_CHECK_DECL(bcopy,string.h strings.h stdlib.h)
2551 ICE_CHECK_DECL(bzero,string.h strings.h stdlib.h)
2552 AC_FUNC_CLOSEDIR_VOID
2553 ICE_CHECK_DECL(closelog,syslog.h)
2554 ICE_CHECK_DECL(connect,sys/types.h sys/socket.h)
2555 ICE_CHECK_DECL(dbm_open,${DB_HEADER-no/db/header/file})
2556 AC_CHECK_FUNCS(endmntent)
2557 ICE_CHECK_DECL(fclose,stdio.h)
2558 ICE_CHECK_DECL(fflush,stdio.h)
2559 ICE_CHECK_DECL(flock,sys/file.h)
2560 ICE_CHECK_DECL(fprintf,stdio.h)
2561 ICE_CHECK_DECL(fputc,stdio.h)
2562 ICE_CHECK_DECL(fputs,stdio.h)
2563 ICE_CHECK_DECL(fread,stdio.h stdlib.h)
2564 ICE_CHECK_DECL(fseek,stdio.h)
2565 ICE_CHECK_DECL(fwrite,stdio.h stdlib.h)
2566 AC_REPLACE_FUNCS(getcwd)
2567 AC_CHECK_FUNCS(getfsent)
2568 ICE_CHECK_DECL(gethostname,unistd.h)
2569 AC_FUNC_GETMNTENT
2570 ICE_CHECK_DECL(getopt,stdlib.h unistd.h libc.h)
2571 ICE_CHECK_DECL(getpeername,sys/types.h sys/socket.h)
2572 AC_CHECK_FUNCS(getpgrp)
2573 AC_FUNC_GETPGRP
2574 ICE_CHECK_DECL(getsockname,sys/types.h sys/socket.h)
2575 ICE_CHECK_DECL(getsockopt,sys/types.h sys/socket.h)
2576 ICE_CHECK_DECL(gettimeofday,time.h sys/time.h)
2577 AMANDA_FUNC_GETTIMEOFDAY_ARGS
2578 AC_CHECK_FUNCS(getvfsent initgroups isascii)
2579 ICE_CHECK_DECL(initgroups,grp.h sys/types.h unistd.h libc.h)
2580 ICE_CHECK_DECL(ioctl,sys/ioctl.h unistd.h libc.h)
2581 ICE_CHECK_DECL(listen,sys/types.h sys/socket.h)
2582 ICE_CHECK_DECL(lstat,sys/types.h sys/stat.h)
2583 ICE_CHECK_DECL(malloc,stdlib.h)
2584 AC_REPLACE_FUNCS(memmove)
2585 ICE_CHECK_DECL(memmove,string.h strings.h)
2586 ICE_CHECK_DECL(memset,string.h strings.h)
2587 AC_CHECK_FUNCS(mkdir)
2588 ICE_CHECK_DECL(mkstemp,stdlib.h)
2589 ICE_CHECK_DECL(mktemp,stdlib.h)
2590 AC_REPLACE_FUNCS(mktime)
2591 ICE_CHECK_DECL(mktime,time.h sys/time.h)
2592 AC_FUNC_MMAP
2593 dnl atexit() is prefered, sunos (maybe others?) define on_exit
2594 AC_CHECK_FUNCS(on_exit)
2595 ICE_CHECK_DECL(openlog,syslog.h)
2596 ICE_CHECK_DECL(pclose,stdio.h)
2597 ICE_CHECK_DECL(perror,stdio.h)
2598 ICE_CHECK_DECL(printf,stdio.h)
2599 AC_CHECK_FUNCS(putenv)
2600 ICE_CHECK_DECL(puts,stdio.h)
2601 ICE_CHECK_DECL(realloc,stdlib.h)
2602 ICE_CHECK_DECL(recvfrom,sys/types.h sys/socket.h)
2603 ICE_CHECK_DECL(remove,stdio.h)
2604 ICE_CHECK_DECL(rename,stdio.h)
2605 ICE_CHECK_DECL(rewind,stdio.h)
2606 AC_CHECK_FUNCS(rmdir)
2607 ICE_CHECK_DECL(ruserok,netdb.h sys/socket.h libc.h unistd.h)
2608 ICE_CHECK_DECL(select,sys/types.h sys/socket.h sys/select.h time.h sys/time.h)
2609 AMANDA_FUNC_SELECT_ARG_TYPE
2610 ICE_CHECK_DECL(sendto,sys/types.h sys/socket.h)
2611 ICE_CHECK_DECL(setegid,unistd.h)
2612 ICE_CHECK_DECL(seteuid,unistd.h)
2613 AC_CHECK_FUNCS(setmntent)
2614 AC_CHECK_FUNCS(shquote)
2615
2616 ICE_CHECK_DECL(setresgid,unistd.h)
2617 ICE_CHECK_DECL(setresuid,unistd.h)
2618
2619 dnl arguments for setpgrp or not
2620 AC_CHECK_FUNC(setpgid, [
2621         AC_DEFINE(HAVE_SETPGID,1,[Define if setpgid() is available. ])
2622         ICE_CHECK_DECL(setpgid,sys/types.h unistd.h)
2623 ])
2624 AC_CHECK_FUNC(setpgrp,[AC_FUNC_SETPGRP])
2625 ICE_CHECK_DECL(setpgrp,sys/types.h unistd.h libc.h)
2626
2627 ICE_CHECK_DECL(setsockopt,sys/types.h sys/socket.h)
2628
2629 AC_CHECK_FUNCS(shmget,
2630     [
2631         AMANDA_FUNC_SHM_ARG_TYPE
2632         case "$FORCE_MMAP" in
2633         n | no)
2634             AC_DEFINE(HAVE_SYSVSHM,1,[Define if SysV shared-memory functions are available. ])
2635           ;;
2636         esac
2637     ]
2638 )
2639 ICE_CHECK_DECL(shmat,sys/types.h sys/ipc.h sys/shm.h)
2640 ICE_CHECK_DECL(shmctl,sys/types.h sys/ipc.h sys/shm.h)
2641 ICE_CHECK_DECL(shmdt,sys/types.h sys/ipc.h sys/shm.h)
2642 ICE_CHECK_DECL(shmget,sys/types.h sys/ipc.h sys/shm.h)
2643
2644 if test "x$ac_cv_func_mmap_fixed_mapped" != xyes; then
2645     case "$FORCE_MMAP" in
2646     n | no)
2647         if test "x$ac_cv_func_shmget" != xyes; then
2648             AC_MSG_WARN([*** Neither shmget() nor mmap() found!])
2649             AC_MSG_WARN([*** This system will not support the Amanda server.])
2650             NO_SERVER_MODE=true
2651         fi
2652       ;;
2653     y | ye | yes)
2654         AC_MSG_WARN([*** --with-mmap used on a system with no mmap() support!])
2655         AC_MSG_WARN([*** This system will not support the Amanda server.])
2656         NO_SERVER_MODE=true
2657       ;;
2658     esac
2659 fi
2660
2661 dnl Some systems have snprintf but not vsnprintf.  If either snprintf or
2662 dnl vsnprintf are missing, then use the snprintf.c we provide.
2663 ICE_CHECK_DECL(snprintf,stdio.h)
2664 ICE_CHECK_DECL(vsnprintf,stdio.h)
2665 if test x"$ice_have_snprintf" != x"yes" ||
2666    test x"$ice_have_vsnprintf" != x"yes"; then
2667     AC_LIBOBJ([snprintf])
2668     if false; then :
2669         dnl so that automake includes snprintf.c in the distribution
2670         AC_REPLACE_FUNCS(snprintf) 
2671     fi
2672 fi
2673
2674 AC_CHECK_FUNCS(sigaction sigemptyset sigvec)
2675 ICE_CHECK_DECL(socket,sys/types.h sys/socket.h)
2676 ICE_CHECK_DECL(socketpair,sys/types.h sys/socket.h)
2677 ICE_CHECK_DECL(sscanf,stdio.h)
2678 AC_CHECK_FUNCS(statfs statvfs)
2679 AC_REPLACE_FUNCS(strerror)
2680 ICE_CHECK_DECL(strerror,string.h strings.h)
2681 AC_FUNC_STRFTIME
2682 AC_REPLACE_FUNCS(strftime)
2683 ICE_CHECK_DECL(strftime,time.h sys/time.h)
2684 AC_REPLACE_FUNCS(strncasecmp)
2685 ICE_CHECK_DECL(strncasecmp,string.h strings.h)
2686 AC_REPLACE_FUNCS(strstr)
2687 ICE_CHECK_DECL(syslog,syslog.h)
2688 ICE_CHECK_DECL(system,stdlib.h)
2689 ICE_CHECK_DECL(time,time.h sys/time.h)
2690 ICE_CHECK_DECL(tolower,ctype.h)
2691 ICE_CHECK_DECL(toupper,ctype.h)
2692 ICE_CHECK_DECL(ungetc,stdio.h)
2693 AC_FUNC_VPRINTF
2694 ICE_CHECK_DECL(vfprintf,stdio.h stdlib.h)
2695 ICE_CHECK_DECL(vprintf,stdio.h stdlib.h)
2696 ICE_CHECK_DECL(vsprintf,stdio.h stdlib.h)
2697 AC_CHECK_FUNC(wait4)
2698 AC_REPLACE_FUNCS(waitpid)
2699 AC_REPLACE_FUNCS(writev)
2700 ICE_CHECK_DECL(writev, unistd.h sys/uio.h)
2701 AC_REPLACE_FUNCS(strcasecmp)
2702 ICE_CHECK_DECL(strcasecmp,string.h strings.h)
2703
2704 AC_CHECK_FUNCS(fnmatch)
2705
2706 AC_SYS_LARGEFILE
2707
2708 dnl disk device prefixes
2709 AC_MSG_CHECKING(disk device prefixes)
2710 dnl Use df to find the mount point for the root filesystem.  Use
2711 dnl the positional parameters to find the particular line from df
2712 dnl that contains the root paritition.  We put it in a subshell so
2713 dnl that the original positional parameters are not messed with.
2714 dfline=`(
2715     df / | while read line; do
2716         set -- $line
2717         while test $# -gt 0; do
2718             if test "x$1" = "x/"; then
2719                 echo $line
2720                 break 2
2721             fi
2722             shift
2723         done
2724     done
2725 ) | sed 's/(//' | sed 's/)//' `
2726
2727 dnl Search for the mount point by using expr to find the parameter
2728 dnl with dev in it.
2729 mount=`(
2730     set -- $dfline
2731     while test $# -gt 0; do
2732         if expr "$1" : '.*dev' >/dev/null 2>&1; then
2733             echo $1
2734             break
2735         fi
2736         shift
2737     done
2738 )`
2739
2740 if test "$DEV_PREFIX" && test "$RDEV_PREFIX"; then
2741     AC_MSG_RESULT((predefined) $DEV_PREFIX - $RDEV_PREFIX)
2742 else
2743     if test -d /dev/dsk; then
2744         DEV_PREFIX=/dev/dsk/
2745         if test -d /dev/rdsk; then
2746             RDEV_PREFIX=/dev/rdsk/
2747         else
2748             RDEV_PREFIX=/dev/dsk/
2749         fi
2750     elif test -d /dev; then
2751         case "$target" in
2752             *-sni-sysv4)
2753                 dev_prefix=/dev/dsk/
2754                 rdev_prefix=/dev/rdsk/
2755                 AC_MSG_WARN("*** Run amsinixfixdevs on Sinix systems using VxFS.")
2756                 ;;
2757
2758             *)
2759                 DEV_PREFIX=/dev/
2760                 # Some systems, notably Linux, do not have raw disk devices
2761                 # names.  Check this by trying to see if a raw disk device name
2762                 # exists using the normal raw device path prepended to the
2763                 # mount point of the root filesystem.
2764                 if test "$mount"; then
2765                     dev_name="/dev/r`basename $mount`"
2766                     if test -b $dev_name -o -c $dev_name; then
2767                         RDEV_PREFIX=/dev/r
2768                     else
2769                         RDEV_PREFIX=/dev/
2770                     fi
2771                 else
2772                     RDEV_PREFIX=/dev/r
2773                 fi
2774                 ;;
2775         esac
2776     else
2777         DEV_PREFIX=/
2778         RDEV_PREFIX=/
2779     fi
2780     AC_MSG_RESULT($DEV_PREFIX - $RDEV_PREFIX)
2781 fi
2782
2783 AC_DEFINE_UNQUOTED(DEV_PREFIX,"${DEV_PREFIX}",[Define as the prefix for disk devices, commonly /dev/ or /dev/dsk/ ])
2784 AC_DEFINE_UNQUOTED(RDEV_PREFIX,"${RDEV_PREFIX}",[Define as the prefix for raw disk devices, commonly /dev/r or /dev/rdsk/ ])
2785
2786 case $mount in
2787     /dev/vg*)
2788         AC_MSG_WARN("*** Run amhpfixdevs on HP-UX systems using /dev/vg??.")
2789         ;;
2790 esac
2791
2792 dnl lock/flock/fcntl
2793 AC_CACHE_CHECK(
2794    [whether posix fcntl locking works],
2795    amanda_cv_posix_filelocking,
2796    [
2797         AC_RUN_IFELSE([AC_LANG_SOURCE([[
2798 #undef  ASSERTIONS
2799 #define CONFIGURE_TEST
2800 #define USE_POSIX_FCNTL
2801 #include "${srcdir-.}/common-src/amflock.c"
2802 ]])],[
2803         amanda_cv_posix_filelocking=yes
2804 ],[
2805         amanda_cv_posix_filelocking="no"
2806 ],[
2807         amanda_cv_posix_filelocking="no (cannot run test)"
2808 ])
2809     rm -f /tmp/conftest.lock
2810 ])
2811 if test "x$amanda_cv_posix_filelocking" = xyes; then
2812     AC_DEFINE(USE_POSIX_FCNTL,1,[Define to use Posix fcntl for file locking.])
2813     HAS_WORKING_FILE_LOCK=1
2814 fi
2815
2816 if test -z "$HAS_WORKING_FILE_LOCK"; then
2817     AC_CACHE_CHECK(
2818         [whether flock locking works],
2819         amanda_cv_flock_filelocking,
2820         [
2821             AC_RUN_IFELSE([AC_LANG_SOURCE([[
2822 #undef  ASSERTIONS
2823 #define CONFIGURE_TEST
2824 #define USE_FLOCK
2825 #include "${srcdir-.}/common-src/amflock.c"
2826 ]])],[
2827                     amanda_cv_flock_filelocking="yes"
2828 ],[
2829                     amanda_cv_flock_filelocking="no"
2830 ],[
2831                     amanda_cv_flock_filelocking="no (cannot run test)"
2832 ])
2833         rm -f /tmp/conftest.lock
2834 ])
2835     if test "x$amanda_cv_flock_filelocking" = xyes; then
2836         AC_DEFINE(USE_FLOCK,1,[Define to use flock for file locking.])
2837         HAS_WORKING_FILE_LOCK=1
2838     fi
2839 fi
2840
2841 if test -z "$HAS_WORKING_FILE_LOCK"; then
2842     AC_CACHE_CHECK(
2843         [whether lockf locking works],
2844         amanda_cv_lockf_filelocking,
2845         [
2846             AC_RUN_IFELSE([AC_LANG_SOURCE([[
2847 #undef  ASSERTIONS
2848 #define CONFIGURE_TEST
2849 #define USE_LOCKF
2850 #include "${srcdir-.}/common-src/amflock.c"
2851 ]])],[
2852                     amanda_cv_lockf_filelocking="yes"
2853 ],[
2854                     amanda_cv_lockf_filelocking="no"
2855 ],[
2856                     amanda_cv_lockf_filelocking="no (cannot run test)"
2857 ])
2858         rm -f /tmp/conftest.lock
2859 ])
2860     if test "x$amanda_cv_lockf_filelocking" = xyes; then
2861         AC_DEFINE(USE_LOCKF,1,[Define to use lockf for file locking.])
2862         HAS_WORKING_FILE_LOCK=1
2863     fi
2864 fi
2865
2866 if test -z "$HAS_WORKING_FILE_LOCK"; then
2867     AC_CACHE_CHECK(
2868         [whether lnlock locking works],
2869         amanda_cv_lnlock_filelocking,
2870         [
2871             AC_RUN_IFELSE([AC_LANG_SOURCE([[
2872 #undef  ASSERTIONS
2873 #define CONFIGURE_TEST
2874 #define USE_LNLOCK
2875 #include "${srcdir-.}/common-src/amflock.c"
2876 #include "${srcdir-.}/common-src/alloc.c"
2877 #include "${srcdir-.}/common-src/error.c"
2878 #include "${srcdir-.}/common-src/snprintf.c"
2879 ]])],[
2880                     amanda_cv_lnlock_filelocking="yes"
2881 ],[
2882                     amanda_cv_lnlock_filelocking="no"
2883 ],[
2884                     amanda_cv_lnlock_filelocking="no (cannot run test)"
2885 ])
2886         rm -f /tmp/conftest.lock
2887 ])
2888     if test "x$amanda_cv_lnlock_filelocking" = xyes; then
2889         AC_DEFINE(USE_LNLOCK,1,[Define to use a hard-link based approach for file locking.])
2890         HAS_WORKING_FILE_LOCK=1
2891     fi
2892 fi
2893
2894 if test -z "$HAS_WORKING_FILE_LOCK"; then
2895     AC_MSG_WARN([*** No working file locking capability found!])
2896     AC_MSG_WARN([*** Be VERY VERY careful.])
2897 fi
2898
2899 dnl extra substitution parameters
2900 AC_SUBST(CHS)
2901 AC_SUBST(MTX)
2902 AC_SUBST(MCUTIL)
2903 AC_SUBST(ac_n)
2904 AC_SUBST(ac_c)
2905
2906 AM_CONDITIONAL(WANT_CLIENT, test x"$NO_CLIENT_MODE" != x"true")
2907 AM_CONDITIONAL(WANT_SAMBA, test ! -z "$SAMBA_CLIENT")
2908 AM_CONDITIONAL(WANT_RESTORE, test x"$NO_RESTORE_MODE" != x"true")
2909 AM_CONDITIONAL(WANT_SERVER, test x"$NO_SERVER_MODE" != x"true")
2910 AM_CONDITIONAL(WANT_RECOVER, test x"$NO_RECOVER_MODE" != x"true" && test x"$NO_CLIENT_MODE" != x"true")
2911 AM_CONDITIONAL(WANT_TAPE, test x"$NO_SERVER_MODE" != x"true" || test x"$NO_RESTORE_MODE" != x"true")
2912 AM_CONDITIONAL(WANT_AMPLOT, test x"$NO_AMPLOT_MODE" != x"true")
2913 AM_CONDITIONAL(WANT_CHG_SCSI, test x"$NO_SCSI_CHANGER_MODE" != x"true")
2914 AM_CONDITIONAL(WANT_CHIO_SCSI, test x"$NO_CHIO_CHANGER_MODE" != x"true")
2915 AM_CONDITIONAL(WANT_RUNTIME_PSEUDO_RELOC, test x"$NEED_RUNTIME_PSEUDO_RELOC" = x"true")
2916 AM_CONDITIONAL(WANT_SETUID_CLIENT, test x"$NEED_SETUID_CLIENT" != x"false")
2917 AM_CONDITIONAL(WANT_SSH_SECURITY, test x"$SSH_SECURITY_SET" = x"true")
2918
2919 case "${FORCE_USE_RUNDUMP-${USE_RUNDUMP}}" in
2920 y |  ye | yes) AC_DEFINE(USE_RUNDUMP,1,[Define to invoke rundump (setuid-root) instead of DUMP program directly. ]);;
2921 esac
2922
2923 # This is necessary so that .o files in LIBOBJS are also built via
2924 # the ANSI2KNR-filtering rules.
2925 LIB@&t@OBJS=`echo "$LIB@&t@OBJS" |
2926              sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
2927 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
2928            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
2929 AC_SUBST(LTLIBOBJS)
2930
2931 LTALLOCA=`echo "$ALLOCA" | sed 's/\.'"${ac_objext}"'/\.lo/g'`
2932 AC_SUBST(LTALLOCA)
2933
2934 ## This stuff is needed for the documentation.
2935 DOC_BUILD_DATE=`date '+%d-%m-%Y'`
2936 AC_SUBST(DOC_BUILD_DATE)
2937
2938 AC_ARG_WITH(xsltproc,
2939     [  --without-built-manpages Do not build manpages from XML source.],
2940     [ case "$withval" in
2941         y | ye | yes)
2942           USE_XSLTPROC=yes;;
2943         n | no)
2944           USE_XSLTPROC=no;;
2945         *)
2946           USE_XSLTPROC=yes;
2947           XSLTPROC="$withval";;
2948       esac
2949     ],
2950     [ USE_XSLTPROC=maybe; ])
2951
2952 AC_DEFUN([AC_PATH_XSLTPROC], [AC_PATH_PROG(XSLTPROC, xsltproc)])
2953
2954 # This looks bad, but && and || have equal precedence in shells, so
2955 # actually it's all OK.
2956 if test "$USE_XSLTPROC" = "yes" || test "$USE_XSLTPROC" = "maybe" && \
2957    test -z "$XSLTPROC"; then
2958     AC_PATH_XSLTPROC
2959     if test -n "$XSLTPROC"; then
2960         USE_XSLTPROC=yes;
2961     else
2962         if test "$USE_XSLTPROC" = yes; then
2963            AC_MSG_ERROR([can't find xsltproc, but running with --with-xsltproc.])
2964         else
2965            USE_XSLTPROC=no;
2966         fi
2967     fi
2968 fi
2969
2970 AM_CONDITIONAL(HAVE_XSLTPROC, test "$USE_XSLTPROC" = yes)
2971
2972 AC_CONFIG_FILES([\
2973         amplot/amcat.awk                amplot/amplot.sh                \
2974         amplot/Makefile                                                 \
2975                                                                         \
2976         changer-src/chg-manual.sh       changer-src/chg-multi.sh        \
2977         changer-src/chg-mtx.sh          changer-src/chg-chs.sh          \
2978         changer-src/chg-rth.pl          changer-src/chg-chio.pl         \
2979         changer-src/chg-zd-mtx.sh       changer-src/Makefile            \
2980         changer-src/chg-juke.sh         changer-src/chg-rait.sh         \
2981         changer-src/chg-null.sh         changer-src/chg-mcutil.sh       \
2982         changer-src/chg-disk.sh         changer-src/chg-iomega.pl       \
2983                                                                         \
2984         client-src/patch-system.sh      client-src/Makefile             \
2985                                                                         \
2986         dumper-src/gnutar.pl            dumper-src/generic-dumper.pl    \
2987         dumper-src/Makefile                                             \
2988                                                                         \
2989         common-src/versuff.c            common-src/Makefile             \
2990                                                                         \
2991         example/amanda.conf             example/Makefile                \
2992         example/chg-mcutil.conf                                         \
2993                                                                         \
2994         man/Makefile                                                    \
2995                                                                         \
2996         docs/Makefile                                                   \
2997                                                                         \
2998         recover-src/Makefile                                            \
2999                                                                         \
3000         restore-src/Makefile                                            \
3001                                                                         \
3002         server-src/amcheckdb.sh         server-src/amcleanup.sh         \
3003         server-src/amdump.sh            server-src/amfreetapes.sh       \
3004         server-src/amoverview.pl        server-src/amrmtape.sh          \
3005         server-src/amtoc.pl             server-src/amverify.sh          \
3006         server-src/Makefile             server-src/amstatus.pl          \
3007         server-src/amverifyrun.sh       server-src/amcrypt.sh           \
3008         server-src/amaespipe.sh                                         \
3009                                                                         \
3010         tape-src/Makefile                                               \
3011                                                                         \
3012         config/Makefile                 Makefile])
3013 AC_OUTPUT