Imported Upstream version 2.6.0p1
[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         for gnutar_name in gtar gnutar tar; do
40             AC_PATH_PROGS(GNUTAR, $gnutar_name, , $LOCSYSPATH)
41             if test -n "$GNUTAR"; then
42               case "`\"$GNUTAR\" --version 2>&1`" in
43                *GNU*tar* | *Free*paxutils* )
44                             # OK, it is GNU tar
45                             break
46                             ;;
47                *)
48                             # warning..
49                             AMANDA_MSG_WARN([$GNUTAR is not GNU tar, so it will not be used.])
50                             # reset the cache for GNUTAR so AC_PATH_PROGS will search again
51                             GNUTAR=''
52                             unset ac_cv_path_GNUTAR
53                             ;;
54               esac
55             fi
56         done
57     fi
58
59     if test "x$GNUTAR" != "x"; then
60         # define unquoted
61         AC_DEFINE_UNQUOTED(GNUTAR, "$GNUTAR", [Location of the GNU 'tar' binary])
62     fi
63     AC_ARG_VAR(GNUTAR, [Location of the GNU 'tar' binary])
64     AC_SUBST(GNUTAR)
65 ])
66
67 # SYNOPSIS
68 #
69 #   AMANDA_PROG_SAMBA_CLIENT
70 #
71 # OVERVIEW
72 #
73 #   Search for a samba client (smbclient) binary, placing the result in
74 #   the variable SAMBA_CLIENT.  The discovered binary is tested to determine an
75 #   internally significant version number, stored in SAMBA_VERSION.  The version
76 #   serves only to differentiate versions of Samba which Amanada must treat 
77 #   differently, and has no relation to the actual Samba version number.
78 #
79 #   Automake conditional 'WANT_SAMBA' is set if a samba client is discovered.
80 #
81 #   Also handles --with-smbclient and (deprecated) --with-samba-user
82 #
83 AC_DEFUN([AMANDA_PROG_SAMBA_CLIENT],
84 [
85     AC_REQUIRE([AMANDA_INIT_PROGS])
86
87     AC_ARG_WITH(smbclient,
88         AS_HELP_STRING([--with-smbclient=PROG],
89                        [use PROG as 'smbclient']),
90         [
91             case "$withval" in
92                 /*) SAMBA_CLIENT="$withval";;
93                 y|ye|yes) :;;
94                 n|no) SAMBA_CLIENT=no ;;
95                 *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-smbclient]);;
96             esac
97         ]
98     )
99
100     AC_ARG_WITH(samba-user,
101         AS_HELP_STRING([--with-samba-user],
102                        [deprecated; place username in 'amandapass']),
103        [ AC_MSG_ERROR([--with-samba-user is no longer supported; place username in 'amandapass']) ]
104     )
105
106     if test "x$SAMBA_CLIENT" != "xno"; then
107       AC_PATH_PROG(SAMBA_CLIENT,smbclient,,$LOCSYSPATH)
108       smbversion=0
109       if test ! -z "$SAMBA_CLIENT"; then
110         case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1`" in
111         *"Unknown host"*)
112                       smbversion=1
113                       ;;
114         *"Connection to not.a.host.name failed"*)
115                       smbversion=2
116                       ;;
117         *)
118                       AMANDA_MSG_WARN([$SAMBA_CLIENT does not seem to be smbclient, so it will not be used.])
119                       SAMBA_CLIENT=
120                       ;;
121         esac
122         if test -n "$SAMBA_CLIENT"; then
123           AC_DEFINE_UNQUOTED(SAMBA_CLIENT,"$SAMBA_CLIENT",
124                   [Define the location of smbclient for backing up Samba PC clients. ])
125           AC_DEFINE_UNQUOTED(SAMBA_VERSION, $smbversion,
126                   [Not the actual samba version, just a number that should be increased whenever we start to rely on a new samba feature. ])
127         fi
128       fi
129     fi
130
131     AM_CONDITIONAL(WANT_SAMBA, test -n "$SAMBA_CLIENT")
132 ])
133
134 # SYNOPSIS
135 #
136 #   AMANDA_PROG_VDUMP_VRESTORE
137 #
138 # DESCRIPTION
139 #
140 #   Search for 'vdump' and 'vrestore', setting and AC_DEFINE-ing VDUMP and 
141 #   VRESTORE if they are found.
142 #
143 AC_DEFUN([AMANDA_PROG_VDUMP_VRESTORE],
144 [
145     AC_REQUIRE([AMANDA_INIT_PROGS])
146
147     AC_PATH_PROG(VDUMP,vdump,,$SYSLOCPATH)
148     AC_PATH_PROG(VRESTORE,vrestore,,$SYSLOCPATH)
149     if test "$VDUMP" -a "$VRESTORE"; then
150         AC_DEFINE_UNQUOTED(VDUMP,"$VDUMP",[Define the location of the vdump program. ])
151         AC_DEFINE_UNQUOTED(VRESTORE,"$VRESTORE",[Define the location of the vrestore program. ])
152     fi
153 ])
154
155 # SYNOPSIS
156 #
157 #   AMANDA_PROG_VXDUMP_VXRESTORE
158 #
159 # DESCRIPTION
160 #
161 #   Search for 'vxdump' and 'vxrestore', setting and AC_DEFINE-ing VXDUMP
162 #   and VXRESTORE if they are found.
163 #
164 #   In addition to the standard paths, this macro will search in
165 #   /usr/lib/fs/vxfs.
166 #
167 AC_DEFUN([AMANDA_PROG_VXDUMP_VXRESTORE],
168 [
169     AC_REQUIRE([AMANDA_INIT_PROGS])
170
171     AC_PATH_PROG(VXDUMP,vxdump,,$SYSLOCPATH:/usr/lib/fs/vxfs)
172     AC_PATH_PROG(VXRESTORE,vxrestore,,$SYSLOCPATH:/usr/lib/fs/vxfs)
173     if test "$VXDUMP" -a "$VXRESTORE"; then
174         AC_DEFINE_UNQUOTED(VXDUMP,"$VXDUMP",
175 [Define the location of the vxdump program on HPUX and SINIX hosts or on
176  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
177         AC_DEFINE_UNQUOTED(VXRESTORE,"$VXRESTORE",
178 [Define the location of the vxrestore program on HPUX and SINIX hosts or on
179  * other hosts where the Veritas filesystem (vxfs) has been installed. ])
180     fi
181 ])
182
183 # SYNOPSIS
184 #
185 #   AMANDA_PROG_XFSDUMP_XFSRESTORE
186 #
187 # DESCRIPTION
188 #
189 #   Search for 'xfsdump' and 'xfsrestore', setting and AC_DEFINE-ing XFSDUMP
190 #   and XFSRESTORE if they are found.
191 #
192 AC_DEFUN([AMANDA_PROG_XFSDUMP_XFSRESTORE],
193 [
194     AC_REQUIRE([AMANDA_INIT_PROGS])
195
196     AC_PATH_PROGS(XFSDUMP,xfsdump,,$SYSLOCPATH)
197     AC_PATH_PROGS(XFSRESTORE,xfsrestore,,$SYSLOCPATH)
198     if test "$XFSDUMP" -a "$XFSRESTORE"; then
199         AC_DEFINE_UNQUOTED(XFSDUMP,"$XFSDUMP",
200                 [Define the location of the xfsdump program on Irix hosts. ])
201         AC_DEFINE_UNQUOTED(XFSRESTORE,"$XFSRESTORE",
202                 [Define the location of the xfsrestore program on Irix hosts. ])
203         AMANDA_MSG_WARN([[xfsdump causes the setuid-root rundump program to be enabled.  To disable it, just #undef XFSDUMP in config/config.h]])
204     fi
205 ])
206
207 # SYNOPSIS
208 #
209 #   AMANDA_PROG_DUMP_RESTORE
210 #
211 # DESCRIPTION
212 #
213 #   Search for compatible dump and restore binaries.  The exact name of
214 #   the binaries we search for depends on the target system.  If working
215 #   binaries are found, DUMP and RESTORE are defined to their full paths.
216 #
217 #   DUMP_RETURNS is defined if the system's 'dump' returns 1 on success.
218 #
219 #   HAVE_DUMP_ESTIMATE is defined to the dump flag which enables estimates.
220 #
221 #   The --with-honor-nodump flag is processed, and the result of the test is
222 #   positive, then HAVE_HONOR_NODUMP is defined.
223 #
224 AC_DEFUN([AMANDA_PROG_DUMP_RESTORE],
225 [
226     AC_REQUIRE([AMANDA_INIT_PROGS])
227     AC_REQUIRE([AMANDA_PROG_GREP])
228
229     # Set the order of dump programs to look for.  Finding the proper file
230     # system dumping program is problematic.  Some systems, notably HP-UX
231     # and AIX, have both the backup and dump programs.  HP-UX can't use the
232     # the backup program while AIX systems can't use the dump program.  So
233     # a variable is set up here to specify the order of dump programs to
234     # search for on the system.
235     DUMP_PROGRAMS="ufsdump dump backup"
236     dump_returns_1=
237     case "$target" in
238         *-dg-*)
239             DUMP_PROGRAMS="dump "$DUMP_PROGRAMS
240             dump_returns_1=yes
241             ;;
242       *-ibm-aix*)
243             DUMP_PROGRAMS="backup "$DUMP_PROGRAMS
244             AC_DEFINE(AIX_BACKUP,1,
245                 [Is DUMP the AIX program 'backup'?])
246             ;;
247       *-ultrix*)
248             dump_returns_1=yes
249             ;;
250     esac
251
252     if test -n "$dump_returns_1"; then
253       AC_DEFINE(DUMP_RETURNS_1,1,
254         [Define this if this system's dump exits with 1 as a success code. ])
255     fi
256
257     AC_PATH_PROGS(DUMP,$DUMP_PROGRAMS,,$SYSLOCPATH)
258     AC_PATH_PROGS(RESTORE,ufsrestore restore,,$SYSLOCPATH)
259     
260     # newer versions of GNU tar include a program named 'backup' which
261     # does *not* implement the expected 'dump' interface.  Detect that here
262     # and pretend we never saw it.
263     if test -n "$DUMP"; then
264       if test "`basename $DUMP`" = "backup"; then
265         backup_gnutar=`$DUMP --version | $GREP "GNU tar"`
266         if test $? -eq 0; then
267           DUMP=
268         fi
269       fi
270     fi
271     
272     if test "$DUMP" -a "$RESTORE"; then
273         AC_DEFINE_UNQUOTED(DUMP,"$DUMP",
274             [Define the location of the ufsdump, backup, or dump program. ])
275         AC_DEFINE_UNQUOTED(RESTORE,"$RESTORE",
276             [Define the location of the ufsrestore or restore program. ])
277
278         # check for an estimate flag
279         if test -x $DUMP; then
280             AC_CACHE_CHECK(
281                 [whether $DUMP supports -E or -S for estimates],
282                 amanda_cv_dump_estimate,
283                 [
284                     case "$DUMP" in
285                     *dump)
286                         AC_TRY_COMMAND($DUMP 9Ef /dev/null /dev/null/invalid/fs 2>&1
287                             | $GREP -v Dumping
288                             | $GREP -v Date
289                             | $GREP -v Label >conftest.d-E 2>&1)
290                         cat conftest.d-E >&AS_MESSAGE_LOG_FD()
291                         AC_TRY_COMMAND($DUMP 9Sf /dev/null /dev/null/invalid/fs 2>&1
292                             | $GREP -v Dumping
293                             | $GREP -v Date
294                             | $GREP -v Label >conftest.d-S 2>&1)
295                         cat conftest.d-S >&AS_MESSAGE_LOG_FD()
296                         AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
297                             | $GREP -v Dumping
298                             | $GREP -v Date
299                             | $GREP -v Label >conftest.d 2>&1)
300                         cat conftest.d >&AS_MESSAGE_LOG_FD()
301                         if AC_TRY_COMMAND(cmp conftest.d-E conftest.d 1>&2); then
302                             amanda_cv_dump_estimate=E
303                         elif AC_TRY_COMMAND(cmp conftest.d-S conftest.d 1>&2); then
304                             amanda_cv_dump_estimate=S
305                         else
306                             amanda_cv_dump_estimate=no
307                         fi
308                         rm -f conftest.d conftest.d-E conftest.d-S
309                       ;;
310                     *) amanda_cv_dump_estimate=no
311                       ;;
312                     esac
313                 ])
314         else
315             AMANDA_MSG_WARN([$DUMP is not executable, cannot run -E/-S test])
316             amanda_cv_dump_estimate=no
317         fi
318         if test "x$amanda_cv_dump_estimate" != xno; then
319             AC_DEFINE_UNQUOTED(HAVE_DUMP_ESTIMATE, "$amanda_cv_dump_estimate",
320                 [Define to the string that enables dump estimates. ])
321         fi
322
323         AC_ARG_WITH(dump-honor-nodump,
324             AS_HELP_STRING([--with-dump-honor-nodump],
325                 [if dump supports -h, use it for level0s too]),
326         [
327             if test -x $DUMP; then
328                 AC_CACHE_CHECK(
329                   [whether $DUMP supports -h (honor nodump flag)],
330                   amanda_cv_honor_nodump,
331                   [
332                     case "$DUMP" in
333                     *dump)
334                         AC_TRY_COMMAND($DUMP 9hf 0 /dev/null /dev/null/invalid/fs 2>&1
335                             | $GREP -v Dumping
336                             | $GREP -v Date
337                             | $GREP -v Label >conftest.d-h 2>&1)
338                         cat conftest.d-h >&AS_MESSAGE_LOG_FD()
339                         AC_TRY_COMMAND($DUMP 9f /dev/null /dev/null/invalid/fs 2>&1
340                             | $GREP -v Dumping
341                             | $GREP -v Date
342                             | $GREP -v Label >conftest.d 2>&1)
343                         cat conftest.d >&AS_MESSAGE_LOG_FD()
344                         if AC_TRY_COMMAND(diff conftest.d-h conftest.d 1>&2); then
345                             amanda_cv_honor_nodump=yes
346                         else
347                             amanda_cv_honor_nodump=no
348                         fi
349                         rm -f conftest.d conftest.d-h
350                       ;;
351                     *) amanda_cv_honor_nodump=no
352                       ;;
353                     esac
354                   ])
355             else
356                 AMANDA_MSG_WARN([$DUMP is not executable, cannot run -h test])
357                 amanda_cv_honor_nodump=no
358             fi
359             if test "x$amanda_cv_honor_nodump" = xyes; then
360                 AC_DEFINE(HAVE_HONOR_NODUMP,1,
361                     [Define this if dump accepts -h for honoring nodump. ])
362             fi
363         ])
364     fi
365 ])
366
367 # SYNOPSIS
368 #
369 #   AMANDA_CHECK_USE_RUNDUMP
370 #
371 # DESCRIPTION
372 #
373 #   Decide if the 'rundump' setuid-root wrapper should be used to invoke
374 #   dump.  If so, USE_RUNDUMP is #defined.
375 #
376 AC_DEFUN([AMANDA_CHECK_USE_RUNDUMP], [
377     USE_RUNDUMP=no
378
379     # some systems require rundump unconditionally
380     case "$target" in
381         *-ultrix*) USE_RUNDUMP=yes ;;
382         *-dg-*) USE_RUNDUMP=yes ;;
383     esac
384
385     AC_ARG_WITH(rundump,
386         AS_HELP_STRING([--with-rundump], [use rundump, a setuid-root wrapper, to invoke dump]), [
387         case "$withval" in
388             n | no) USE_RUNDUMP=no ;;
389             y | ye | yes) USE_RUNDUMP=yes ;;
390             *) AC_MSG_ERROR([You must not supply an argument to --with-rundump option.]);;
391         esac
392         ])
393
394     if test x"$USE_RUNDUMP" = x"yes"; then
395         AC_DEFINE(USE_RUNDUMP,1,
396             [Define to invoke rundump (setuid-root) instead of DUMP program directly. ])
397     fi
398 ])