Whamcloud - gitweb
LU-3462 ldiskfs: Subsume ldiskfs's build system into lustre
[fs/lustre-release.git] / config / lustre-build-ldiskfs.m4
1 AC_DEFUN([LDISKFS_LINUX_SERIES],
2 [
3 LDISKFS_SERIES=
4 AC_MSG_CHECKING([which ldiskfs series to use])
5
6 SER=
7 AS_IF([test x$RHEL_KERNEL = xyes], [
8         AS_VERSION_COMPARE([$RHEL_KERNEL_VERSION],[2.6.32-343],[
9         AS_VERSION_COMPARE([$RHEL_KERNEL_VERSION],[2.6.32],[],
10         [SER="2.6-rhel6.series"],[SER="2.6-rhel6.series"])],
11         [SER="2.6-rhel6.4.series"],[SER="2.6-rhel6.4.series"])
12 ], [test x$SUSE_KERNEL = xyes], [
13         AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[
14         AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32],[],
15         [SER="2.6-sles11.series"],[SER="2.6-sles11.series"])],
16         [SER="3.0-sles11.series"],[SER="3.0-sles11.series"])
17 ])
18 LDISKFS_SERIES=$SER
19
20 AS_IF([test -z "$LDISKFS_SERIES"],
21         [AC_MSG_WARN([Unknown kernel version $LDISKFS_VERSIONRELEASE])])
22 AC_MSG_RESULT([$LDISKFS_SERIES])
23
24 AC_SUBST(LDISKFS_SERIES)
25 ])
26
27 #
28 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
29 #
30 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD],
31 [AC_MSG_CHECKING([if ext4_free_blocks needs struct buffer_head])
32  LB_LINUX_TRY_COMPILE([
33         #include <linux/fs.h>
34         #include "$EXT4_SRC_DIR/ext4.h"
35 ],[
36         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
37 ],[
38         AC_MSG_RESULT([yes])
39         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
40                   [ext4_free_blocks do not require struct buffer_head])
41 ],[
42         AC_MSG_RESULT([no])
43 ])
44 ])
45
46 #
47 # 2.6.35 renamed ext_pblock to ext4_ext_pblock(ex)
48 #
49 AC_DEFUN([LB_EXT_PBLOCK],
50 [AC_MSG_CHECKING([if kernel has ext_pblocks])
51  LB_LINUX_TRY_COMPILE([
52         #include <linux/fs.h>
53         #include "$EXT4_SRC_DIR/ext4_extents.h"
54 ],[
55         ext_pblock(NULL);
56 ],[
57         AC_MSG_RESULT([yes])
58         AC_DEFINE(HAVE_EXT_PBLOCK, 1,
59                   [kernel has ext_pblocks])
60 ],[
61         AC_MSG_RESULT([no])
62 ])
63 ])
64
65 #
66 # LDISKFS_AC_PATCH_PROGRAM
67 #
68 # Determine which program should be used to apply the patches to
69 # the ext4 source code to produce the ldiskfs source code.
70 #
71 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
72         AC_ARG_ENABLE([quilt],
73                 [AC_HELP_STRING([--disable-quilt],
74                         [disable use of quilt for ldiskfs])],
75                 [AS_IF([test "x$enableval" = xno],
76                         [use_quilt=no],
77                         [use_quilt=maybe])],
78                 [use_quilt=maybe]
79         )
80
81         AS_IF([test x$use_quilt = xmaybe], [
82                 AC_PATH_PROG([quilt_avail], [quilt], [no])
83                 AS_IF([test x$quilt_avail = xno], [
84                         use_quilt=no
85                 ], [
86                         use_quilt=yes
87                 ])
88         ])
89
90         AS_IF([test x$use_quilt = xno], [
91                 AC_PATH_PROG([patch_avail], [patch], [no])
92                 AS_IF([test x$patch_avail = xno], [
93                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
94                 ])
95         ])
96 ])
97
98 #
99 # LB_CONDITIONAL_LDISKFS
100 #
101 AC_DEFUN([LB_CONFIG_LDISKFS],
102 [
103 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
104 # However we continue to support this option through Lustre 2.5.
105 AC_ARG_WITH([ldiskfs],
106         [],
107         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
108         AS_IF([test x$withval != xyes -a x$withval != xno],
109                 [AC_MSG_ERROR([the ldiskfs option is deprecated, and
110                         no longer supports paths to external ldiskfs source])])
111         ]
112 )
113
114 AC_ARG_ENABLE([ldiskfs],
115         [AS_HELP_STRING([--disable-ldiskfs],
116                 [disable ldiskfs osd (default is enable)])],
117         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
118                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
119         [AS_IF([test "${with_ldiskfs+set}" = set],
120                 [enable_ldiskfs=$with_ldiskfs],
121                 [enable_ldiskfs=maybe])
122         ]
123 )
124
125 AS_IF([test x$enable_server = xno],
126         [AS_CASE([$enable_ldiskfs],
127                 [maybe], [enable_ldiskfs=no],
128                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
129         )]
130 )
131
132 AS_IF([test x$enable_ldiskfs != xno],[
133         # In the future, we chould change enable_ldiskfs from maybe to
134         # either yes or no based on additional tests, e.g.  whether a patch
135         # set is available for the detected kernel.  For now, we just always
136         # set it to "yes".
137         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
138
139         LDISKFS_LINUX_SERIES
140         LDISKFS_AC_PATCH_PROGRAM
141         LB_EXT4_SRC_DIR
142         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
143         LB_EXT_PBLOCK
144         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
145         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
146         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
147         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
148         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
149 ])
150
151 AC_MSG_CHECKING([whether to build ldiskfs])
152 AC_MSG_RESULT([$enable_ldiskfs])
153
154 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
155 ])
156
157 #
158 # LB_VALIDATE_EXT4_SRC_DIR
159 #
160 # Spot check the existance of several source files common to ext4.
161 # Detecting this at configure time allows us to avoid a potential build
162 # failure and provide a useful error message to explain what is wrong.
163 #
164 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR],
165 [
166 if test x$EXT4_SRC_DIR = x; then
167         enable_ldiskfs_build='no'
168 else
169         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
170                 enable_ldiskfs_build='no'
171                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
172         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
173                 enable_ldiskfs_build='no'
174                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
175         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
176                 enable_ldiskfs_build='no'
177                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
178         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
179                 enable_ldiskfs_build='no'
180                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
181 fi
182
183 if test x$enable_ldiskfs_build = xno; then
184         enable_ldiskfs='no'
185
186         AC_MSG_WARN([
187
188 Disabling ldiskfs support because complete ext4 source does not exist.
189
190 If you are building using kernel-devel packages and require ldiskfs
191 server support then ensure that the matching kernel-debuginfo-common
192 and kernel-debuginfo-common-<arch> packages are installed.
193
194 ])
195
196 fi
197 ])
198
199 #
200 # LB_EXT4_SRC_DIR
201 #
202 # Determine the location of the ext4 source code.  It it required
203 # for several configure tests and to build ldiskfs.
204 #
205 AC_DEFUN([LB_EXT4_SRC_DIR],
206 [
207 # Kernel ext source located with devel headers
208 linux_src=$LINUX
209 if test -e "$linux_src/fs/ext4/super.c"; then
210         EXT4_SRC_DIR=$linux_src/fs/ext4
211 else
212         # Kernel ext source provided by kernel-debuginfo-common package
213         linux_src=$(ls -1d /usr/src/debug/*/linux-$LINUXRELEASE \
214                 2>/dev/null | tail -1)
215         if test -e "$linux_src/fs/ext4/super.c"; then
216                 EXT4_SRC_DIR=$linux_src/fs/ext4
217         else
218                 EXT4_SRC_DIR=
219         fi
220 fi
221
222 AC_MSG_CHECKING([ext4 source directory])
223 AC_MSG_RESULT([$EXT4_SRC_DIR])
224 AC_SUBST(EXT4_SRC_DIR)
225
226 LB_VALIDATE_EXT4_SRC_DIR
227 ])
228
229 #
230 # LB_DEFINE_E2FSPROGS_NAMES
231 #
232 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
233 #
234 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
235 [
236 AC_ARG_WITH([ldiskfsprogs],
237         AC_HELP_STRING([--with-ldiskfsprogs],
238                        [use alternate names for ldiskfs-enabled e2fsprogs]),
239         [],[withval='no'])
240
241 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
242 if test x$withval = xyes ; then
243         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
244         E2FSPROGS="ldiskfsprogs"
245         MKE2FS="mkfs.ldiskfs"
246         DEBUGFS="debugfs.ldiskfs"
247         TUNE2FS="tunefs.ldiskfs"
248         E2LABEL="label.ldiskfs"
249         DUMPE2FS="dumpfs.ldiskfs"
250         E2FSCK="fsck.ldiskfs"
251         PFSCK="pfsck.ldiskfs"
252         AC_MSG_RESULT([enabled])
253 else
254         E2FSPROGS="e2fsprogs"
255         MKE2FS="mke2fs"
256         DEBUGFS="debugfs"
257         TUNE2FS="tune2fs"
258         E2LABEL="e2label"
259         DUMPE2FS="dumpe2fs"
260         E2FSCK="e2fsck"
261         PFSCK="fsck"
262         AC_MSG_RESULT([disabled])
263 fi
264
265 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
266 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
267 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
268 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
269 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
270 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
271 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
272 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
273
274 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
275 AC_SUBST([MKE2FS], [$MKE2FS])
276 AC_SUBST([DEBUGFS], [$DEBUGFS])
277 AC_SUBST([TUNE2FS], [$TUNE2FS])
278 AC_SUBST([E2LABEL], [$E2LABEL])
279 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
280 AC_SUBST([E2FSCK], [$E2FSCK])
281 AC_SUBST([PFSCK], [$PFSCK])
282 ])