Imported Upstream version 3.3.0
[debian/amanda] / config / amanda / dumpers.m4
1 # OVERVIEW
2 #
3
4 # SYNOPSIS
5 #
6 #   AMANDA_PROG_GNUTAR
7 #
8 # OVERVIEW
9 #
10 #   Search for a GNU 'tar' binary, placing the result in the precious 
11 #   variable GNUTAR.  The discovered binary is tested to ensure it's really
12 #   GNU tar.
13 #
14 #   Also handle --with-gnutar
15 #
16 AC_DEFUN([AMANDA_PROG_GNUTAR],
17 [
18     AC_REQUIRE([AMANDA_INIT_PROGS])
19
20     # call with
21     AC_ARG_WITH(gnutar,
22         AS_HELP_STRING([--with-gnutar=PROG],
23                        [use PROG as GNU 'tar']),
24         [
25             # check withval
26             case "$withval" in
27                 /*) GNUTAR="$withval";;
28                 y|ye|yes) :;;
29                 n|no) GNUTAR=no ;;
30                 *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-gnutar]);;
31             esac
32             # done
33         ]
34     )
35
36     if test "x$GNUTAR" = "xno"; then
37         GNUTAR=
38     else
39         OLD_GNUTAR=$GNUTAR
40         for gnutar_name in gtar gnutar tar; do
41             AC_PATH_PROGS(GNUTAR, $gnutar_name, , $LOCSYSPATH)
42             if test -n "$GNUTAR"; then
43               case `"$GNUTAR" --version 2>&1` in
44                *GNU*tar* | *Free*paxutils* )
45                             # OK, it is GNU tar
46                             break
47                             ;;
48                *)
49                             if test -n "$OLD_GNUTAR"; then
50                                     AMANDA_MSG_WARN([$GNUTAR is not GNU tar, it will be used.])
51                             else 
52                                     # warning..
53                                     AMANDA_MSG_WARN([$GNUTAR is not GNU tar, so it will not be used.])
54                                     # reset the cache for GNUTAR so AC_PATH_PROGS will search again
55                                     GNUTAR=''
56                                     unset ac_cv_path_GNUTAR
57                             fi
58                             ;;
59               esac
60             fi
61         done
62     fi
63
64     if test "x$GNUTAR" != "x"; then
65         # define unquoted
66         AC_DEFINE_UNQUOTED(GNUTAR, "$GNUTAR", [Location of the GNU 'tar' binary])
67     fi
68     AC_ARG_VAR(GNUTAR, [Location of the GNU 'tar' binary])
69     AC_SUBST(GNUTAR)
70 ])
71
72 # SYNOPSIS
73 #
74 #   AMANDA_PROG_STAR
75 #
76 # OVERVIEW
77 #
78 #   Search for a 'star' binary, placing the result in the precious 
79 #   variable STAR.  The discovered binary is tested to ensure it's really
80 #   star.
81 #
82 #   Also handle --with-star
83 #
84 AC_DEFUN([AMANDA_PROG_STAR],
85 [
86     AC_REQUIRE([AMANDA_INIT_PROGS])
87
88     # call with
89     AC_ARG_WITH(star,
90         AS_HELP_STRING([--with-star=PROG],
91                        [use PROG as 'star']),
92         [
93             # check withval
94             case "$withval" in
95                 /*) STAR="$withval";;
96                 y|ye|yes) :;;
97                 n|no) STAR=no ;;
98                 *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-star]);;
99             esac
100             # done
101         ]
102     )
103
104     if test "x$STAR" = "xno"; then
105         STAR=
106     else
107         OLD_STAR=$STAR
108         AC_PATH_PROGS(STAR, star, , $LOCSYSPATH)
109         if test -n "$STAR"; then
110             case `"$STAR" --version 2>/dev/null` in
111              *star*)
112                     # OK, it is star
113                     break
114                     ;;
115              *)
116                     if test -n "$OLD_STAR"; then
117                         AMANDA_MSG_WARN([$STAR is not star, it will be used.])
118                     else
119                         # warning..
120                         AMANDA_MSG_WARN([$STAR is not star, so it will not be used.])
121                         # reset the cache for STAR so AC_PATH_PROGS will search again
122                         STAR=''
123                         unset ac_cv_path_STAR
124                     fi
125                     ;;
126             esac
127         fi
128     fi
129
130     if test "x$STAR" != "x"; then
131         # define unquoted
132         AC_DEFINE_UNQUOTED(STAR, "$STAR", [Location of the 'star' binary])
133     fi
134     AC_ARG_VAR(STAR, [Location of the 'star' binary])
135     AC_SUBST(STAR)
136 ])
137
138 # SYNOPSIS
139 #
140 #   AMANDA_PROG_SUNTAR
141 #
142 # OVERVIEW
143 #
144 #   Use the value given with the option --with-suntar= or the value of the 
145 #   precious variable SUNTAR to define the location of Sun's version of tar.
146 #   Otherwise set the value to /usr/sbin/tar.  Value is not checked.
147 #
148 #   Also handle --with-suntar
149 #
150 AC_DEFUN([AMANDA_PROG_SUNTAR],
151 [
152     AC_REQUIRE([AMANDA_INIT_PROGS])
153
154     # call with
155     AC_ARG_WITH(suntar,
156         AS_HELP_STRING([--with-suntar=PROG],
157                        [use PROG as 'suntar']),
158         [
159             # check withval
160             case "$withval" in
161                 /*) SUNTAR="$withval";;
162                 y|ye|yes) :;;
163                 n|no) SUNTAR=no ;;
164                 *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-suntar]);;
165             esac
166             # done
167         ],
168         [
169             if test "x$SUNTAR" == "x"; then
170                 SUNTAR="/usr/sbin/tar"
171             fi
172         ]
173     )
174
175     if test "x$SUNTAR" = "xno"; then
176         SUNTAR=
177     fi
178
179     if test "x$SUNTAR" != "x"; then
180         # define unquoted
181         AC_DEFINE_UNQUOTED(SUNTAR, "$SUNTAR", [Location of the 'suntar' binary])
182     fi
183     AC_ARG_VAR(SUNTAR, [Location of the 'suntar' binary])
184     AC_SUBST(SUNTAR)
185 ])
186
187 # SYNOPSIS
188 #
189 #   AMANDA_PROG_SAMBA_CLIENT
190 #
191 # OVERVIEW
192 #
193 #   Search for a samba client (smbclient) binary, placing the result in
194 #   the variable SAMBA_CLIENT.  The discovered binary is tested to determine an
195 #   internally significant version number, stored in SAMBA_VERSION.  The version
196 #   serves only to differentiate versions of Samba which Amanada must treat 
197 #   differently, and has no relation to the actual Samba version number.
198 #
199 #   Automake conditional 'WANT_SAMBA' is set if a samba client is discovered.
200 #
201 #   Also handles --with-smbclient and (deprecated) --with-samba-user
202 #
203 AC_DEFUN([AMANDA_PROG_SAMBA_CLIENT],
204 [
205     AC_REQUIRE([AMANDA_INIT_PROGS])
206
207     AC_ARG_WITH(smbclient,
208         AS_HELP_STRING([--with-smbclient=PROG],
209                        [use PROG as 'smbclient']),
210         [
211             case "$withval" in
212                 /*) SAMBA_CLIENT="$withval";;
213                 y|ye|yes) :;;
214                 n|no) SAMBA_CLIENT=no ;;
215                 *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-smbclient]);;
216             esac
217         ]
218     )
219
220     AC_ARG_WITH(samba-user,
221         AS_HELP_STRING([--with-samba-user],
222                        [deprecated; place username in 'amandapass']),
223        [ AC_MSG_ERROR([--with-samba-user is no longer supported; place username in 'amandapass']) ]
224     )
225
226     if test "x$SAMBA_CLIENT" != "xno"; then
227       AC_PATH_PROG(SAMBA_CLIENT,smbclient,,$LOCSYSPATH)
228       smbversion=0
229       if test ! -z "$SAMBA_CLIENT"; then
230         case `"$SAMBA_CLIENT" '\\\\nosuchhost.amanda.org\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1` in
231         *"Unknown host"*)
232                       smbversion=1
233                       ;;
234         *"Connection to nosuchhost.amanda.org failed"*)
235                       smbversion=2
236                       ;;
237         *)
238                       AMANDA_MSG_WARN([$SAMBA_CLIENT does not seem to be smbclient, so it will not be used.])
239                       SAMBA_CLIENT=
240                       ;;
241         esac
242         if test -n "$SAMBA_CLIENT"; then
243           AC_DEFINE_UNQUOTED(SAMBA_CLIENT,"$SAMBA_CLIENT",
244                   [Define the location of smbclient for backing up Samba PC clients. ])
245           AC_DEFINE_UNQUOTED(SAMBA_VERSION, $smbversion,
246                   [Not the actual samba version, just a number that should be increased whenever we start to rely on a new samba feature. ])
247         fi
248       fi
249     fi
250
251     AM_CONDITIONAL(WANT_SAMBA, test -n "$SAMBA_CLIENT")
252 ])
253
254 # SYNOPSIS
255 #
256 #   AMANDA_PROG_VDUMP_VRESTORE
257 #
258 # DESCRIPTION
259 #
260 #   Search for 'vdump' and 'vrestore', setting and AC_DEFINE-ing VDUMP and 
261 #   VRESTORE if they are found.
262 #
263 AC_DEFUN([AMANDA_PROG_VDUMP_VRESTORE],
264 [
265     AC_REQUIRE([AMANDA_INIT_PROGS])
266
267     AC_PATH_PROG(VDUMP,vdump,,$SYSLOCPATH)
268     AC_PATH_PROG(VRESTORE,vrestore,,$SYSLOCPATH)
269     if test "$VDUMP" -a "$VRESTORE"; then
270         AC_DEFINE_UNQUOTED(VDUMP,"$VDUMP",[Define the location of the vdump program. ])
271         AC_DEFINE_UNQUOTED(VRESTORE,"$VRESTORE",[Define the location of the vrestore program. ])
272     fi
273 ])
274
275 # SYNOPSIS
276 #
277 #   AMANDA_PROG_VXDUMP_VXRESTORE
278 #
279 # DESCRIPTION
280 #
281 #   Search for 'vxdump' and 'vxrestore', setting and AC_DEFINE-ing VXDUMP
282 #   and VXRESTORE if they are found.
283 #
284 #   In addition to the standard paths, this macro will search in
285 #   /usr/lib/fs/vxfs.
286 #
287 AC_DEFUN([AMANDA_PROG_VXDUMP_VXRESTORE],
288 [
289     AC_REQUIRE([AMANDA_INIT_PROGS])
290
291     AC_PATH_PROG(VXDUMP,vxdump,,$SYSLOCPATH:/usr/lib/fs/vxfs)
292     AC_PATH_PROG(VXRESTORE,vxrestore,,$SYSLOCPATH:/usr/lib/fs/vxfs)
293     if test "$VXDUMP" -a "$VXRESTORE"; then
294         AC_DEFINE_UNQUOTED(VXDUMP,"$VXDUMP",
295 [Define the location of the vxdump program on HPUX and SINIX hosts or on
296  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
297         AC_DEFINE_UNQUOTED(VXRESTORE,"$VXRESTORE",
298 [Define the location of the vxrestore program on HPUX and SINIX hosts or on
299  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
300     fi
301 ])
302
303 # SYNOPSIS
304 #
305 #   AMANDA_PROG_XFSDUMP_XFSRESTORE
306 #
307 # DESCRIPTION
308 #
309 #   Search for 'xfsdump' and 'xfsrestore', setting and AC_DEFINE-ing XFSDUMP
310 #   and XFSRESTORE if they are found.
311 #
312 AC_DEFUN([AMANDA_PROG_XFSDUMP_XFSRESTORE],
313 [
314     AC_REQUIRE([AMANDA_INIT_PROGS])
315
316     AC_PATH_PROGS(XFSDUMP,xfsdump,,$SYSLOCPATH)
317     AC_PATH_PROGS(XFSRESTORE,xfsrestore,,$SYSLOCPATH)
318     if test "$XFSDUMP" -a "$XFSRESTORE"; then
319         AC_DEFINE_UNQUOTED(XFSDUMP,"$XFSDUMP",
320                 [Define the location of the xfsdump program on Irix hosts. ])
321         AC_DEFINE_UNQUOTED(XFSRESTORE,"$XFSRESTORE",
322                 [Define the location of the xfsrestore program on Irix hosts. ])
323         AMANDA_MSG_WARN([[xfsdump causes the setuid-root rundump program to be enabled.  To disable it, just #undef XFSDUMP in config/config.h]])
324     fi
325 ])
326
327 # SYNOPSIS
328 #
329 #   AMANDA_PROG_DUMP_RESTORE
330 #
331 # DESCRIPTION
332 #
333 #   Search for compatible dump and restore binaries.  The exact name of
334 #   the binaries we search for depends on the target system.  If working
335 #   binaries are found, DUMP and RESTORE are defined to their full paths.
336 #
337 #   DUMP_RETURNS_1 is defined and substituted if the system's 'dump'
338 #   returns 1 on success.
339 #
340 #   HAVE_DUMP_ESTIMATE is defined to the dump flag which enables estimates.
341 #
342 #   The --with-honor-nodump flag is processed, and the result of the test is
343 #   positive, then HAVE_HONOR_NODUMP is defined.
344 #
345 AC_DEFUN([AMANDA_PROG_DUMP_RESTORE],
346 [
347     AC_REQUIRE([AMANDA_INIT_PROGS])
348     AC_REQUIRE([AMANDA_PROG_GREP])
349
350     # Set the order of dump programs to look for.  Finding the proper file
351     # system dumping program is problematic.  Some systems, notably HP-UX
352     # and AIX, have both the backup and dump programs.  HP-UX can't use the
353     # the backup program while AIX systems can't use the dump program.  So
354     # a variable is set up here to specify the order of dump programs to
355     # search for on the system.
356     DUMP_PROGRAMS="ufsdump dump backup"
357     DUMP_RETURNS_1=
358     AIX_BACKUP=
359     case "$host" in
360         *-dg-*)
361             DUMP_PROGRAMS="dump "$DUMP_PROGRAMS
362             DUMP_RETURNS_1=1
363             ;;
364       *-ibm-aix*)
365             DUMP_PROGRAMS="backup "$DUMP_PROGRAMS
366             AIX_BACKUP=1
367             AC_DEFINE(AIX_BACKUP,1,
368                 [Is DUMP the AIX program 'backup'?])
369             ;;
370       *-ultrix*)
371             DUMP_RETURNS_1=1
372             ;;
373     esac
374
375     if test -n "$DUMP_RETURNS_1"; then
376       AC_DEFINE(DUMP_RETURNS_1,1,
377         [Define this if this system's dump exits with 1 as a success code. ])
378     fi
379
380     AC_PATH_PROGS(DUMP,$DUMP_PROGRAMS,,$SYSLOCPATH)
381     AC_PATH_PROGS(RESTORE,ufsrestore restore,,$SYSLOCPATH)
382     
383     # newer versions of GNU tar include a program named 'backup' which
384     # does *not* implement the expected 'dump' interface.  Detect that here
385     # and pretend we never saw it.
386     if test -n "$DUMP"; then
387       if test "`basename $DUMP`" = "backup"; then
388         backup_gnutar=`$DUMP --version | $GREP "GNU tar"`
389         if test $? -eq 0; then
390           DUMP=
391         fi
392       fi
393     fi
394     
395     if test "$DUMP" -a "$RESTORE"; then
396         AC_DEFINE_UNQUOTED(DUMP,"$DUMP",
397             [Define the location of the ufsdump, backup, or dump program. ])
398         AC_DEFINE_UNQUOTED(RESTORE,"$RESTORE",
399             [Define the location of the ufsrestore or restore program. ])
400
401         # check for an estimate flag
402         if test -x $DUMP; then
403             AC_CACHE_CHECK(
404                 [whether $DUMP supports -E or -S for estimates],
405                 amanda_cv_dump_estimate,
406                 [
407                     case "$DUMP" in
408                     *dump)
409                         AC_TRY_COMMAND($DUMP 9Ef /dev/null /dev/null/invalid/fs 2>&1
410                             | $GREP -v Dumping
411                             | $GREP -v Date
412                             | $GREP -v Label >conftest.d-E 2>&1)
413                         cat conftest.d-E >&AS_MESSAGE_LOG_FD()
414                         AC_TRY_COMMAND($DUMP 9Sf /dev/null /dev/null/invalid/fs 2>&1
415                             | $GREP -v Dumping
416                             | $GREP -v Date
417                             | $GREP -v Label >conftest.d-S 2>&1)
418                         cat conftest.d-S >&AS_MESSAGE_LOG_FD()
419                         AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
420                             | $GREP -v Dumping
421                             | $GREP -v Date
422                             | $GREP -v Label >conftest.d 2>&1)
423                         cat conftest.d >&AS_MESSAGE_LOG_FD()
424                         if AC_TRY_COMMAND(cmp conftest.d-E conftest.d 1>&2); then
425                             amanda_cv_dump_estimate=E
426                         elif AC_TRY_COMMAND(cmp conftest.d-S conftest.d 1>&2); then
427                             amanda_cv_dump_estimate=S
428                         else
429                             amanda_cv_dump_estimate=no
430                         fi
431                         rm -f conftest.d conftest.d-E conftest.d-S
432                       ;;
433                     *) amanda_cv_dump_estimate=no
434                       ;;
435                     esac
436                 ])
437         else
438             AMANDA_MSG_WARN([$DUMP is not executable, cannot run -E/-S test])
439             amanda_cv_dump_estimate=no
440         fi
441         if test "x$amanda_cv_dump_estimate" != xno; then
442             AC_DEFINE_UNQUOTED(HAVE_DUMP_ESTIMATE, "$amanda_cv_dump_estimate",
443                 [Define to the string that enables dump estimates. ])
444         fi
445
446         AC_ARG_WITH(dump-honor-nodump,
447             AS_HELP_STRING([--with-dump-honor-nodump],
448                 [if dump supports -h, use it for level0s too]),
449         [
450             if test -x $DUMP; then
451                 AC_CACHE_CHECK(
452                   [whether $DUMP supports -h (honor nodump flag)],
453                   amanda_cv_honor_nodump,
454                   [
455                     case "$DUMP" in
456                     *dump)
457                         AC_TRY_COMMAND($DUMP 9hf 0 /dev/null /dev/null/invalid/fs 2>&1
458                             | $GREP -v Dumping
459                             | $GREP -v Date
460                             | $GREP -v Label >conftest.d-h 2>&1)
461                         cat conftest.d-h >&AS_MESSAGE_LOG_FD()
462                         AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
463                             | $GREP -v Dumping
464                             | $GREP -v Date
465                             | $GREP -v Label >conftest.d 2>&1)
466                         cat conftest.d >&AS_MESSAGE_LOG_FD()
467                         if AC_TRY_COMMAND(diff conftest.d-h conftest.d 1>&2); then
468                             amanda_cv_honor_nodump=yes
469                         else
470                             amanda_cv_honor_nodump=no
471                         fi
472                         rm -f conftest.d conftest.d-h
473                       ;;
474                     *) amanda_cv_honor_nodump=no
475                       ;;
476                     esac
477                   ])
478             else
479                 AMANDA_MSG_WARN([$DUMP is not executable, cannot run -h test])
480                 amanda_cv_honor_nodump=no
481             fi
482             if test "x$amanda_cv_honor_nodump" = xyes; then
483                 AC_DEFINE(HAVE_HONOR_NODUMP,1,
484                     [Define this if dump accepts -h for honoring nodump. ])
485             fi
486         ])
487     fi
488
489     AC_SUBST(AIX_BACKUP)
490     AC_SUBST(DUMP_RETURNS_1)
491 ])
492
493 # SYNOPSIS
494 #
495 #   AMANDA_CHECK_USE_RUNDUMP
496 #
497 # DESCRIPTION
498 #
499 #   Decide if the 'rundump' setuid-root wrapper should be used to invoke
500 #   dump.  If so, USE_RUNDUMP is defined and substituted.
501 #
502 AC_DEFUN([AMANDA_CHECK_USE_RUNDUMP], [
503     USE_RUNDUMP=no
504
505     # some systems require rundump unconditionally
506     case "$host" in
507         *-ultrix*) USE_RUNDUMP=yes ;;
508         *-dg-*) USE_RUNDUMP=yes ;;
509     esac
510
511     AC_ARG_WITH(rundump,
512         AS_HELP_STRING([--with-rundump], [use rundump, a setuid-root wrapper, to invoke dump]), [
513         case "$withval" in
514             n | no) USE_RUNDUMP=no ;;
515             y | ye | yes) USE_RUNDUMP=yes ;;
516             *) AC_MSG_ERROR([You must not supply an argument to --with-rundump option.]);;
517         esac
518         ])
519
520     if test x"$USE_RUNDUMP" = x"yes"; then
521         USE_RUNDUMP=1
522         AC_DEFINE(USE_RUNDUMP,1,
523             [Define to invoke rundump (setuid-root) instead of DUMP program directly. ])
524     else
525         USE_RUNDUMP=
526     fi
527
528     AC_SUBST(USE_RUNDUMP)
529 ])