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