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])
16 AC_MSG_RESULT([$zfsconfig]);
20 ZFSDIR=${TOPDIR}/$BUILDDIR
30 AC_DEFUN([ZFS_AC_KERNEL], [
34 AS_HELP_STRING([--with-linux=PATH],
35 [Path to kernel source]),
36 [kernelsrc="$withval"; kernelbuild="$withval"])
38 AC_ARG_WITH(linux-obj,
39 AS_HELP_STRING([--with-linux-obj=PATH],
40 [Path to kernel build objects]),
41 [kernelbuild="$withval"])
43 AC_MSG_CHECKING([kernel source directory])
44 if test -z "$kernelsrc"; then
46 sourcelink=/lib/modules/${ver}/source
47 buildlink=/lib/modules/${ver}/build
49 if test -e $sourcelink; then
50 kernelsrc=`(cd $sourcelink; /bin/pwd)`
52 if test -e $buildlink; then
53 kernelbuild=`(cd $buildlink; /bin/pwd)`
55 if test -z "$kernelsrc"; then
56 kernelsrc=$kernelbuild
58 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
59 AC_MSG_RESULT([Not found])
61 *** Please specify the location of the kernel source
62 *** with the '--with-linux=PATH' option])
66 AC_MSG_RESULT([$kernelsrc])
67 AC_MSG_CHECKING([kernel build directory])
68 AC_MSG_RESULT([$kernelbuild])
70 AC_MSG_CHECKING([kernel source version])
71 if test -r $kernelbuild/include/linux/version.h &&
72 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
74 kernsrcver=`(echo "#include <linux/version.h>";
75 echo "kernsrcver=UTS_RELEASE") |
76 cpp -I $kernelbuild/include |
77 grep "^kernsrcver=" | cut -d \" -f 2`
79 elif test -r $kernelbuild/include/linux/utsrelease.h &&
80 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
82 kernsrcver=`(echo "#include <linux/utsrelease.h>";
83 echo "kernsrcver=UTS_RELEASE") |
84 cpp -I $kernelbuild/include |
85 grep "^kernsrcver=" | cut -d \" -f 2`
88 if test -z "$kernsrcver"; then
89 AC_MSG_RESULT([Not found])
91 *** Cannot determine the version of the linux kernel source.
92 *** Please prepare the kernel before running this script])
95 AC_MSG_RESULT([$kernsrcver])
97 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
99 LINUX_OBJ=${kernelbuild}
106 AC_DEFUN([ZFS_AC_SPL], [
109 AS_HELP_STRING([--with-spl=PATH],
110 [Path to spl source]),
111 [splsrc="$withval"; splbuild="$withval"])
113 AC_ARG_WITH([spl-obj],
114 AS_HELP_STRING([--with-spl-obj=PATH],
115 [Path to spl build objects]),
116 [splbuild="$withval"])
119 AC_MSG_CHECKING([spl source directory])
120 if test -z "$splsrc"; then
122 sourcelink=/tmp/`whoami`/spl
123 buildlink=/tmp/`whoami`/spl
125 if test -e $sourcelink; then
126 splsrc=`(cd $sourcelink; /bin/pwd)`
128 if test -e $buildlink; then
129 splbuild=`(cd $buildlink; /bin/pwd)`
131 if test -z "$splsrc"; then
136 if test -z "$splsrc" -o -z "$splbuild"; then
137 sourcelink=/lib/modules/${ver}/source
138 buildlink=/lib/modules/${ver}/build
140 if test -e $sourcelink; then
141 splsrc=`(cd $sourcelink; /bin/pwd)`
143 if test -e $buildlink; then
144 splbuild=`(cd $buildlink; /bin/pwd)`
146 if test -z "$splsrc"; then
149 if test -z "$splsrc" -o -z "$splbuild"; then
150 AC_MSG_RESULT([Not found])
152 *** Please specify the location of the spl source
153 *** with the '--with-spl=PATH' option])
157 AC_MSG_RESULT([$splsrc])
158 AC_MSG_CHECKING([spl build directory])
159 AC_MSG_RESULT([$splbuild])
161 AC_MSG_CHECKING([spl source version])
162 if test -r $splbuild/spl_config.h &&
163 fgrep -q VERSION $splbuild/spl_config.h; then
165 splsrcver=`(echo "#include <spl_config.h>";
166 echo "splsrcver=VERSION") |
168 grep "^splsrcver=" | cut -d \" -f 2`
171 if test -z "$splsrcver"; then
172 AC_MSG_RESULT([Not found])
174 *** Cannot determine the version of the spl source.
175 *** Please prepare the spl source before running this script])
178 AC_MSG_RESULT([$splsrcver])
180 AC_MSG_CHECKING([spl Module.symvers])
181 if test -r $splbuild/modules/Module.symvers; then
182 splsymvers=$splbuild/modules/Module.symvers
183 elif test -r $kernelbuild/Module.symvers; then
184 splsymvers=$kernelbuild/Module.symvers
187 if test -z "$splsymvers"; then
188 AC_MSG_RESULT([Not found])
190 *** Cannot find extra Module.symvers in the spl source.
191 *** Please prepare the spl source before running this script])
194 AC_MSG_RESULT([$splsymvers])
199 AC_DEFUN([ZFS_AC_LICENSE], [
200 AC_MSG_CHECKING([license])
201 AC_MSG_RESULT([CDDL])
202 dnl # AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
203 dnl # [Define to 1 if module is licensed under the GPL])
206 AC_DEFUN([ZFS_AC_DEBUG], [
207 AC_MSG_CHECKING([whether debugging is enabled])
208 AC_ARG_ENABLE( [debug],
209 AS_HELP_STRING([--enable-debug],
210 [Enable generic debug support (default off)]),
211 [ case "$enableval" in
212 yes) zfs_ac_debug=yes ;;
213 no) zfs_ac_debug=no ;;
214 *) AC_MSG_RESULT([Error!])
215 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
218 if test "$zfs_ac_debug" = yes; then
220 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
221 HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
224 AC_DEFINE([NDEBUG], [1],
225 [Define to 1 to disable debug tracing])
226 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
227 HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
231 AC_DEFUN([ZFS_AC_SCRIPT_CONFIG], [
232 SCRIPT_CONFIG=.script-config
233 rm -f ${SCRIPT_CONFIG}
234 echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
235 echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
236 echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG}
237 echo >>${SCRIPT_CONFIG}
238 echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG}
239 echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG}
240 echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG}
241 echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG}
242 echo >>${SCRIPT_CONFIG}
243 echo "ZFSSRC=${TOPDIR}/src" >>${SCRIPT_CONFIG}
244 echo "ZFSBUILD=${ZFSDIR}" >>${SCRIPT_CONFIG}
245 echo >>${SCRIPT_CONFIG}
246 echo "TOPDIR=${TOPDIR} >>${SCRIPT_CONFIG}
247 echo "LIBDIR=${LIBDIR} >>${SCRIPT_CONFIG}
248 echo "CMDDIR=${CMDDIR} >>${SCRIPT_CONFIG}
252 dnl # ZFS_LINUX_CONFTEST
254 AC_DEFUN([ZFS_LINUX_CONFTEST], [
255 cat >conftest.c <<_ACEOF
261 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
263 m4_define([ZFS_LANG_PROGRAM], [
268 dnl Do *not* indent the following line: there may be CPP directives.
269 dnl Don't move the `;' right after for the same reason.
277 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
279 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
280 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])dnl
281 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
282 echo "obj-m := conftest.o" >build/Makefile
283 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])],
284 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])],
286 [_AC_MSG_LOG_CONFTEST
287 m4_ifvaln([$5],[$5])dnl])dnl
288 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
292 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
294 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
295 [ZFS_LINUX_COMPILE_IFELSE(
296 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
298 [test -s build/conftest.o],
303 dnl # ZFS_LINUX_CONFIG
305 AC_DEFUN([ZFS_LINUX_CONFIG],
306 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
307 ZFS_LINUX_TRY_COMPILE([
308 #ifndef AUTOCONF_INCLUDED
309 #include <linux/config.h>
313 #error CONFIG_$1 not #defined
325 dnl # ZFS_CHECK_SYMBOL_EXPORT
326 dnl # check symbol exported or not
328 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
329 [AC_MSG_CHECKING([whether symbol $1 is exported])
330 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
332 if test $rc -ne 0; then
335 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
337 if test $rc -eq 0; then
342 if test $export -eq 0; then
356 dnl # 2.6.x API change
357 dnl # bio_end_io_t uses 2 args (size was dropped from prototype)
359 AC_DEFUN([ZFS_AC_2ARGS_BIO_END_IO_T],
360 [AC_MSG_CHECKING([whether bio_end_io_t wants 2 args])
361 tmp_flags="$EXTRA_KCFLAGS"
362 EXTRA_KCFLAGS="-Werror"
363 ZFS_LINUX_TRY_COMPILE([
364 #include <linux/bio.h>
366 void (*wanted_end_io)(struct bio *, int) = NULL;
367 bio_end_io_t *local_end_io;
369 local_end_io = wanted_end_io;
372 AC_DEFINE(HAVE_2ARGS_BIO_END_IO_T, 1,
373 [bio_end_io_t wants 2 args])
377 EXTRA_KCFLAGS="$tmp_flags"