Imported Upstream version 3.1.0
[debian/amanda] / config / amanda / changer.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_SETUP_CHANGER
4 #
5 # OVERVIEW
6 #
7 #   Set up for changers.  This first checks the availability of several
8 #   changer-related headers, then, based on those results, tries to 
9 #   compile some test programs for each supported changer API.  It finishes
10 #   by defining a series of AM_CONDITIONALS which are all used in
11 #   changer-src/Makefile.am.
12 #
13 #   The macro also searches for chio, chs, mtx, and mcutil, which are used
14 #   from various shell scripts in the changer-src/ directory.
15 #
16 AC_DEFUN([AMANDA_SETUP_CHANGER], [
17     AC_REQUIRE([AMANDA_PROG_CHIO])
18     AC_REQUIRE([AMANDA_PROG_CHS])
19     AC_REQUIRE([AMANDA_PROG_MTX])
20     AC_REQUIRE([AMANDA_PROG_MCUTIL])
21
22     AC_CHECK_HEADERS( \
23         camlib.h \
24         chio.h \
25         linux/chio.h \
26         scsi/sg.h \
27         scsi/scsi_ioctl.h \
28         sys/chio.h \
29         sys/dsreq.h \
30         sys/mtio.h \
31         sys/scarray.h \
32         sys/gscdds.h \
33         sys/scsi.h \
34         sys/scsiio.h \
35         sys/scsi/impl/uscsi.h \
36         sys/scsi/scsi/ioctl.h, \
37         [], [], [AC_INCLUDES_DEFAULT])
38
39     #
40     # chio support
41     #
42     if test x"$ac_cv_header_sys_scsi_h" = x"yes"; then
43         AC_CACHE_CHECK([for HP/UX-like scsi changer support],
44             amanda_cv_hpux_scsi_chio,
45             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
46 #include <sys/scsi.h>
47     ]], [[
48             static struct element_addresses changer_info;
49             int i = SIOC_ELEMENT_ADDRESSES;
50             int j = SIOC_ELEMENT_STATUS;
51             int k = SIOC_MOVE_MEDIUM;
52     ]])],[amanda_cv_hpux_scsi_chio=yes],[amanda_cv_hpux_scsi_chio=no])])
53         if test x"$amanda_cv_hpux_scsi_chio" = x"yes"; then
54             WANT_SCSI_HPUX=yes
55             WANT_CHG_SCSI=yes
56         fi
57     fi
58
59     #
60     # Linux SCSI based on ioctl
61     #
62     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
63        test x"$ac_cv_header_scsi_scsi_ioctl_h" = x"yes"; then 
64             AC_CACHE_CHECK([for Linux like scsi support (ioctl)],
65             amanda_cv_linux_scsi,
66             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
67 #include <scsi/scsi_ioctl.h>
68 #include <sys/mtio.h>
69     ]], [[
70             int device;
71             char *Command;
72             ioctl(device, SCSI_IOCTL_SEND_COMMAND, Command);
73     ]])],[amanda_cv_linux_scsi=yes],[amanda_cv_linux_scsi=no])])
74     fi
75
76     #
77     # Linux SCSI based on sg
78     #
79     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
80        test x"$ac_cv_header_scsi_sg_h" = x"yes"; then 
81             AC_CACHE_CHECK([for Linux like scsi support (sg)],
82             amanda_cv_linux_sg_scsi,
83             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
84 #include <sys/types.h>
85 #include <scsi/sg.h>
86 #include <sys/mtio.h>
87     ]], [[
88             int device;
89             struct sg_header *psg_header;
90             char *buffer;
91             write(device, buffer, 1);
92     ]])],[amanda_cv_linux_sg_scsi=yes],[amanda_cv_linux_sg_scsi=no])])
93     fi
94
95     if test x"$amanda_cv_linux_scsi" = x"yes" ||
96      test x"$amanda_cv_linux_sg_scsi" = x"yes";then
97             WANT_SCSI_LINUX=yes
98             WANT_CHG_SCSI=yes
99     fi
100
101     #
102     # HP-UX SCSI
103     #
104     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
105        test x"$ac_cv_header_sys_scsi_h" = x"yes"; then 
106             AC_CACHE_CHECK([for HP-UX like scsi support],
107             amanda_cv_hpux_scsi,
108             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
109 #include <stdio.h>
110 #include <sys/ioctl.h>
111 #include <sys/scsi.h>
112 #include <sys/mtio.h>
113     ]], [[
114             int device;
115             char *Command;
116             ioctl(device, SIOC_IO, Command);
117     ]])],[amanda_cv_hpux_scsi=yes],[amanda_cv_hpux_scsi=no])])
118             if test x"$amanda_cv_hpux_scsi" = x"yes";then
119                     WANT_SCSI_HPUX_NEW=yes
120                     WANT_CHG_SCSI=yes
121                     WANT_CHG_SCSI_CHIO=yes
122             fi
123     fi
124
125     #
126     # IRIX SCSI
127     #
128     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
129        test x"$ac_cv_header_sys_dsreq_h" = x"yes"; then 
130             AC_CACHE_CHECK([for Irix like scsi support],
131             amanda_cv_irix_scsi,
132             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
133 #include <sys/types.h>
134 #include <sys/dsreq.h>
135 #include <sys/mtio.h>
136     ]], [[
137             int device=1;
138             char Command;
139             ioctl(device, DS_ENTER, &Command);
140     ]])],[amanda_cv_irix_scsi=yes],[amanda_cv_irix_scsi=no])])
141             if test x"$amanda_cv_irix_scsi" = x"yes";then
142                     WANT_SCSI_IRIX=yes
143                     WANT_CHG_SCSI=yes
144             fi
145     fi
146
147     #
148     # Solaris  SCSI
149     #
150     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
151        test x"$ac_cv_header_sys_scsi_impl_uscsi_h" = x"yes"; then 
152             AC_CACHE_CHECK([for Solaris-like scsi support],
153             amanda_cv_solaris_scsi,
154             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
155 #include <sys/types.h>
156 #include <sys/scsi/impl/uscsi.h>
157 #include <sys/mtio.h>
158     ]], [[
159             int device;
160             char *Command;
161             ioctl(device, USCSICMD, Command);
162     ]])],[amanda_cv_solaris_scsi=yes],[amanda_cv_solaris_scsi=no])])
163             if test x"$amanda_cv_solaris_scsi" = x"yes";then
164                     WANT_SCSI_SOLARIS=yes
165                     WANT_CHG_SCSI=yes
166             fi
167     fi
168
169     #
170     # AIX SCSI
171     #
172     if test x"$ac_cv_header_sys_tape_h" = x"yes" &&
173        test x"$ac_cv_header_sys_scarray_h" = x"yes" &&
174        test x"$ac_cv_header_sys_gscdds_h" = x"yes"; then 
175             AC_CACHE_CHECK([for AIX like scsi support],
176             amanda_cv_aix_scsi,
177             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
178 #include <sys/types.h>
179 #include <sys/scarray.h>
180 #include <sys/tape.h>
181     ]], [[
182             int device;
183             char *Command;
184             ioctl(device, STIOCMD, Command);
185     ]])],[amanda_cv_aix_scsi=yes],[amanda_cv_aix_scsi=no])])
186             if test x"$amanda_cv_aix_scsi" = x"yes";then
187                     WANT_SCSI_AIX=yes
188                     WANT_CHG_SCSI=yes
189             fi
190     fi
191     #
192     # BSD CAM SCSI
193     #
194     if test x"$ac_cv_header_cam_cam_h" = x"yes";then
195             AC_CACHE_CHECK([for CAM like scsi support],
196             amanda_cv_cam_scsi,
197             [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
198 #include <stdio.h>
199 # include <fcntl.h>
200 # include <cam/cam.h>
201 # include <cam/cam_ccb.h>
202 # include <cam/scsi/scsi_message.h>
203 # include <cam/scsi/scsi_pass.h>
204 # include <camlib.h>
205     ]], [[
206             struct cam_device *curdev;
207
208             curdev = cam_open_pass("", O_RDWR, NULL);
209     ]])],[amanda_cv_cam_scsi=yes],[amanda_cv_cam_scsi=no])])
210             if test x"$amanda_cv_cam_scsi" = x"yes";then
211                     WANT_SCSI_CAM=yes
212                     WANT_CHG_SCSI=yes
213                     AC_CHECK_LIB(cam,main)
214             fi
215     fi
216
217
218     #
219     # BSD SCSI
220     #
221     if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
222        test x"$ac_cv_header_sys_scsiio_h" = x"yes"; then
223         AC_CACHE_CHECK([for BSD like scsi support],
224         amanda_cv_bsd_scsi,
225         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
226 #include <sys/types.h>
227 #include <sys/scsiio.h>
228 #include <sys/mtio.h>
229     ]], [[
230         int device=1;
231         char Command;
232         ioctl(device, SCIOCCOMMAND, &Command);
233     ]])],[amanda_cv_bsd_scsi=yes],[amanda_cv_bsd_scsi=no])])
234         if test x"$amanda_cv_bsd_scsi" = x"yes";then
235            WANT_SCSI_BSD=yes
236            WANT_CHG_SCSI=yes
237         fi
238     fi
239
240     # Do not build chg-scsi-chio if we cannot find the needed support
241     # include files for the SCSI interfaces
242     # chio.h and sys/chio.h are chio based systems
243     if test x"$ac_cv_header_chio_h" = x"yes" ||
244        test x"$ac_cv_header_linux_chio_h" = x"yes" ||
245        test x"$ac_cv_header_sys_chio_h" = x"yes"; then
246        # chg-scsi does not support FreeBSD 3.0's chio.h; it became backward
247        # incompatible with the introduction of camlib.h
248        if test x"$ac_cv_header_camlib_h" != x"yes"; then
249          WANT_SCSI_CHIO=yes
250          # prefer to use chg-scsi, unless we already have a driver for that,
251          # in which case set it up as chg-scsi-chio.
252          if test x"$WANT_CHG_SCSI" = x"no"; then
253            WANT_CHG_SCSI=yes
254          else
255            WANT_CHG_SCSI_CHIO=yes
256          fi
257        fi
258     fi
259
260     # scsi-based implementations
261     AM_CONDITIONAL(WANT_CHG_SCSI, test x"$WANT_CHG_SCSI" = x"yes")
262     AM_CONDITIONAL(WANT_SCSI_LINUX, test x"$WANT_SCSI_LINUX" = x"yes")
263     AM_CONDITIONAL(WANT_SCSI_HPUX_NEW, test x"$WANT_SCSI_HPUX_NEW" = x"yes")
264     AM_CONDITIONAL(WANT_SCSI_IRIX, test x"$WANT_SCSI_IRIX" = x"yes")
265     AM_CONDITIONAL(WANT_SCSI_SOLARIS, test x"$WANT_SCSI_SOLARIS" = x"yes")
266     AM_CONDITIONAL(WANT_SCSI_AIX, test x"$WANT_SCSI_AIX" = x"yes")
267     AM_CONDITIONAL(WANT_SCSI_CAM, test x"$WANT_SCSI_CAM" = x"yes")
268     AM_CONDITIONAL(WANT_SCSI_BSD, test x"$WANT_SCSI_BSD" = x"yes")
269
270     # scsi-chio-based implementations
271     AM_CONDITIONAL(WANT_CHG_SCSI_CHIO, test x"$WANT_CHG_SCSI_CHIO" = x"yes")
272     AM_CONDITIONAL(WANT_SCSI_HPUX, test x"$WANT_SCSI_HPUX" = x"yes")
273     AM_CONDITIONAL(WANT_SCSI_CHIO, test x"$WANT_SCSI_CHIO" = x"yes")
274 ])