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