1 AC_DEFUN([ZFS_AC_CONFIG], [
4 BUILDDIR=$ZFS_META_NAME #+$zfsconfig
5 ZFSDIR=$TOPDIR/$BUILDDIR
8 UNAME=`uname -r | cut -d- -f1`
18 AC_ARG_WITH([zfs-config],
19 AS_HELP_STRING([--with-config=CONFIG],
20 [Config file 'kernel|user|lustre']),
21 [zfsconfig="$withval"])
23 AC_MSG_CHECKING([zfs config file])
25 [ case "$zfsconfig" in
26 kernel) ZFS_AC_KERNEL_CONFIG ;;
27 user) ZFS_AC_USER_CONFIG ;;
28 lustre) ZFS_AC_LUSTRE_CONFIG ;;
30 AC_MSG_RESULT([Error!])
31 AC_MSG_ERROR([Bad value "$zfsconfig" for --with-config,
32 user kernel|user|lustre]) ;;
35 AC_MSG_RESULT([$zfsconfig]);
38 AC_DEFUN([ZFS_AC_KERNEL], [
42 AS_HELP_STRING([--with-linux=PATH],
43 [Path to kernel source]),
44 [kernelsrc="$withval"; kernelbuild="$withval"])
46 AC_ARG_WITH(linux-obj,
47 AS_HELP_STRING([--with-linux-obj=PATH],
48 [Path to kernel build objects]),
49 [kernelbuild="$withval"])
51 AC_MSG_CHECKING([kernel source directory])
52 if test -z "$kernelsrc"; then
54 sourcelink=/lib/modules/${ver}/source
55 buildlink=/lib/modules/${ver}/build
57 if test -e $sourcelink; then
58 kernelsrc=`(cd $sourcelink; /bin/pwd)`
60 if test -e $buildlink; then
61 kernelbuild=`(cd $buildlink; /bin/pwd)`
63 if test -z "$kernelsrc"; then
64 kernelsrc=$kernelbuild
66 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
67 AC_MSG_RESULT([Not found])
69 *** Please specify the location of the kernel source
70 *** with the '--with-linux=PATH' option])
74 AC_MSG_RESULT([$kernelsrc])
75 AC_MSG_CHECKING([kernel build directory])
76 AC_MSG_RESULT([$kernelbuild])
78 AC_MSG_CHECKING([kernel source version])
79 if test -r $kernelbuild/include/linux/version.h &&
80 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
82 kernsrcver=`(echo "#include <linux/version.h>";
83 echo "kernsrcver=UTS_RELEASE") |
84 cpp -I $kernelbuild/include |
85 grep "^kernsrcver=" | cut -d \" -f 2`
87 elif test -r $kernelbuild/include/linux/utsrelease.h &&
88 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
90 kernsrcver=`(echo "#include <linux/utsrelease.h>";
91 echo "kernsrcver=UTS_RELEASE") |
92 cpp -I $kernelbuild/include |
93 grep "^kernsrcver=" | cut -d \" -f 2`
96 if test -z "$kernsrcver"; then
97 AC_MSG_RESULT([Not found])
99 *** Cannot determine the version of the linux kernel source.
100 *** Please prepare the kernel before running this script])
103 AC_MSG_RESULT([$kernsrcver])
105 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
107 LINUX_OBJ=${kernelbuild}
114 AC_DEFUN([ZFS_AC_SPL], [
117 AS_HELP_STRING([--with-spl=PATH],
118 [Path to spl source]),
119 [splsrc="$withval"; splbuild="$withval"])
121 AC_ARG_WITH([spl-obj],
122 AS_HELP_STRING([--with-spl-obj=PATH],
123 [Path to spl build objects]),
124 [splbuild="$withval"])
127 AC_MSG_CHECKING([spl source directory])
128 if test -z "$splsrc"; then
130 sourcelink=/tmp/`whoami`/spl
131 buildlink=/tmp/`whoami`/spl
133 if test -e $sourcelink; then
134 splsrc=`(cd $sourcelink; /bin/pwd)`
136 if test -e $buildlink; then
137 splbuild=`(cd $buildlink; /bin/pwd)`
139 if test -z "$splsrc"; then
144 if test -z "$splsrc" -o -z "$splbuild"; then
145 sourcelink=/lib/modules/${ver}/source
146 buildlink=/lib/modules/${ver}/build
148 if test -e $sourcelink; then
149 splsrc=`(cd $sourcelink; /bin/pwd)`
151 if test -e $buildlink; then
152 splbuild=`(cd $buildlink; /bin/pwd)`
154 if test -z "$splsrc"; then
157 if test -z "$splsrc" -o -z "$splbuild"; then
158 AC_MSG_RESULT([Not found])
160 *** Please specify the location of the spl source
161 *** with the '--with-spl=PATH' option])
165 AC_MSG_RESULT([$splsrc])
166 AC_MSG_CHECKING([spl build directory])
167 AC_MSG_RESULT([$splbuild])
169 AC_MSG_CHECKING([spl source version])
170 if test -r $splbuild/spl_config.h &&
171 fgrep -q VERSION $splbuild/spl_config.h; then
173 splsrcver=`(echo "#include <spl_config.h>";
174 echo "splsrcver=VERSION") |
176 grep "^splsrcver=" | cut -d \" -f 2`
179 if test -z "$splsrcver"; then
180 AC_MSG_RESULT([Not found])
182 *** Cannot determine the version of the spl source.
183 *** Please prepare the spl source before running this script])
186 AC_MSG_RESULT([$splsrcver])
188 AC_MSG_CHECKING([spl Module.symvers])
189 if test -r $splbuild/modules/Module.symvers; then
190 splsymvers=$splbuild/modules/Module.symvers
191 elif test -r $kernelbuild/Module.symvers; then
192 splsymvers=$kernelbuild/Module.symvers
195 if test -z "$splsymvers"; then
196 AC_MSG_RESULT([Not found])
198 *** Cannot find extra Module.symvers in the spl source.
199 *** Please prepare the spl source before running this script])
202 AC_MSG_RESULT([$splsymvers])
207 AC_DEFUN([ZFS_AC_LICENSE], [
208 AC_MSG_CHECKING([license])
209 AC_MSG_RESULT([CDDL])
210 dnl # AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
211 dnl # [Define to 1 if module is licensed under the GPL])
214 AC_DEFUN([ZFS_AC_DEBUG], [
215 AC_MSG_CHECKING([whether debugging is enabled])
216 AC_ARG_ENABLE( [debug],
217 AS_HELP_STRING([--enable-debug],
218 [Enable generic debug support (default off)]),
219 [ case "$enableval" in
220 yes) zfs_ac_debug=yes ;;
221 no) zfs_ac_debug=no ;;
222 *) AC_MSG_RESULT([Error!])
223 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
226 if test "$zfs_ac_debug" = yes; then
228 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
229 HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
232 AC_DEFINE([NDEBUG], [1],
233 [Define to 1 to disable debug tracing])
234 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
235 HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
239 AC_DEFUN([ZFS_AC_SCRIPT_CONFIG], [
240 SCRIPT_CONFIG=.script-config
241 rm -f ${SCRIPT_CONFIG}
242 echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
243 echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
244 echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG}
245 echo >>${SCRIPT_CONFIG}
246 echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG}
247 echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG}
248 echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG}
249 echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG}
250 echo >>${SCRIPT_CONFIG}
251 echo "ZFSSRC=${TOPDIR}/src" >>${SCRIPT_CONFIG}
252 echo "ZFSBUILD=${ZFSDIR}" >>${SCRIPT_CONFIG}
253 echo >>${SCRIPT_CONFIG}
254 echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG}
255 echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG}
256 echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG}
260 dnl # ZFS_LINUX_CONFTEST
262 AC_DEFUN([ZFS_LINUX_CONFTEST], [
263 cat >conftest.c <<_ACEOF
269 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
271 m4_define([ZFS_LANG_PROGRAM], [
276 dnl Do *not* indent the following line: there may be CPP directives.
277 dnl Don't move the `;' right after for the same reason.
285 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
287 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
288 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])dnl
289 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
290 echo "obj-m := conftest.o" >build/Makefile
291 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])],
292 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])],
294 [_AC_MSG_LOG_CONFTEST
295 m4_ifvaln([$5],[$5])dnl])dnl
296 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
300 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
302 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
303 [ZFS_LINUX_COMPILE_IFELSE(
304 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
306 [test -s build/conftest.o],
311 dnl # ZFS_LINUX_CONFIG
313 AC_DEFUN([ZFS_LINUX_CONFIG],
314 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
315 ZFS_LINUX_TRY_COMPILE([
316 #ifndef AUTOCONF_INCLUDED
317 #include <linux/config.h>
321 #error CONFIG_$1 not #defined
333 dnl # ZFS_CHECK_SYMBOL_EXPORT
334 dnl # check symbol exported or not
336 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
337 [AC_MSG_CHECKING([whether symbol $1 is exported])
338 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
340 if test $rc -ne 0; then
343 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
345 if test $rc -eq 0; then
350 if test $export -eq 0; then
364 dnl # 2.6.x API change
365 dnl # bio_end_io_t uses 2 args (size was dropped from prototype)
367 AC_DEFUN([ZFS_AC_2ARGS_BIO_END_IO_T],
368 [AC_MSG_CHECKING([whether bio_end_io_t wants 2 args])
369 tmp_flags="$EXTRA_KCFLAGS"
370 EXTRA_KCFLAGS="-Werror"
371 ZFS_LINUX_TRY_COMPILE([
372 #include <linux/bio.h>
374 void (*wanted_end_io)(struct bio *, int) = NULL;
375 bio_end_io_t *local_end_io;
377 local_end_io = wanted_end_io;
380 AC_DEFINE(HAVE_2ARGS_BIO_END_IO_T, 1,
381 [bio_end_io_t wants 2 args])
385 EXTRA_KCFLAGS="$tmp_flags"