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