1 AC_DEFUN([ZFS_AC_KERNEL], [
5 AS_HELP_STRING([--with-linux=PATH],
6 [Path to kernel source]),
7 [kernelsrc="$withval"; kernelbuild="$withval"])
10 AS_HELP_STRING([--with-linux-obj=PATH],
11 [Path to kernel build objects]),
12 [kernelbuild="$withval"])
14 AC_MSG_CHECKING([kernel source directory])
15 if test -z "$kernelsrc"; then
17 sourcelink=/lib/modules/${ver}/source
18 buildlink=/lib/modules/${ver}/build
20 if test -e $sourcelink; then
21 kernelsrc=`(cd $sourcelink; /bin/pwd)`
23 if test -e $buildlink; then
24 kernelbuild=`(cd $buildlink; /bin/pwd)`
26 if test -z "$kernelsrc"; then
27 kernelsrc=$kernelbuild
29 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
30 AC_MSG_RESULT([Not found])
32 *** Please specify the location of the kernel source
33 *** with the '--with-linux=PATH' option])
37 AC_MSG_RESULT([$kernelsrc])
38 AC_MSG_CHECKING([kernel build directory])
39 AC_MSG_RESULT([$kernelbuild])
41 AC_MSG_CHECKING([kernel source version])
42 if test -r $kernelbuild/include/linux/version.h &&
43 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
45 kernsrcver=`(echo "#include <linux/version.h>";
46 echo "kernsrcver=UTS_RELEASE") |
47 cpp -I $kernelbuild/include |
48 grep "^kernsrcver=" | cut -d \" -f 2`
50 elif test -r $kernelbuild/include/linux/utsrelease.h &&
51 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
53 kernsrcver=`(echo "#include <linux/utsrelease.h>";
54 echo "kernsrcver=UTS_RELEASE") |
55 cpp -I $kernelbuild/include |
56 grep "^kernsrcver=" | cut -d \" -f 2`
59 if test -z "$kernsrcver"; then
60 AC_MSG_RESULT([Not found])
62 *** Cannot determine the version of the linux kernel source.
63 *** Please prepare the kernel before running this script])
66 AC_MSG_RESULT([$kernsrcver])
68 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
70 LINUX_OBJ=${kernelbuild}
77 AC_DEFUN([ZFS_AC_SPL], [
80 AS_HELP_STRING([--with-spl=PATH],
81 [Path to spl source]),
82 [splsrc="$withval"; splbuild="$withval"])
84 AC_ARG_WITH([spl-obj],
85 AS_HELP_STRING([--with-spl-obj=PATH],
86 [Path to spl build objects]),
87 [splbuild="$withval"])
90 AC_MSG_CHECKING([spl source directory])
91 if test -z "$splsrc"; then
93 sourcelink=/tmp/`whoami`/spl
94 buildlink=/tmp/`whoami`/spl
96 if test -e $sourcelink; then
97 splsrc=`(cd $sourcelink; /bin/pwd)`
99 if test -e $buildlink; then
100 splbuild=`(cd $buildlink; /bin/pwd)`
102 if test -z "$splsrc"; then
107 if test -z "$splsrc" -o -z "$splbuild"; then
108 sourcelink=/lib/modules/${ver}/source
109 buildlink=/lib/modules/${ver}/build
111 if test -e $sourcelink; then
112 splsrc=`(cd $sourcelink; /bin/pwd)`
114 if test -e $buildlink; then
115 splbuild=`(cd $buildlink; /bin/pwd)`
117 if test -z "$splsrc"; then
120 if test -z "$splsrc" -o -z "$splbuild"; then
121 AC_MSG_RESULT([Not found])
123 *** Please specify the location of the spl source
124 *** with the '--with-spl=PATH' option])
128 AC_MSG_RESULT([$splsrc])
129 AC_MSG_CHECKING([spl build directory])
130 AC_MSG_RESULT([$splbuild])
132 AC_MSG_CHECKING([spl source version])
133 if test -r $splbuild/spl_config.h &&
134 fgrep -q VERSION $splbuild/spl_config.h; then
136 splsrcver=`(echo "#include <spl_config.h>";
137 echo "splsrcver=VERSION") |
139 grep "^splsrcver=" | cut -d \" -f 2`
142 if test -z "$splsrcver"; then
143 AC_MSG_RESULT([Not found])
145 *** Cannot determine the version of the spl source.
146 *** Please prepare the spl source before running this script])
149 AC_MSG_RESULT([$splsrcver])
151 AC_MSG_CHECKING([spl Module.symvers])
152 if test -r $splbuild/modules/Module.symvers; then
153 splsymvers=$splbuild/modules/Module.symvers
154 elif test -r $kernelbuild/Module.symvers; then
155 splsymvers=$kernelbuild/Module.symvers
158 if test -z "$splsymvers"; then
159 AC_MSG_RESULT([Not found])
161 *** Cannot find extra Module.symvers in the spl source.
162 *** Please prepare the spl source before running this script])
165 AC_MSG_RESULT([$splsymvers])
170 AC_DEFUN([ZFS_AC_LICENSE], [
171 AC_MSG_CHECKING([license])
172 AC_MSG_RESULT([CDDL])
173 dnl # AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
174 dnl # [Define to 1 if module is licensed under the GPL])
177 AC_DEFUN([ZFS_AC_DEBUG], [
178 AC_MSG_CHECKING([whether debugging is enabled])
179 AC_ARG_ENABLE( [debug],
180 AS_HELP_STRING([--enable-debug],
181 [Enable generic debug support (default off)]),
182 [ case "$enableval" in
183 yes) zfs_ac_debug=yes ;;
184 no) zfs_ac_debug=no ;;
185 *) AC_MSG_RESULT([Error!])
186 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
189 if test "$zfs_ac_debug" = yes; then
191 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
192 HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
195 AC_DEFINE([NDEBUG], [1],
196 [Define to 1 to disable debug tracing])
197 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
198 HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
202 AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [
203 SCRIPT_CONFIG=.script-config
204 rm -f ${SCRIPT_CONFIG}
205 echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
206 echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
207 echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG}
208 echo >>${SCRIPT_CONFIG}
209 echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG}
210 echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG}
211 echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG}
212 echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG}
213 echo >>${SCRIPT_CONFIG}
214 echo "ZFSSRC=${TOPDIR}/src" >>${SCRIPT_CONFIG}
215 echo "ZFSBUILD=${ZFSDIR}" >>${SCRIPT_CONFIG}
216 echo >>${SCRIPT_CONFIG}
217 echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG}
218 echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG}
219 echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG}
222 AC_DEFUN([ZFS_AC_CONFIG], [
225 BUILDDIR=$ZFS_META_NAME #+$zfsconfig
226 ZFSDIR=$TOPDIR/$BUILDDIR
229 UNAME=`uname -r | cut -d- -f1`
239 AC_ARG_WITH([zfs-config],
240 AS_HELP_STRING([--with-config=CONFIG],
241 [Config file 'kernel|user|lustre']),
242 [zfsconfig="$withval"])
244 AC_MSG_CHECKING([zfs config])
245 AC_MSG_RESULT([$zfsconfig]);
248 kernel) ZFS_AC_CONFIG_KERNEL ;;
249 user) ZFS_AC_CONFIG_USER ;;
250 lustre) ZFS_AC_CONFIG_LUSTRE ;;
252 AC_MSG_RESULT([Error!])
253 AC_MSG_ERROR([Bad value "$zfsconfig" for --with-config,
254 user kernel|user|lustre]) ;;
261 dnl # ZFS_LINUX_CONFTEST
263 AC_DEFUN([ZFS_LINUX_CONFTEST], [
264 cat >conftest.c <<_ACEOF
270 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
272 m4_define([ZFS_LANG_PROGRAM], [
277 dnl Do *not* indent the following line: there may be CPP directives.
278 dnl Don't move the `;' right after for the same reason.
286 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
288 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
289 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])dnl
290 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
291 echo "obj-m := conftest.o" >build/Makefile
292 dnl AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LINUXINCLUDE="-Iinclude -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM SUBDIRS=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
293 AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" LINUXINCLUDE="-Iinclude -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
295 [_AC_MSG_LOG_CONFTEST
296 m4_ifvaln([$5],[$5])dnl])dnl
297 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
301 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
303 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
304 [ZFS_LINUX_COMPILE_IFELSE(
305 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
307 [test -s build/conftest.o],
312 dnl # ZFS_LINUX_CONFIG
314 AC_DEFUN([ZFS_LINUX_CONFIG],
315 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
316 ZFS_LINUX_TRY_COMPILE([
317 #ifndef AUTOCONF_INCLUDED
318 #include <linux/config.h>
322 #error CONFIG_$1 not #defined
334 dnl # ZFS_CHECK_SYMBOL_EXPORT
335 dnl # check symbol exported or not
337 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
338 [AC_MSG_CHECKING([whether symbol $1 is exported])
339 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
341 if test $rc -ne 0; then
344 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
346 if test $rc -eq 0; then
351 if test $export -eq 0; then
365 dnl # 2.6.x API change
366 dnl # bio_end_io_t uses 2 args (size was dropped from prototype)
368 AC_DEFUN([ZFS_AC_2ARGS_BIO_END_IO_T],
369 [AC_MSG_CHECKING([whether bio_end_io_t wants 2 args])
370 tmp_flags="$EXTRA_KCFLAGS"
371 EXTRA_KCFLAGS="-Werror"
372 ZFS_LINUX_TRY_COMPILE([
373 #include <linux/bio.h>
375 void (*wanted_end_io)(struct bio *, int) = NULL;
376 bio_end_io_t *local_end_io;
378 local_end_io = wanted_end_io;
381 AC_DEFINE(HAVE_2ARGS_BIO_END_IO_T, 1,
382 [bio_end_io_t wants 2 args])
386 EXTRA_KCFLAGS="$tmp_flags"