d08f27a9a0f0032443096c4a3c96b2a413300bdb
[debian/amanda] / config / amanda / tape.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_WITH_MAXTAPEBLOCKSIZE
4 #
5 # OVERVIEW
6 #
7 #   Implement the --with-maxtapeblocksize option, and DEFINE and SUBST the
8 #   result in MAX_TAPE_BLOCk_KB and MAXTAPEBLOCKSIZE, respectively.
9 #
10 AC_DEFUN([AMANDA_WITH_MAXTAPEBLOCKSIZE], [
11     AC_ARG_WITH(maxtapeblocksize,
12         AS_HELP_STRING([--with-maxtapeblocksize=kb],
13             [Maximum size of a tape block (default: 32)]),
14         [ MAXTAPEBLOCKSIZE="$withval" ],
15         [ MAXTAPEBLOCKSIZE=32 ]
16     )
17
18     AC_DEFINE_UNQUOTED(MAX_TAPE_BLOCK_KB,($MAXTAPEBLOCKSIZE),
19         [Maximum size of a tape block in KBytes.])
20     AC_SUBST(MAXTAPEBLOCKSIZE)
21 ])
22
23 # SYNOPSIS
24 #
25 #   AMANDA_TAPE_DEVICE
26 #
27 # OVERVIEW
28 #
29 #   Set up for the 'tape' device.  One of the conditionals WANT_TAPE_XENIX,
30 #   WANT_TAPE_AIX, WANT_TAPE_UWARE, and WANT_TAPE_POSIX will be true; the
31 #   corresponding symbols are also DEFINEd.  Finally, WANT_TAPE_DEVICE is
32 #   defined nad AM_CONDITIONAL'd if the tape device should be supported (if
33 #   at least one of the backends is available).
34 #
35 #   If 'struct mtget' fields mt_flags, mt_fileno, mt_blkno, mt_dsreg, and 
36 #   mt_erreg, the corresponding HAVE_MT_* is DEFINEd.
37 #
38 #   Not that most of the checks in this section correspond to the older
39 #   tapeio (in tape-src/), rather than the new tape device.
40 #
41 AC_DEFUN([AMANDA_TAPE_DEVICE], [
42     AC_CHECK_HEADERS( \
43         linux/zftape.h \
44         sys/tape.h \
45         sys/mtio.h \
46         )
47
48     # check for MTIOCTOP, an indicator of POSIX tape support
49     AC_CACHE_CHECK([for MTIOCTOP], amanda_cv_HAVE_MTIOCTOP,[
50         AC_TRY_COMPILE([
51 #ifdef HAVE_SYS_TAPE_H
52 # include <sys/tape.h>
53 #endif
54 #ifdef HAVE_SYS_MTIO_H
55 # include <sys/mtio.h>
56 #endif
57 #ifndef MTIOCTOP
58 #error MTIOCTOP not defined
59 #endif
60             ],
61             [ int dummy = 0; ],
62             amanda_cv_HAVE_MTIOCTOP=yes,
63             amanda_cv_HAVE_MTIOCTOP=no,
64             amanda_cv_HAVE_MTIOCTOP=no)]
65
66         HAVE_MTIOCTOP=$amanda_cv_HAVE_MTIOCTOP
67     )
68
69     # decide which tape device to compile (arranged in such a way that
70     # only one actually gets compiled)
71     case "$target" in
72       *-ibm-aix*) aix_tapeio=yes ;;
73       *-sysv4.2uw2*) uware_tapeio=yes ;;
74       *-sco3.2v5*) xenix_tapeio=yes ;;
75       i386-pc-isc4*) xenix_tapeio=yes ;;
76     esac
77
78     # maybe we have no tape device at all (e.g., Mac OS X)?
79     if test -n "$xenix_tapeio" ||
80        test -n "$aix_tapeio" ||
81        test -n "$uware_tapeio" ||
82        test -n "$HAVE_MTIOCTOP"; then
83         want_tape_device=yes
84         AC_DEFINE(WANT_TAPE_DEVICE, 1, [Define if the tape-device will be built])
85     fi
86
87     AM_CONDITIONAL(WANT_TAPE_XENIX, test -n "$xenix_tapeio")
88     AM_CONDITIONAL(WANT_TAPE_AIX, test -n "$aix_tapeio")
89     AM_CONDITIONAL(WANT_TAPE_UWARE, test -n "$uware_tapeio")
90     AM_CONDITIONAL(WANT_TAPE_POSIX, test -n "$HAVE_MTIOCTOP")
91     AM_CONDITIONAL(WANT_TAPE_DEVICE, test -n "$want_tape_device")
92
93     if test -n "$xenix_tapeio"; then
94       AC_DEFINE(WANT_TAPE_XENIX,1,[Define on XENIX/ISC. ])
95     fi
96
97     if test -n "$aix_tapeio"; then
98       AC_DEFINE(WANT_TAPE_AIX,1,[Define on AIX. ])
99     fi
100
101     if test -n "$uware_tapeio"; then
102       AC_DEFINE(WANT_TAPE_UWARE,1,[Define on UnixWare. ])
103     fi
104
105     #
106     # Check for various "mt status" related structure elements.
107     #
108     AC_MSG_CHECKING([for mt_flags mtget structure element])
109     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
110 #include <stdio.h>
111 #include <sys/types.h>
112 #include <sys/mtio.h>
113         ]], [[
114             struct mtget buf;
115             long ds;
116
117             ds = buf.mt_flags;
118         ]])],[
119             AC_MSG_RESULT(yes)
120             AC_DEFINE(HAVE_MT_FLAGS,1,
121                 [Define if the mtget structure has an mt_flags field])
122         ],[
123             AC_MSG_RESULT(no)
124         ])
125
126     AC_MSG_CHECKING([for mt_fileno mtget structure element])
127     mt_fileno_result="found"
128     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
129 #include <stdio.h>
130 #include <sys/types.h>
131 #include <sys/mtio.h>
132         ]], [[
133             struct mtget buf;
134             long ds;
135
136             ds = buf.mt_fileno;
137         ]])],[
138             AC_MSG_RESULT(yes)
139             AC_DEFINE(HAVE_MT_FILENO,1,
140                 [Define if the mtget structure has an mt_fileno field])
141         ],[
142             AC_MSG_RESULT(no)
143         ])
144
145     AC_MSG_CHECKING(for mt_blkno mtget structure element)
146     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
147 #include <stdio.h>
148 #include <sys/types.h>
149 #include <sys/mtio.h>
150         ]], [[
151             struct mtget buf;
152             long ds;
153
154             ds = buf.mt_blkno;
155         ]])],[
156             AC_MSG_RESULT(yes)
157             AC_DEFINE(HAVE_MT_BLKNO,1,
158                 [Define if the mtget structure has an mt_blkno field])
159         ],[
160             AC_MSG_RESULT(no)
161         ])
162
163     AC_MSG_CHECKING(for mt_dsreg mtget structure element)
164     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
165 #include <stdio.h>
166 #include <sys/types.h>
167 #include <sys/mtio.h>
168         ]], [[
169             struct mtget buf;
170             long ds;
171
172             ds = buf.mt_dsreg;
173         ]])],[
174             AC_MSG_RESULT(yes)
175             AC_DEFINE(HAVE_MT_DSREG,1,
176                 [Define if the mtget structure has an mt_dsreg field])
177         ],[
178             AC_MSG_RESULT(no)
179         ])
180
181     AC_MSG_CHECKING(for mt_erreg mtget structure element)
182     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
183 #include <stdio.h>
184 #include <sys/types.h>
185 #include <sys/mtio.h>
186         ]], [[
187             struct mtget buf;
188             long ds;
189
190             ds = buf.mt_erreg;
191         ]])],[
192             AC_MSG_RESULT(yes)
193             AC_DEFINE(HAVE_MT_ERREG,1,
194                 [Define if the mtget structure has an mt_erreg field])
195         ],[
196             AC_MSG_RESULT(no)
197         ])
198 ])