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 BUILDDIR=$META_NAME #+$zfsconfig
21 ZFSDIR=$TOPDIR/$BUILDDIR
24 UNAME=`uname -r | cut -d- -f1`
35 AC_DEFUN([ZFS_AC_KERNEL], [
39 AS_HELP_STRING([--with-linux=PATH],
40 [Path to kernel source]),
41 [kernelsrc="$withval"; kernelbuild="$withval"])
43 AC_ARG_WITH(linux-obj,
44 AS_HELP_STRING([--with-linux-obj=PATH],
45 [Path to kernel build objects]),
46 [kernelbuild="$withval"])
48 AC_MSG_CHECKING([kernel source directory])
49 if test -z "$kernelsrc"; then
51 sourcelink=/lib/modules/${ver}/source
52 buildlink=/lib/modules/${ver}/build
54 if test -e $sourcelink; then
55 kernelsrc=`(cd $sourcelink; /bin/pwd)`
57 if test -e $buildlink; then
58 kernelbuild=`(cd $buildlink; /bin/pwd)`
60 if test -z "$kernelsrc"; then
61 kernelsrc=$kernelbuild
63 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
64 AC_MSG_RESULT([Not found])
66 *** Please specify the location of the kernel source
67 *** with the '--with-linux=PATH' option])
71 AC_MSG_RESULT([$kernelsrc])
72 AC_MSG_CHECKING([kernel build directory])
73 AC_MSG_RESULT([$kernelbuild])
75 AC_MSG_CHECKING([kernel source version])
76 if test -r $kernelbuild/include/linux/version.h &&
77 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
79 kernsrcver=`(echo "#include <linux/version.h>";
80 echo "kernsrcver=UTS_RELEASE") |
81 cpp -I $kernelbuild/include |
82 grep "^kernsrcver=" | cut -d \" -f 2`
84 elif test -r $kernelbuild/include/linux/utsrelease.h &&
85 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
87 kernsrcver=`(echo "#include <linux/utsrelease.h>";
88 echo "kernsrcver=UTS_RELEASE") |
89 cpp -I $kernelbuild/include |
90 grep "^kernsrcver=" | cut -d \" -f 2`
93 if test -z "$kernsrcver"; then
94 AC_MSG_RESULT([Not found])
96 *** Cannot determine the version of the linux kernel source.
97 *** Please prepare the kernel before running this script])
100 AC_MSG_RESULT([$kernsrcver])
102 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
104 LINUX_OBJ=${kernelbuild}
111 AC_DEFUN([ZFS_AC_SPL], [
114 AS_HELP_STRING([--with-spl=PATH],
115 [Path to spl source]),
116 [splsrc="$withval"; splbuild="$withval"])
118 AC_ARG_WITH([spl-obj],
119 AS_HELP_STRING([--with-spl-obj=PATH],
120 [Path to spl build objects]),
121 [splbuild="$withval"])
124 AC_MSG_CHECKING([spl source directory])
125 if test -z "$splsrc"; then
127 sourcelink=/tmp/`whoami`/spl
128 buildlink=/tmp/`whoami`/spl
130 if test -e $sourcelink; then
131 splsrc=`(cd $sourcelink; /bin/pwd)`
133 if test -e $buildlink; then
134 splbuild=`(cd $buildlink; /bin/pwd)`
136 if test -z "$splsrc"; then
141 if test -z "$splsrc" -o -z "$splbuild"; then
142 sourcelink=/lib/modules/${ver}/source
143 buildlink=/lib/modules/${ver}/build
145 if test -e $sourcelink; then
146 splsrc=`(cd $sourcelink; /bin/pwd)`
148 if test -e $buildlink; then
149 splbuild=`(cd $buildlink; /bin/pwd)`
151 if test -z "$splsrc"; then
154 if test -z "$splsrc" -o -z "$splbuild"; then
155 AC_MSG_RESULT([Not found])
157 *** Please specify the location of the spl source
158 *** with the '--with-spl=PATH' option])
162 AC_MSG_RESULT([$splsrc])
163 AC_MSG_CHECKING([spl build directory])
164 AC_MSG_RESULT([$splbuild])
166 AC_MSG_CHECKING([spl source version])
167 if test -r $splbuild/spl_config.h &&
168 fgrep -q VERSION $splbuild/spl_config.h; then
170 splsrcver=`(echo "#include <spl_config.h>";
171 echo "splsrcver=VERSION") |
173 grep "^splsrcver=" | cut -d \" -f 2`
176 if test -z "$splsrcver"; then
177 AC_MSG_RESULT([Not found])
179 *** Cannot determine the version of the spl source.
180 *** Please prepare the spl source before running this script])
183 AC_MSG_RESULT([$splsrcver])
185 AC_MSG_CHECKING([spl Module.symvers])
186 if test -r $splbuild/modules/Module.symvers; then
187 splsymvers=$splbuild/modules/Module.symvers
188 elif test -r $kernelbuild/Module.symvers; then
189 splsymvers=$kernelbuild/Module.symvers
192 if test -z "$splsymvers"; then
193 AC_MSG_RESULT([Not found])
195 *** Cannot find extra Module.symvers in the spl source.
196 *** Please prepare the spl source before running this script])
199 AC_MSG_RESULT([$splsymvers])
204 AC_DEFUN([ZFS_AC_LICENSE], [
205 AC_MSG_CHECKING([license])
206 AC_MSG_RESULT([CDDL])
207 dnl # AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
208 dnl # [Define to 1 if module is licensed under the GPL])
211 AC_DEFUN([ZFS_AC_DEBUG], [
212 AC_MSG_CHECKING([whether debugging is enabled])
213 AC_ARG_ENABLE( [debug],
214 AS_HELP_STRING([--enable-debug],
215 [Enable generic debug support (default off)]),
216 [ case "$enableval" in
217 yes) zfs_ac_debug=yes ;;
218 no) zfs_ac_debug=no ;;
219 *) AC_MSG_RESULT([Error!])
220 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
223 if test "$zfs_ac_debug" = yes; then
225 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
226 HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
229 AC_DEFINE([NDEBUG], [1],
230 [Define to 1 to disable debug tracing])
231 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
232 HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
236 AC_DEFUN([ZFS_AC_SCRIPT_CONFIG], [
237 SCRIPT_CONFIG=.script-config
238 rm -f ${SCRIPT_CONFIG}
239 echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
240 echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
241 echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG}
242 echo >>${SCRIPT_CONFIG}
243 echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG}
244 echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG}
245 echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG}
246 echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG}
247 echo >>${SCRIPT_CONFIG}
248 echo "ZFSSRC=${TOPDIR}/src" >>${SCRIPT_CONFIG}
249 echo "ZFSBUILD=${ZFSDIR}" >>${SCRIPT_CONFIG}
250 echo >>${SCRIPT_CONFIG}
251 echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG}
252 echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG}
253 echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG}
257 dnl # ZFS_LINUX_CONFTEST
259 AC_DEFUN([ZFS_LINUX_CONFTEST], [
260 cat >conftest.c <<_ACEOF
266 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
268 m4_define([ZFS_LANG_PROGRAM], [
273 dnl Do *not* indent the following line: there may be CPP directives.
274 dnl Don't move the `;' right after for the same reason.
282 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
284 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
285 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])dnl
286 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
287 echo "obj-m := conftest.o" >build/Makefile
288 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])],
289 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])],
291 [_AC_MSG_LOG_CONFTEST
292 m4_ifvaln([$5],[$5])dnl])dnl
293 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
297 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
299 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
300 [ZFS_LINUX_COMPILE_IFELSE(
301 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
303 [test -s build/conftest.o],
308 dnl # ZFS_LINUX_CONFIG
310 AC_DEFUN([ZFS_LINUX_CONFIG],
311 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
312 ZFS_LINUX_TRY_COMPILE([
313 #ifndef AUTOCONF_INCLUDED
314 #include <linux/config.h>
318 #error CONFIG_$1 not #defined
330 dnl # ZFS_CHECK_SYMBOL_EXPORT
331 dnl # check symbol exported or not
333 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
334 [AC_MSG_CHECKING([whether symbol $1 is exported])
335 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
337 if test $rc -ne 0; then
340 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
342 if test $rc -eq 0; then
347 if test $export -eq 0; then
361 dnl # 2.6.x API change
362 dnl # bio_end_io_t uses 2 args (size was dropped from prototype)
364 AC_DEFUN([ZFS_AC_2ARGS_BIO_END_IO_T],
365 [AC_MSG_CHECKING([whether bio_end_io_t wants 2 args])
366 tmp_flags="$EXTRA_KCFLAGS"
367 EXTRA_KCFLAGS="-Werror"
368 ZFS_LINUX_TRY_COMPILE([
369 #include <linux/bio.h>
371 void (*wanted_end_io)(struct bio *, int) = NULL;
372 bio_end_io_t *local_end_io;
374 local_end_io = wanted_end_io;
377 AC_DEFINE(HAVE_2ARGS_BIO_END_IO_T, 1,
378 [bio_end_io_t wants 2 args])
382 EXTRA_KCFLAGS="$tmp_flags"