blob: a0c6bab4bd55c1c6f0f06e7cbfb6e08299b44607 [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"
113 else
114 fuse_configured=no
115 kernel_autoconf=$kernelbuild/include/linux/autoconf.h
116 AC_MSG_CHECKING([if FUSE is configured in the kernel])
117 if test -f $kernel_autoconf; then
118 if grep -q "^#define CONFIG_FUSE_FS 1" $kernel_autoconf || grep -q "^#define CONFIG_FUSE_FS_MODULE 1" $kernel_autoconf; then
119 fuse_configured=yes
120 fi
121 fi
122 AC_MSG_RESULT([$fuse_configured])
123 if test -z "$enable_kernel_module" -a "$fuse_configured" = yes; then
124 ENABLE_FUSE_MODULE=n
125 fi
126 fi
127fi
128
129if test "$ENABLE_FUSE_MODULE" = n; then
130 AC_MSG_NOTICE([NOTE: Detected that FUSE is already present in the kernel, so])
131 AC_MSG_NOTICE([NOTE: building of kernel module is disabled. To force building])
132 AC_MSG_NOTICE([NOTE: of kernel module use the '--enable-kernel-module' option.])
133fi
134
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000135if test "$enable_kernel_module" = no; then
136 ENABLE_FUSE_MODULE=n
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000137fi
138
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000139AC_SUBST(ENABLE_FUSE_MODULE)
140
141if test "$ENABLE_FUSE_MODULE" = y; then
142 AC_MSG_CHECKING([if kernel has extended attribute support])
143 if test -f $kernelsrc/include/linux/xattr.h; then
144 AC_DEFINE(HAVE_KERNEL_XATTR, 1, [Kernel has xattr support])
145 AC_MSG_RESULT([yes])
146 else
147 AC_MSG_RESULT([no])
148 fi
Miklos Szeredie5183742005-02-02 11:14:04 +0000149
Miklos Szeredid9079a72005-10-26 15:29:06 +0000150 AC_MSG_CHECKING([whether lookup_instantiate_filp is defined])
151 if test -f $kernelsrc/include/linux/namei.h && egrep -q "lookup_instantiate_filp" $kernelsrc/include/linux/namei.h; then
152 AC_DEFINE(HAVE_LOOKUP_INSTANTIATE_FILP, 1, [lookup_instantiate_filp() is defined])
153 AC_MSG_RESULT([yes])
154 else
155 AC_MSG_RESULT([no])
156 fi
157
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000158 isuml=no
159 KERNELMAKE_PARAMS=
160 KERNELCPPFLAGS=
161 AC_MSG_CHECKING([if this is user mode linux])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000162 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 +0000163 isuml=yes
164 KERNELMAKE_PARAMS="ARCH=um"
165 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"
166 fi
167 AC_MSG_RESULT([$isuml])
Miklos Szeredi2c650412005-10-26 15:12:59 +0000168 if test "$kernelbuild" != "$kernelsrc"; then
169 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild"
170 fi
Miklos Szeredi8c7da232005-01-09 12:27:41 +0000171 AC_SUBST(KERNELMAKE_PARAMS)
172 AC_SUBST(KERNELCPPFLAGS)
Miklos Szeredi3cc8a262005-11-29 11:04:27 +0000173 AC_SUBST(KERNELCFLAGS)
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000174fi
Miklos Szeredi51ec1032004-11-10 11:52:26 +0000175
176AC_CONFIG_FILES([Makefile])
177AC_OUTPUT