blob: ab7b09cd83ba870732667923c99ca2bb5fa6312d [file] [log] [blame]
Miklos Szeredi918f0ad2007-12-12 11:53:38 +00001AC_INIT(fuse-kernel, 2.7.2)
Miklos Szeredi51ec1032004-11-10 11:52:26 +00002AC_CONFIG_HEADERS([config.h])
3
Miklos Szeredi3a6ea062004-11-11 10:33:58 +00004AC_PROG_INSTALL
5
Miklos Szeredibac4c772005-11-23 13:35:54 +00006runver=`uname -r`
Miklos Szeredi6cf952a2006-09-30 07:39:33 +00007bad_kernel_version=no
Miklos Szeredibac4c772005-11-23 13:35:54 +00008ENABLE_FUSE_MODULE=y
Miklos Szeredi3cc8a262005-11-29 11:04:27 +00009KERNELCFLAGS=
Miklos Szeredibac4c772005-11-23 13:35:54 +000010
Miklos Szeredi51ec1032004-11-10 11:52:26 +000011kernelsrc=
Miklos Szeredi2c650412005-10-26 15:12:59 +000012kernelbuild=
Miklos Szeredi51ec1032004-11-10 11:52:26 +000013AC_ARG_WITH(kernel,
14 [ --with-kernel=PATH Specify location of kernel source ],
Miklos Szeredi2c650412005-10-26 15:12:59 +000015 [kernelsrc="$withval"; kernelbuild="$withval"])
16AC_ARG_WITH(kernel-build,
17 [ --with-kernel-build=PATH Specify location of kernel build ],
18 [kernelbuild="$withval"])
Miklos Szeredi8c7da232005-01-09 12:27:41 +000019AC_ARG_ENABLE(kernel-module,
20 [ --enable-kernel-module Compile kernel module ])
21
Miklos Szeredibac4c772005-11-23 13:35:54 +000022if test -z "$enable_kernel_module" -a -z "$kernelbuild" && echo "$runver" | grep -q "^2.6"; then
23 checkmodule=no
24 AC_MSG_CHECKING([if FUSE is loaded as a module])
25 if cat /proc/modules | grep -q "^fuse "; then
26 AC_MSG_RESULT([yes])
27 checkmodule=yes
28 else
29 AC_MSG_RESULT([no])
30 AC_MSG_CHECKING([if FUSE module is built into the kernel])
31 if test -e /sys/class/misc/fuse; then
32 AC_MSG_RESULT([yes])
33 ENABLE_FUSE_MODULE=n
34 else
35 AC_MSG_RESULT([no])
36 checkmodule=yes
Miklos Szeredi8c7da232005-01-09 12:27:41 +000037 fi
38 fi
Miklos Szeredibac4c772005-11-23 13:35:54 +000039 if test "$checkmodule" = yes; then
40 AC_MSG_CHECKING([if FUSE module is from official kernel])
Miklos Szeredi15af1b82006-01-16 17:52:24 +000041 if test ! -f /lib/modules/${runver}/kernel/fs/fuse/fuse.ko; then
42 AC_MSG_RESULT([no])
43 elif fgrep -q "fuse distribution version: " /lib/modules/${runver}/kernel/fs/fuse/fuse.ko 2> /dev/null; then
Miklos Szeredibac4c772005-11-23 13:35:54 +000044 AC_MSG_RESULT([no])
45 else
46 AC_MSG_RESULT([yes])
47 ENABLE_FUSE_MODULE=n
48 fi
Miklos Szeredi8c7da232005-01-09 12:27:41 +000049 fi
50fi
Miklos Szeredibac4c772005-11-23 13:35:54 +000051
52if test "$ENABLE_FUSE_MODULE" = y; then
53 AC_MSG_CHECKING([kernel source directory])
54 if test -z "$kernelsrc"; then
55 kernelbuild=
56 sourcelink=/lib/modules/${runver}/source
57 buildlink=/lib/modules/${runver}/build
58
59 if test -e $sourcelink; then
60 kernelsrc=`(cd $sourcelink; /bin/pwd)`
61 fi
62 if test -e $buildlink; then
63 kernelbuild=`(cd $buildlink; /bin/pwd)`
64 fi
65 if test -z "$kernelsrc"; then
66 kernelsrc=$kernelbuild
67 fi
68 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
69 AC_MSG_RESULT([Not found])
70 AC_MSG_ERROR([
71 *** Please specify the location of the kernel source with
72 *** the '--with-kernel=SRCDIR' option])
73 fi
74 fi
75 AC_MSG_RESULT([$kernelsrc])
76 AC_MSG_CHECKING([kernel build directory])
77 AC_MSG_RESULT([$kernelbuild])
78
79 AC_MSG_CHECKING([kernel source version])
Miklos Szeredi3ded1a32006-08-18 18:43:50 +000080 if test -r $kernelbuild/include/linux/version.h && fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
Miklos Szeredibac4c772005-11-23 13:35:54 +000081 kernsrcver=`(echo "#include <linux/version.h>"; echo "kernsrcver=UTS_RELEASE") | cpp -I $kernelbuild/include | grep "^kernsrcver=" | cut -d \" -f 2`
Miklos Szeredi3ded1a32006-08-18 18:43:50 +000082 elif test -r $kernelbuild/include/linux/utsrelease.h && fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
83 kernsrcver=`(echo "#include <linux/utsrelease.h>"; echo "kernsrcver=UTS_RELEASE") | cpp -I $kernelbuild/include | grep "^kernsrcver=" | cut -d \" -f 2`
Miklos Szeredibac4c772005-11-23 13:35:54 +000084 fi
85 if test -z "$kernsrcver"; then
86 AC_MSG_RESULT([Not found])
87 AC_MSG_ERROR([
88 *** Cannot determine the version of the linux kernel source. Please
89 *** prepare the kernel before running this script])
90 fi
91 AC_MSG_RESULT([$kernsrcver])
Miklos Szeredibac4c772005-11-23 13:35:54 +000092 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
93 AC_SUBST(kernelsrc)
Miklos Szeredibac4c772005-11-23 13:35:54 +000094 AC_SUBST(kmoduledir)
95
Miklos Szeredi6cf952a2006-09-30 07:39:33 +000096 if echo "$kernsrcver" | egrep -q ["^(2.4|2.6.[0-8]([^0-9]|\$))"]; then
97 bad_kernel_version=yes
98 AC_MSG_NOTICE([
99NOTE: Disabled building the kernel module, because this release only
100NOTE: supports Linux versions 2.6.9 or later. You can use the kernel
101NOTE: module from an earlier FUSE release with the library from this
102NOTE: release.])
Miklos Szeredibac4c772005-11-23 13:35:54 +0000103 else
104 fuse_configured=no
105 kernel_autoconf=$kernelbuild/include/linux/autoconf.h
106 AC_MSG_CHECKING([if FUSE is configured in the kernel])
107 if test -f $kernel_autoconf; then
108 if grep -q "^#define CONFIG_FUSE_FS 1" $kernel_autoconf || grep -q "^#define CONFIG_FUSE_FS_MODULE 1" $kernel_autoconf; then
109 fuse_configured=yes
110 fi
111 fi
112 AC_MSG_RESULT([$fuse_configured])
113 if test -z "$enable_kernel_module" -a "$fuse_configured" = yes; then
114 ENABLE_FUSE_MODULE=n
115 fi
116 fi
117fi
118
119if test "$ENABLE_FUSE_MODULE" = n; then
Miklos Szeredi6cf952a2006-09-30 07:39:33 +0000120 AC_MSG_NOTICE([
121NOTE: Detected that FUSE is already present in the kernel, so
122NOTE: building of kernel module is disabled. To force building
123NOTE: of kernel module use the '--enable-kernel-module' option.])
Miklos Szeredibac4c772005-11-23 13:35:54 +0000124fi
125
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000126if test "$enable_kernel_module" = no; then
127 ENABLE_FUSE_MODULE=n
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000128fi
Miklos Szeredi6cf952a2006-09-30 07:39:33 +0000129if test "$bad_kernel_version" = yes; then
130 ENABLE_FUSE_MODULE=n
131fi
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000132
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000133AC_SUBST(ENABLE_FUSE_MODULE)
134
135if test "$ENABLE_FUSE_MODULE" = y; then
Miklos Szeredi15af1b82006-01-16 17:52:24 +0000136 AC_MSG_CHECKING([if kernel defines kzalloc function])
137 if egrep -qw "kzalloc" $kernelsrc/include/linux/slab.h; then
138 AC_DEFINE(HAVE_KZALLOC, 1, [kzalloc() is defined])
139 AC_MSG_RESULT([yes])
140 else
141 AC_MSG_RESULT([no])
142 fi
143
144 AC_MSG_CHECKING([if kernel defines fs_subsys])
145 if egrep -qw "fs_subsys" $kernelsrc/include/linux/fs.h; then
146 AC_DEFINE(HAVE_FS_SUBSYS, 1, [fs_subsys is defined])
147 AC_MSG_RESULT([yes])
148 else
149 AC_MSG_RESULT([no])
150 fi
Miklos Szeredie5183742005-02-02 11:14:04 +0000151
Miklos Szeredid6f8db72006-10-13 09:54:24 +0000152 AC_MSG_CHECKING([whether lookup_instantiate_filp is defined])
153 if test -f $kernelsrc/include/linux/namei.h && egrep -q "lookup_instantiate_filp" $kernelsrc/include/linux/namei.h; then
154 AC_DEFINE(HAVE_LOOKUP_INSTANTIATE_FILP, 1, [lookup_instantiate_filp() is defined])
155 AC_MSG_RESULT([yes])
156 else
157 AC_MSG_RESULT([no])
158 fi
159
Miklos Szeredi856e5cb2006-10-11 05:44:55 +0000160 AC_MSG_CHECKING([if umount_begin is passed a vfsmount])
161 if egrep -q "\(\*umount_begin\) *\(struct vfsmount \*" $kernelsrc/include/linux/fs.h; then
162 AC_DEFINE(UMOUNT_BEGIN_VFSMOUNT, 1, [umount_begin is passed a vfsmount])
163 AC_MSG_RESULT([yes])
164 else
165 AC_MSG_RESULT([no])
166 fi
167
Miklos Szeredid6f8db72006-10-13 09:54:24 +0000168 AC_MSG_CHECKING([if inode has i_blksize field])
169 if egrep -qw "i_blksize" $kernelsrc/include/linux/fs.h; then
170 AC_DEFINE(HAVE_I_BLKSIZE, 1, [inode has i_blksize field])
171 AC_MSG_RESULT([yes])
172 else
173 AC_MSG_RESULT([no])
174 fi
175 AC_MSG_CHECKING([if inode has i_private field])
176 if egrep -qw "i_private" $kernelsrc/include/linux/fs.h; then
177 AC_DEFINE(HAVE_I_PRIVATE, 1, [inode has i_private field])
Miklos Szeredid9079a72005-10-26 15:29:06 +0000178 AC_MSG_RESULT([yes])
179 else
180 AC_MSG_RESULT([no])
181 fi
Miklos Szeredi47910d72007-02-03 11:28:17 +0000182 AC_MSG_CHECKING([if inode has i_mutex field ])
183 if egrep -qw "i_mutex" $kernelsrc/include/linux/fs.h; then
184 AC_DEFINE(HAVE_I_MUTEX, 1, [inode has i_mutex field])
185 AC_MSG_RESULT([yes])
186 else
187 AC_MSG_RESULT([no])
188 fi
189 AC_MSG_CHECKING([if kernel has mutex.h ])
190 if test -f $kernelsrc/include/linux/mutex.h; then
191 AC_DEFINE(HAVE_MUTEX_H, 1, [kernel has mutex.h])
192 AC_MSG_RESULT([yes])
193 else
194 AC_MSG_RESULT([no])
195 fi
Miklos Szeredi2b3a22f2007-06-19 09:23:02 +0000196 AC_MSG_CHECKING([if kernel has exportfs.h ])
197 if test -f $kernelsrc/include/linux/exportfs.h; then
198 AC_DEFINE(HAVE_EXPORTFS_H, 1, [kernel has exportfs.h])
199 AC_MSG_RESULT([yes])
200 else
201 AC_MSG_RESULT([no])
202 fi
Miklos Szeredi2a53c582007-03-14 09:32:00 +0000203 AC_MSG_CHECKING([if kernel has BLOCK option ])
Miklos Szeredi2b3a22f2007-06-19 09:23:02 +0000204 if test -f $kernelsrc/block/Kconfig && egrep -q "config *BLOCK" $kernelsrc/block/Kconfig; then
Miklos Szeredi2a53c582007-03-14 09:32:00 +0000205 AC_DEFINE(HAVE_CONFIG_BLOCK, 1, [kernel has BLOCK option])
206 AC_MSG_RESULT([yes])
207 else
208 AC_MSG_RESULT([no])
209 fi
Miklos Szeredid9079a72005-10-26 15:29:06 +0000210
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000211 isuml=no
212 KERNELMAKE_PARAMS=
213 KERNELCPPFLAGS=
214 AC_MSG_CHECKING([if this is user mode linux])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000215 if test -f $kernelbuild/include/linux/autoconf.h && egrep -q "^#define CONFIG_(USERMODE|UML) 1" $kernelbuild/include/linux/autoconf.h; then
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000216 isuml=yes
217 KERNELMAKE_PARAMS="ARCH=um"
218 KERNELCPPFLAGS="-D__arch_um__ -DSUBARCH=\\\"i386\\\" -D_LARGEFILE64_SOURCE -I${kernelsrc}/arch/um/include -Derrno=kernel_errno -I${kernelsrc}/arch/um/kernel/tt/include -I${kernelsrc}/arch/um/kernel/skas/include"
219 fi
220 AC_MSG_RESULT([$isuml])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000221 if test "$kernelbuild" != "$kernelsrc"; then
222 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild"
223 fi
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000224 AC_SUBST(KERNELMAKE_PARAMS)
225 AC_SUBST(KERNELCPPFLAGS)
Miklos Szeredi3cc8a262005-11-29 11:04:27 +0000226 AC_SUBST(KERNELCFLAGS)
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000227fi
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000228
229AC_CONFIG_FILES([Makefile])
230AC_OUTPUT