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