blob: 3748107a97ae4ef84fc710c53aa451fb35e10a08 [file] [log] [blame]
Miklos Szeredi95da8602006-01-06 18:29:40 +00001AC_INIT(fuse-kernel, 2.5.0-pre2)
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`
7ENABLE_FUSE_MODULE=y
Miklos Szeredi3cc8a262005-11-29 11:04:27 +00008KERNELCFLAGS=
Miklos Szeredibac4c772005-11-23 13:35:54 +00009
Miklos Szeredi51ec1032004-11-10 11:52:26 +000010kernelsrc=
Miklos Szeredi2c650412005-10-26 15:12:59 +000011kernelbuild=
Miklos Szeredi51ec1032004-11-10 11:52:26 +000012AC_ARG_WITH(kernel,
13 [ --with-kernel=PATH Specify location of kernel source ],
Miklos Szeredi2c650412005-10-26 15:12:59 +000014 [kernelsrc="$withval"; kernelbuild="$withval"])
15AC_ARG_WITH(kernel-build,
16 [ --with-kernel-build=PATH Specify location of kernel build ],
17 [kernelbuild="$withval"])
Miklos Szeredi8c7da232005-01-09 12:27:41 +000018AC_ARG_ENABLE(kernel-module,
19 [ --enable-kernel-module Compile kernel module ])
20
Miklos Szeredibac4c772005-11-23 13:35:54 +000021if test -z "$enable_kernel_module" -a -z "$kernelbuild" && echo "$runver" | grep -q "^2.6"; then
22 checkmodule=no
23 AC_MSG_CHECKING([if FUSE is loaded as a module])
24 if cat /proc/modules | grep -q "^fuse "; then
25 AC_MSG_RESULT([yes])
26 checkmodule=yes
27 else
28 AC_MSG_RESULT([no])
29 AC_MSG_CHECKING([if FUSE module is built into the kernel])
30 if test -e /sys/class/misc/fuse; then
31 AC_MSG_RESULT([yes])
32 ENABLE_FUSE_MODULE=n
33 else
34 AC_MSG_RESULT([no])
35 checkmodule=yes
Miklos Szeredi8c7da232005-01-09 12:27:41 +000036 fi
37 fi
Miklos Szeredibac4c772005-11-23 13:35:54 +000038 if test "$checkmodule" = yes; then
39 AC_MSG_CHECKING([if FUSE module is from official kernel])
40 if fgrep -q "fuse distribution version: " /lib/modules/${runver}/kernel/fs/fuse/fuse.ko 2> /dev/null; then
41 AC_MSG_RESULT([no])
42 else
43 AC_MSG_RESULT([yes])
44 ENABLE_FUSE_MODULE=n
45 fi
Miklos Szeredi8c7da232005-01-09 12:27:41 +000046 fi
47fi
Miklos Szeredibac4c772005-11-23 13:35:54 +000048
49if test "$ENABLE_FUSE_MODULE" = y; then
50 AC_MSG_CHECKING([kernel source directory])
51 if test -z "$kernelsrc"; then
52 kernelbuild=
53 sourcelink=/lib/modules/${runver}/source
54 buildlink=/lib/modules/${runver}/build
55
56 if test -e $sourcelink; then
57 kernelsrc=`(cd $sourcelink; /bin/pwd)`
58 fi
59 if test -e $buildlink; then
60 kernelbuild=`(cd $buildlink; /bin/pwd)`
61 fi
62 if test -z "$kernelsrc"; then
63 kernelsrc=$kernelbuild
64 fi
65 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
66 AC_MSG_RESULT([Not found])
67 AC_MSG_ERROR([
68 *** Please specify the location of the kernel source with
69 *** the '--with-kernel=SRCDIR' option])
70 fi
71 fi
72 AC_MSG_RESULT([$kernelsrc])
73 AC_MSG_CHECKING([kernel build directory])
74 AC_MSG_RESULT([$kernelbuild])
75
76 AC_MSG_CHECKING([kernel source version])
77 if test -r $kernelbuild/include/linux/version.h; then
78 kernsrcver=`(echo "#include <linux/version.h>"; echo "kernsrcver=UTS_RELEASE") | cpp -I $kernelbuild/include | grep "^kernsrcver=" | cut -d \" -f 2`
79 fi
80 if test -z "$kernsrcver"; then
81 AC_MSG_RESULT([Not found])
82 AC_MSG_ERROR([
83 *** Cannot determine the version of the linux kernel source. Please
84 *** prepare the kernel before running this script])
85 fi
86 AC_MSG_RESULT([$kernsrcver])
87 majver=`echo "$kernsrcver" | cut -f-2 -d.`
88 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
89 AC_SUBST(kernelsrc)
90 AC_SUBST(majver)
91 AC_SUBST(kmoduledir)
92
93 if echo "$kernsrcver" | grep -q "^2.4"; then
94 old_cflags="$CFLAGS"
95 CFLAGS="-I${kernelsrc}/include -Wall -O2 -fno-strict-aliasing -D__KERNEL__"
96 AC_CHECK_DECL(i_size_read,
97 AC_DEFINE(HAVE_I_SIZE_FUNC, 1,
98 [Kernel has i_size_read() and i_size_write() functions]),,
99 [#include <linux/fs.h>])
100 AC_CHECK_DECL(recalc_sigpending_tsk,
101 AC_DEFINE(HAVE_RECALC_SIGPENDING_TSK, 1,
102 [Kernel has recalc_sigpending_tsk() function]),,
103 [#include <linux/sched.h>])
Miklos Szeredi3cc8a262005-11-29 11:04:27 +0000104 AC_MSG_CHECKING([if '-msoft-float' option is valid])
105 CFLAGS="-msoft-float"
106 have_msoft_float=no
107 AC_TRY_COMPILE([], [], [have_msoft_float=yes])
108 AC_MSG_RESULT([$have_msoft_float])
109 if test "$have_msoft_float" = yes; then
110 KERNELCFLAGS="$CFLAGS"
111 fi
Miklos Szeredibac4c772005-11-23 13:35:54 +0000112 CFLAGS="$old_cflags"
Miklos Szeredia9820342006-01-10 10:54:11 +0000113 AC_MSG_CHECKING([architecture])
114 arch=`/bin/ls -l ${kernelsrc}/include/asm | sed "s/.*-> asm-//"`
115 AC_MSG_RESULT([$arch])
116 if test "$arch" = x86_64; then
117 KERNELCFLAGS="$KERNELCFLAGS -mno-red-zone -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000"
118 fi
Miklos Szeredibac4c772005-11-23 13:35:54 +0000119 else
120 fuse_configured=no
121 kernel_autoconf=$kernelbuild/include/linux/autoconf.h
122 AC_MSG_CHECKING([if FUSE is configured in the kernel])
123 if test -f $kernel_autoconf; then
124 if grep -q "^#define CONFIG_FUSE_FS 1" $kernel_autoconf || grep -q "^#define CONFIG_FUSE_FS_MODULE 1" $kernel_autoconf; then
125 fuse_configured=yes
126 fi
127 fi
128 AC_MSG_RESULT([$fuse_configured])
129 if test -z "$enable_kernel_module" -a "$fuse_configured" = yes; then
130 ENABLE_FUSE_MODULE=n
131 fi
132 fi
133fi
134
135if test "$ENABLE_FUSE_MODULE" = n; then
136 AC_MSG_NOTICE([NOTE: Detected that FUSE is already present in the kernel, so])
137 AC_MSG_NOTICE([NOTE: building of kernel module is disabled. To force building])
138 AC_MSG_NOTICE([NOTE: of kernel module use the '--enable-kernel-module' option.])
139fi
140
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000141if test "$enable_kernel_module" = no; then
142 ENABLE_FUSE_MODULE=n
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000143fi
144
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000145AC_SUBST(ENABLE_FUSE_MODULE)
146
147if test "$ENABLE_FUSE_MODULE" = y; then
148 AC_MSG_CHECKING([if kernel has extended attribute support])
149 if test -f $kernelsrc/include/linux/xattr.h; then
150 AC_DEFINE(HAVE_KERNEL_XATTR, 1, [Kernel has xattr support])
151 AC_MSG_RESULT([yes])
152 else
153 AC_MSG_RESULT([no])
154 fi
Miklos Szeredie5183742005-02-02 11:14:04 +0000155
Miklos Szeredid9079a72005-10-26 15:29:06 +0000156 AC_MSG_CHECKING([whether lookup_instantiate_filp is defined])
157 if test -f $kernelsrc/include/linux/namei.h && egrep -q "lookup_instantiate_filp" $kernelsrc/include/linux/namei.h; then
158 AC_DEFINE(HAVE_LOOKUP_INSTANTIATE_FILP, 1, [lookup_instantiate_filp() is defined])
159 AC_MSG_RESULT([yes])
160 else
161 AC_MSG_RESULT([no])
162 fi
163
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000164 isuml=no
165 KERNELMAKE_PARAMS=
166 KERNELCPPFLAGS=
167 AC_MSG_CHECKING([if this is user mode linux])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000168 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 +0000169 isuml=yes
170 KERNELMAKE_PARAMS="ARCH=um"
171 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"
172 fi
173 AC_MSG_RESULT([$isuml])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000174 if test "$kernelbuild" != "$kernelsrc"; then
175 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild"
176 fi
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000177 AC_SUBST(KERNELMAKE_PARAMS)
178 AC_SUBST(KERNELCPPFLAGS)
Miklos Szeredi3cc8a262005-11-29 11:04:27 +0000179 AC_SUBST(KERNELCFLAGS)
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000180fi
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000181
182AC_CONFIG_FILES([Makefile])
183AC_OUTPUT