Whamcloud - gitweb
LU-2686 kernel: Kernel update for 3.7.2-201.fc18
[fs/lustre-release.git] / config / lustre-build-ldiskfs.m4
1 #
2 # LB_PATH_LDISKFS
3 #
4 # --without-ldiskfs   - Disable ldiskfs support.
5 # --with-ldiskfs=no
6 #
7 # --with-ldiskfs      - Enable ldiskfs support and attempt to autodetect the
8 # --with-ldiskfs=yes    headers in one of the following places in this order:
9 #                       * ./ldiskfs
10 #                       * /usr/src/ldiskfs-*/$LINUXRELEASE
11 #                       * ../ldiskfs
12 #
13 # --with-ldiskfs=path - Enable ldiskfs support and use the headers in the
14 #                       provided path.  No autodetection is performed.
15 #
16 # --with-ldiskfs-obj  - When ldiskfs support is enabled the object directory
17 #                       will be based on the --with-ldiskfs directory.  If
18 #                       this is detected incorrectly it can be explicitly
19 #                       specified using this option.
20 #
21 # NOTE: As with all external packages ldiskfs is expected to already be
22 # configured and built.  However, if the ldiskfs tree is located in-tree
23 # (./ldiskfs) then it will be configured and built recursively as part of
24 # the lustre build system.
25 #
26 # NOTE: The lustre and in-tree ldiskfs build systems both make use these
27 # macros.  This is undesirable and confusing at best, it is potentially
28 # danagerous at worst.  The ldiskfs build system should be entirely stand
29 # alone without dependency on the lustre build system.
30 #
31 AC_DEFUN([LB_PATH_LDISKFS],
32 [
33 AC_ARG_WITH([ldiskfs],
34         AC_HELP_STRING([--with-ldiskfs=path], [set path to ldiskfs source]),
35         [],[
36                 if test x$enable_server = xyes && test x$enable_dist = xno; then
37                         with_ldiskfs='yes'
38                 else
39                         with_ldiskfs='no'
40                 fi
41         ])
42
43 case x$with_ldiskfs in
44         xno)
45                 LDISKFS_DIR=
46                 ;;
47         xyes)
48                 LDISKFS_DIR=
49
50                 # Check ./ldiskfs
51                 ldiskfs_src=$PWD/ldiskfs
52                 if test -e "$ldiskfs_src"; then
53                         LDISKFS_DIR=$(readlink -f $ldiskfs_src)
54                 else
55                         # Check /usr/src/ldiskfs-*/$LINUXRELEASE
56                         ldiskfs_src=$(ls -1d \
57                                 /usr/src/ldiskfs-*/$LINUXRELEASE \
58                                 2>/dev/null | tail -1)
59                         if test -e "$ldiskfs_src"; then
60                                 LDISKFS_DIR=$(readlink -f $ldiskfs_src)
61                         else
62                                 # Check ../ldiskfs
63                                 ldiskfs_src=$PWD/../ldiskfs
64                                 if test -e "$ldiskfs_src"; then
65                                         LDISKFS_DIR=$(readlink -f $ldiskfs_src)
66                                 else
67                                         # Disable ldiskfs failed to detect
68                                         with_ldiskfs='no'
69                                 fi
70                         fi
71                 fi
72
73                 ;;
74         *)
75                 LDISKFS_DIR=$(readlink -f $with_ldiskfs)
76                 with_ldiskfs='yes'
77                 ;;
78 esac
79
80 AC_MSG_CHECKING([whether to enable ldiskfs])
81 AC_MSG_RESULT([$with_ldiskfs])
82
83 AC_ARG_WITH([ldiskfs-obj],
84         AC_HELP_STRING([--with-ldiskfs-obj=path],[set path to ldiskfs objects]),
85         [
86                 if test x$with_ldiskfs = xyes; then
87                         LDISKFS_OBJ="$withval"
88                 fi
89         ],[
90                 if test x$with_ldiskfs = xyes; then
91                         LDISKFS_OBJ=$LDISKFS_DIR
92                 fi
93         ])
94
95 if test x$with_ldiskfs = xyes; then
96         AC_MSG_CHECKING([ldiskfs source directory])
97         AC_MSG_RESULT([$LDISKFS_DIR])
98         AC_SUBST(LDISKFS_DIR)
99
100         AC_MSG_CHECKING([ldiskfs object directory])
101         AC_MSG_RESULT([$LDISKFS_OBJ])
102         AC_SUBST(LDISKFS_OBJ)
103
104         LB_LDISKFS_SYMVERS
105         LB_LDISKFS_EXT_DIR
106         LB_LDISKFS_BUILD
107         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
108 fi
109
110 #
111 # LDISKFS_DEVEL is required because when using the ldiskfs-devel package the
112 # ext4 source will be fully patched to ldiskfs.  When building with the
113 # in-tree ldiskfs this patching this will occur after the configure step.
114 # We needed a way to determine if we should check the patched or unpatched
115 # source files.
116 #
117 # Longer term this could be removed by moving the ldiskfs patching in to
118 # the configure phase.  Or better yet ldiskfs could be updated to generate
119 # a ldiskfs_config.h which clearly defines how it was built.  This can
120 # then be directly included by Lustre to avoid all the autoconf guess work.
121 # For an example of this behavior consult the lustre/zfs build integration.
122 #
123 AM_CONDITIONAL(LDISKFS_DEVEL, \
124         test x$LDISKFS_DIR = x$(readlink -f $PWD/ldiskfs) || \
125         test x$LDISKFS_DIR = x$(readlink -f $PWD/../ldiskfs))
126
127 AM_CONDITIONAL(LDISKFS_BUILD, test x$enable_ldiskfs_build = xyes)
128 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs = xyes)
129
130 if test -e "$PWD/ldiskfs"; then
131         LDISKFS_DIST_SUBDIR="ldiskfs"
132         AC_SUBST(LDISKFS_DIST_SUBDIR)
133         AC_CONFIG_SUBDIRS("ldiskfs")
134 fi
135 ])
136
137 #
138 # LB_LDISKFS_EXT_DIR
139 #
140 # Determine the location of the ext4 source code.  It it required
141 # for several configure tests and to build ldiskfs.
142 #
143 AC_DEFUN([LB_LDISKFS_EXT_DIR],
144 [
145 # Kernel ext source located with devel headers
146 linux_src=$LINUX
147 if test -e "$linux_src/fs/ext4/super.c"; then
148         EXT_DIR=$linux_src/fs/ext4
149 else
150         # Kernel ext source provided by kernel-debuginfo-common package
151         linux_src=$(ls -1d /usr/src/debug/*/linux-$LINUXRELEASE \
152                 2>/dev/null | tail -1)
153         if test -e "$linux_src/fs/ext4/super.c"; then
154                 EXT_DIR=$linux_src/fs/ext4
155         else
156                 EXT_DIR=
157         fi
158 fi
159
160 AC_MSG_CHECKING([ext4 source directory])
161 AC_MSG_RESULT([$EXT_DIR])
162 AC_SUBST(EXT_DIR)
163 ])
164
165 #
166 # LB_LDISKFS_EXT_SOURCE
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_LDISKFS_EXT_SOURCE],
173 [
174 if test x$EXT_DIR = x; then
175         enable_ldiskfs_build='no'
176 else
177         LB_CHECK_FILE([$EXT_DIR/dir.c], [], [
178                 enable_ldiskfs_build='no'
179                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
180         LB_CHECK_FILE([$EXT_DIR/file.c], [], [
181                 enable_ldiskfs_build='no'
182                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
183         LB_CHECK_FILE([$EXT_DIR/inode.c], [], [
184                 enable_ldiskfs_build='no'
185                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
186         LB_CHECK_FILE([$EXT_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_build='no'
193         with_ldiskfs='no'
194         LDISKFS_SUBDIR=
195
196         AC_MSG_WARN([
197
198 Disabling server because complete ext4 source does not exist.
199
200 If you are building using kernel-devel packages and require ldiskfs
201 server support then ensure that the matching kernel-debuginfo-common
202 and kernel-debuginfo-common-<arch> packages are installed.
203
204 ])
205
206 fi
207 ])
208
209 #
210 # Optionally configure/make the ldiskfs sources.  If the sources are
211 # determined to reside in-tree this feature will automatically be
212 # enabled.  If the sources are not in-tree it will be disabled.
213 # Use --enable-ldiskfs-build or --disable-ldiskfs-build if you need
214 # to override this behavior.
215 #
216 AC_DEFUN([LB_LDISKFS_BUILD],
217 [
218 AC_ARG_ENABLE([ldiskfs-build],
219         AC_HELP_STRING([--enable-ldiskfs-build],
220                 [enable ldiskfs configure/make]),
221         [], [
222                 LDISKFS_DIR_INTREE=$(readlink -f $PWD/ldiskfs)
223                 if test x$LDISKFS_DIR = x$LDISKFS_DIR_INTREE; then
224                         enable_ldiskfs_build='yes'
225                 else
226                         enable_ldiskfs_build='no'
227                 fi
228         ])
229
230 AC_MSG_CHECKING([whether to build ldiskfs])
231 if test x$enable_ldiskfs_build = xyes; then
232         AC_MSG_RESULT([$enable_ldiskfs_build])
233         LDISKFS_SUBDIR="ldiskfs"
234
235         LB_CHECK_FILE([$LDISKFS_DIR/configure], [], [
236                 AC_MSG_ERROR([Complete ldiskfs build system must exist])])
237         LB_LDISKFS_EXT_SOURCE
238
239         AC_SUBST(LDISKFS_SUBDIR)
240 else
241         enable_ldiskfs_build='no'
242         AC_MSG_RESULT([$enable_ldiskfs_build])
243 fi
244 ])
245
246 AC_DEFUN([LB_LDISKFS_SYMVERS],
247 [
248 AC_MSG_CHECKING([ldiskfs module symbols])
249 if test -r $LDISKFS_OBJ/Module.symvers; then
250         LDISKFS_SYMBOLS=Module.symvers
251 elif test -r $LDISKFS_OBJ/Modules.symvers; then
252         LDISKFS_SYMBOLS=Modules.symvers
253 elif test -r $LDISKFS_OBJ/ldiskfs/Module.symvers; then
254         LDISKFS_SYMBOLS=Module.symvers
255 elif test -r $LDISKFS_OBJ/ldiskfs/Modules.symvers; then
256         LDISKFS_SYMBOLS=Modules.symvers
257 else
258         LDISKFS_SYMBOLS=$SYMVERFILE
259 fi
260
261 AC_MSG_RESULT([$LDISKFS_SYMBOLS])
262 AC_SUBST(LDISKFS_SYMBOLS)
263 ])
264
265 #
266 # LB_DEFINE_E2FSPROGS_NAMES
267 #
268 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
269 #
270 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
271 [
272 AC_ARG_WITH([ldiskfsprogs],
273         AC_HELP_STRING([--with-ldiskfsprogs],
274                        [use alternate names for ldiskfs-enabled e2fsprogs]),
275         [],[withval='no'])
276
277 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
278 if test x$withval = xyes ; then
279         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
280         E2FSPROGS="ldiskfsprogs"
281         MKE2FS="mkfs.ldiskfs"
282         DEBUGFS="debugfs.ldiskfs"
283         TUNE2FS="tunefs.ldiskfs"
284         E2LABEL="label.ldiskfs"
285         DUMPE2FS="dumpfs.ldiskfs"
286         E2FSCK="fsck.ldiskfs"
287         PFSCK="pfsck.ldiskfs"
288         AC_MSG_RESULT([enabled])
289 else
290         E2FSPROGS="e2fsprogs"
291         MKE2FS="mke2fs"
292         DEBUGFS="debugfs"
293         TUNE2FS="tune2fs"
294         E2LABEL="e2label"
295         DUMPE2FS="dumpe2fs"
296         E2FSCK="e2fsck"
297         PFSCK="fsck"
298         AC_MSG_RESULT([disabled])
299 fi
300
301 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
302 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
303 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
304 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
305 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
306 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
307 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
308 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
309
310 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
311 AC_SUBST([MKE2FS], [$MKE2FS])
312 AC_SUBST([DEBUGFS], [$DEBUGFS])
313 AC_SUBST([TUNE2FS], [$TUNE2FS])
314 AC_SUBST([E2LABEL], [$E2LABEL])
315 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
316 AC_SUBST([E2FSCK], [$E2FSCK])
317 AC_SUBST([PFSCK], [$PFSCK])
318 ])