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