1 AC_DEFUN([ZFS_AC_CONFIG], [
3 AC_ARG_WITH([zfs-config],
4 AS_HELP_STRING([--with-config=CONFIG],
5 [Config file 'kernel|user|lustre']),
6 [zfsconfig="$withval"])
8 AC_MSG_CHECKING([zfs config file])
9 if test -z "$zfsconfig" || test ! -r config/$zfsconfig; then
12 *** Please specify one of the valid config files located
13 *** in ./config/ with the '--with-zfs-config=CONFIG' option])
17 BUILDDIR=$ZFS_META_NAME #+$zfsconfig
18 ZFSDIR=$TOPDIR/$BUILDDIR
21 UNAME=`uname -r | cut -d- -f1`
31 AC_MSG_RESULT([$zfsconfig]);
34 AC_SUBST(KERNELMAKE_PARAMS)
35 AC_SUBST(KERNELCPPFLAGS)
39 AC_DEFUN([ZFS_AC_KERNEL], [
43 AS_HELP_STRING([--with-linux=PATH],
44 [Path to kernel source]),
45 [kernelsrc="$withval"; kernelbuild="$withval"])
47 AC_ARG_WITH(linux-obj,
48 AS_HELP_STRING([--with-linux-obj=PATH],
49 [Path to kernel build objects]),
50 [kernelbuild="$withval"])
52 AC_MSG_CHECKING([kernel source directory])
53 if test -z "$kernelsrc"; then
55 sourcelink=/lib/modules/${ver}/source
56 buildlink=/lib/modules/${ver}/build
58 if test -e $sourcelink; then
59 kernelsrc=`(cd $sourcelink; /bin/pwd)`
61 if test -e $buildlink; then
62 kernelbuild=`(cd $buildlink; /bin/pwd)`
64 if test -z "$kernelsrc"; then
65 kernelsrc=$kernelbuild
67 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
68 AC_MSG_RESULT([Not found])
70 *** Please specify the location of the kernel source
71 *** with the '--with-linux=PATH' option])
75 AC_MSG_RESULT([$kernelsrc])
76 AC_MSG_CHECKING([kernel build directory])
77 AC_MSG_RESULT([$kernelbuild])
79 AC_MSG_CHECKING([kernel source version])
80 if test -r $kernelbuild/include/linux/version.h &&
81 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
83 kernsrcver=`(echo "#include <linux/version.h>";
84 echo "kernsrcver=UTS_RELEASE") |
85 cpp -I $kernelbuild/include |
86 grep "^kernsrcver=" | cut -d \" -f 2`
88 elif test -r $kernelbuild/include/linux/utsrelease.h &&
89 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
91 kernsrcver=`(echo "#include <linux/utsrelease.h>";
92 echo "kernsrcver=UTS_RELEASE") |
93 cpp -I $kernelbuild/include |
94 grep "^kernsrcver=" | cut -d \" -f 2`
97 if test -z "$kernsrcver"; then
98 AC_MSG_RESULT([Not found])
100 *** Cannot determine the version of the linux kernel source.
101 *** Please prepare the kernel before running this script])
104 AC_MSG_RESULT([$kernsrcver])
106 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
108 LINUX_OBJ=${kernelbuild}
115 AC_DEFUN([ZFS_AC_SPL], [
118 AS_HELP_STRING([--with-spl=PATH],
119 [Path to spl source]),
120 [splsrc="$withval"; splbuild="$withval"])
122 AC_ARG_WITH([spl-obj],
123 AS_HELP_STRING([--with-spl-obj=PATH],
124 [Path to spl build objects]),
125 [splbuild="$withval"])
128 AC_MSG_CHECKING([spl source directory])
129 if test -z "$splsrc"; then
131 sourcelink=/tmp/`whoami`/spl
132 buildlink=/tmp/`whoami`/spl
134 if test -e $sourcelink; then
135 splsrc=`(cd $sourcelink; /bin/pwd)`
137 if test -e $buildlink; then
138 splbuild=`(cd $buildlink; /bin/pwd)`
140 if test -z "$splsrc"; then
145 if test -z "$splsrc" -o -z "$splbuild"; then
146 sourcelink=/lib/modules/${ver}/source
147 buildlink=/lib/modules/${ver}/build
149 if test -e $sourcelink; then
150 splsrc=`(cd $sourcelink; /bin/pwd)`
152 if test -e $buildlink; then
153 splbuild=`(cd $buildlink; /bin/pwd)`
155 if test -z "$splsrc"; then
158 if test -z "$splsrc" -o -z "$splbuild"; then
159 AC_MSG_RESULT([Not found])
161 *** Please specify the location of the spl source
162 *** with the '--with-spl=PATH' option])
166 AC_MSG_RESULT([$splsrc])
167 AC_MSG_CHECKING([spl build directory])
168 AC_MSG_RESULT([$splbuild])
170 AC_MSG_CHECKING([spl source version])
171 if test -r $splbuild/spl_config.h &&
172 fgrep -q VERSION $splbuild/spl_config.h; then
174 splsrcver=`(echo "#include <spl_config.h>";
175 echo "splsrcver=VERSION") |
177 grep "^splsrcver=" | cut -d \" -f 2`
180 if test -z "$splsrcver"; then
181 AC_MSG_RESULT([Not found])
183 *** Cannot determine the version of the spl source.
184 *** Please prepare the spl source before running this script])
187 AC_MSG_RESULT([$splsrcver])
189 AC_MSG_CHECKING([spl Module.symvers])
190 if test -r $splbuild/modules/Module.symvers; then
191 splsymvers=$splbuild/modules/Module.symvers
192 elif test -r $kernelbuild/Module.symvers; then
193 splsymvers=$kernelbuild/Module.symvers
196 if test -z "$splsymvers"; then
197 AC_MSG_RESULT([Not found])
199 *** Cannot find extra Module.symvers in the spl source.
200 *** Please prepare the spl source before running this script])
203 AC_MSG_RESULT([$splsymvers])
208 AC_DEFUN([ZFS_AC_LICENSE], [
209 AC_MSG_CHECKING([license])
210 AC_MSG_RESULT([CDDL])
211 dnl # AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
212 dnl # [Define to 1 if module is licensed under the GPL])
215 AC_DEFUN([ZFS_AC_DEBUG], [
216 AC_MSG_CHECKING([whether debugging is enabled])
217 AC_ARG_ENABLE( [debug],
218 AS_HELP_STRING([--enable-debug],
219 [Enable generic debug support (default off)]),
220 [ case "$enableval" in
221 yes) zfs_ac_debug=yes ;;
222 no) zfs_ac_debug=no ;;
223 *) AC_MSG_RESULT([Error!])
224 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
227 if test "$zfs_ac_debug" = yes; then
229 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
230 HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
233 AC_DEFINE([NDEBUG], [1],
234 [Define to 1 to disable debug tracing])
235 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
236 HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
240 AC_DEFUN([ZFS_AC_SCRIPT_CONFIG], [
241 SCRIPT_CONFIG=.script-config
242 rm -f ${SCRIPT_CONFIG}
243 echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
244 echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
245 echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG}
246 echo >>${SCRIPT_CONFIG}
247 echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG}
248 echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG}
249 echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG}
250 echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG}
251 echo >>${SCRIPT_CONFIG}
252 echo "ZFSSRC=${TOPDIR}/src" >>${SCRIPT_CONFIG}
253 echo "ZFSBUILD=${ZFSDIR}" >>${SCRIPT_CONFIG}
254 echo >>${SCRIPT_CONFIG}
255 echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG}
256 echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG}
257 echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG}
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"