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