Whamcloud - gitweb
LU-1199 build: Untangle the ldiskfs build system from lustre
[fs/lustre-release.git] / ldiskfs / build / autoconf / ldiskfs.m4
1
2 #
3 # LB_LDISKFS_EXT_DIR
4 #
5 # Determine the location of the ext4 source code.  It is required
6 # for several configure tests and to build ldiskfs.
7 #
8 AC_DEFUN([LB_LDISKFS_EXT_DIR],
9 [
10 # Kernel ext source located with devel headers
11 linux_src=$LINUX
12 if test -e "$linux_src/fs/ext4/super.c"; then
13         EXT_DIR=$linux_src/fs/ext4
14 else
15         # Kernel ext source provided by kernel-debuginfo-common package
16         linux_src=$(ls -1d /usr/src/debug/*/linux-$LINUXRELEASE \
17                 2>/dev/null | tail -1)
18         if test -e "$linux_src/fs/ext4/super.c"; then
19                 EXT_DIR=$linux_src/fs/ext4
20         else
21                 EXT_DIR=
22         fi
23 fi
24
25 AC_MSG_CHECKING([ext4 source directory])
26 AC_MSG_RESULT([$EXT_DIR])
27 AC_SUBST(EXT_DIR)
28 ])
29
30 #
31 # LB_LDISKFS_EXT_SOURCE
32 #
33 # Spot check the existance of several source files common to ext4.
34 # Detecting this at configure time allows us to avoid a potential build
35 # failure and provide a useful error message to explain what is wrong.
36 #
37 AC_DEFUN([LB_LDISKFS_EXT_SOURCE],
38 [
39 if test x$EXT_DIR = x; then
40         enable_ldiskfs_build='no'
41 else
42         LB_CHECK_FILE([$EXT_DIR/dir.c], [], [
43                 enable_ldiskfs_build='no'
44                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
45         LB_CHECK_FILE([$EXT_DIR/file.c], [], [
46                 enable_ldiskfs_build='no'
47                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
48         LB_CHECK_FILE([$EXT_DIR/inode.c], [], [
49                 enable_ldiskfs_build='no'
50                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
51         LB_CHECK_FILE([$EXT_DIR/super.c], [], [
52                 enable_ldiskfs_build='no'
53                 AC_MSG_WARN([ext4 must exist for ldiskfs build])])
54 fi
55
56 if test x$enable_ldiskfs_build = xno; then
57         enable_server='no'
58         enable_ldiskfs_build='no'
59         with_ldiskfs='no'
60         LDISKFS_SUBDIR=
61
62         AC_MSG_WARN([
63
64 Disabling server because complete ext4 source does not exist.
65
66 If you are building using kernel-devel packages and require ldiskfs
67 server support then ensure that the matching kernel-debuginfo-common
68 and kernel-debuginfo-common-<arch> packages are installed.
69
70 ])
71
72 fi
73 ])
74
75 #
76 # LB_LDISKFS_DEFINE_OPTIONS
77 #
78 # Enable config options related to ldiskfs.  These are used by ldiskfs,
79 # lvfs, and the osd-ldiskfs code (which includes ldiskfs headers.)
80 #
81 AC_DEFUN([LB_LDISKFS_DEFINE_OPTIONS],
82 [
83 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
84
85 with_ldiskfs_pdo=no
86 case $LINUXRELEASE in
87 2.6.32*)
88         if test x$RHEL_KERNEL = xyes; then
89                 with_ldiskfs_pdo=yes
90                 AC_DEFINE(HAVE_LDISKFS_PDO, 1, [have ldiskfs PDO patch])
91         fi
92         if test x$SUSE_KERNEL = xyes; then
93                 with_ldiskfs_pdo=yes
94                 AC_DEFINE(HAVE_LDISKFS_PDO, 1, [have ldiskfs PDO patch])
95         fi
96         ;;
97 esac
98 LB_LDISKFS_JBD2_JOURNAL_CALLBACK_SET
99
100 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1,
101         [enable extended attributes for ldiskfs])
102 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1,
103         [enable posix acls for ldiskfs])
104 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1,
105         [enable fs security for ldiskfs])
106 AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1,
107         [enable posix acls for ldiskfs])
108 AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1,
109         [enable extented attributes for ldiskfs])
110 AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1,
111         [enable fs security for ldiskfs])
112 ])
113
114 #
115 # Check for jbd2_journal_callback_set(), which is needed for commit
116 # callbacks.  When LU-433 lands jbd2_journal_callback_set() will only
117 # remain for legacy reasons and AC_MSG_ERROR can be removed.
118 #
119 AC_DEFUN([LB_LDISKFS_JBD2_JOURNAL_CALLBACK_SET],
120 [
121         LB_CHECK_SYMBOL_EXPORT([jbd2_journal_callback_set],
122                 [fs/jbd2/journal.c],
123                 [AC_DEFINE(HAVE_JBD2_JOURNAL_CALLBACK_SET, 1,
124                         [kernel exports jbd2_journal_callback_set])])
125 ])
126
127
128 AC_DEFUN([LB_LDISKFS_SYMVERS],
129 [
130 AC_MSG_CHECKING([ldiskfs module symbols])
131 if test -r $LDISKFS_OBJ/Module.symvers; then
132         LDISKFS_SYMBOLS=Module.symvers
133 elif test -r $LDISKFS_OBJ/Modules.symvers; then
134         LDISKFS_SYMBOLS=Modules.symvers
135 elif test -r $LDISKFS_OBJ/ldiskfs/Module.symvers; then
136         LDISKFS_SYMBOLS=Module.symvers
137 elif test -r $LDISKFS_OBJ/ldiskfs/Modules.symvers; then
138         LDISKFS_SYMBOLS=Modules.symvers
139 else
140         LDISKFS_SYMBOLS=$SYMVERFILE
141 fi
142
143 AC_MSG_RESULT([$LDISKFS_SYMBOLS])
144 AC_SUBST(LDISKFS_SYMBOLS)
145 ])
146
147 AC_DEFUN([LB_LDISKFS_RELEASE],
148 [
149 AC_MSG_CHECKING([ldiskfs source release])
150 if test -r $LDISKFS_OBJ/config.h; then
151         tmp_flags="$EXTRA_KCFLAGS"
152         EXTRA_KCFLAGS="-I$LDISKFS_DIR $EXTRA_KCFLAGS"
153         LB_LINUX_TRY_MAKE([
154                 #undef PACKAGE_NAME
155                 #undef PACKAGE_TARNAME
156                 #undef PACKAGE_VERSION
157                 #undef PACKAGE_STRING
158                 #undef PACKAGE_BUGREPORT
159                 #undef PACKAGE
160                 #undef VERSION
161                 #undef STDC_HEADERS
162
163                 #include <$LDISKFS_OBJ/config.h>
164         ],[
165                 char *LDISKFS_RELEASE;
166                 LDISKFS_RELEASE=VERSION;
167         ],[
168                 $makerule LUSTRE_KERNEL_TEST=conftest.i
169         ],[
170                 test -s build/conftest.i
171         ],[
172                 eval $(grep "LDISKFS_RELEASE=" build/conftest.i)
173         ],[
174                 AC_MSG_RESULT([unknown])
175                 AC_MSG_ERROR([Could not preprocess test program.])
176         ])
177         EXTRA_KCFLAGS="$tmp_flags"
178         rm build/conftest.i
179 elif test -r $LDISKFS_DIR/configure.ac; then
180         LDISKFS_RELEASE=$(awk '/AC\_INIT/ { print [$]3 }' \
181                  $LDISKFS_DIR/configure.ac | tr ',' '\n')
182 else
183         AC_MSG_RESULT([unknown])
184         AC_MSG_ERROR([Could not locate config.h, META, or configure.ac to check release.])
185 fi
186
187 if test x$LDISKFS_RELEASE = x; then
188         AC_MSG_RESULT([unknown])
189         AC_MSG_ERROR([Could not determine ldiskfs release.])
190 fi
191
192 AC_MSG_RESULT([$LDISKFS_RELEASE])
193 AC_SUBST(LDISKFS_RELEASE)
194 ])
195
196 AC_DEFUN([LB_LDISKFS_SERIES],
197 [
198 if $1; then
199         AC_MSG_CHECKING([which ldiskfs series to use])
200         case $LINUXRELEASE in
201         2.6.18*)
202                 if test x$RHEL_KERNEL = xyes; then
203                         LDISKFS_SERIES="2.6-rhel5-ext4.series"
204                 fi
205                 ;;
206         2.6.32*)
207                 if test x$RHEL_KERNEL = xyes; then
208                         LDISKFS_SERIES="2.6-rhel6.series"
209                 fi
210                 if test x$SUSE_KERNEL = xyes; then
211                         LDISKFS_SERIES="2.6-sles11.series"
212                 fi
213                 ;;
214         *)
215                 AC_MSG_WARN([Unknown kernel version $LINUXRELEASE])
216                 LDISKFS_SERIES=
217                 ;;
218         esac
219         AC_MSG_RESULT([$LDISKFS_SERIES])
220 else
221         LDISKFS_SERIES=
222 fi
223 AC_SUBST(LDISKFS_SERIES)
224 ])