]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
Remove rpm/fedora directory
[mirror_spl.git] / config / spl-build.m4
CommitLineData
716154c5
BB
1###############################################################################
2# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3# Copyright (C) 2007 The Regents of the University of California.
4# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5###############################################################################
6# SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7###############################################################################
8
86933a6e
BB
9AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
10 SPL_AC_KERNEL
11
86933a6e
BB
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
14 fi
86933a6e 15 AC_SUBST(KERNELMAKE_PARAMS)
a7958f7e
BB
16
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
86933a6e
BB
18 AC_SUBST(KERNELCPPFLAGS)
19
20 SPL_AC_DEBUG
21 SPL_AC_DEBUG_KMEM
055ffd98 22 SPL_AC_DEBUG_KMEM_TRACKING
0408008b 23 SPL_AC_TEST_MODULE
5e9b5d83 24 SPL_AC_ATOMIC_SPINLOCK
c3d9c0df 25 SPL_AC_SHRINKER_CALLBACK
79a3bf13 26 SPL_AC_CTL_NAME
1ddf9722 27 SPL_AC_PDE_DATA
a54718cf 28 SPL_AC_SET_FS_PWD_WITH_CONST
86933a6e
BB
29 SPL_AC_2ARGS_VFS_UNLINK
30 SPL_AC_4ARGS_VFS_RENAME
0d0b5237 31 SPL_AC_2ARGS_VFS_FSYNC
bbdc6ae4 32 SPL_AC_INODE_TRUNCATE_RANGE
9b2048c2 33 SPL_AC_FS_STRUCT_SPINLOCK
f7fd6ddd 34 SPL_AC_KUIDGID_T
e811949a 35 SPL_AC_PUT_TASK_STRUCT
46aa7b39 36 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
1c7b3eaf 37 SPL_AC_KERNEL_FALLOCATE
42b3ce62
BB
38 SPL_AC_CONFIG_ZLIB_INFLATE
39 SPL_AC_CONFIG_ZLIB_DEFLATE
3dfc591a 40 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
a55bcaad 41 SPL_AC_SHRINK_CONTROL_STRUCT
588d9004 42 SPL_AC_RWSEM_SPINLOCK_IS_RAW
10087fe1 43 SPL_AC_SCHED_RT_HEADER
2a305c34 44 SPL_AC_2ARGS_VFS_GETATTR
184c6873 45 SPL_AC_USLEEP_RANGE
a073aeb0 46 SPL_AC_KMEM_CACHE_ALLOCFLAGS
2fc44f66 47 SPL_AC_WAIT_ON_BIT
86933a6e
BB
48])
49
50AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
bb339d06 51 modpost=$LINUX/scripts/Makefile.modpost
86933a6e 52 AC_MSG_CHECKING([kernel file name for module symbols])
0408008b 53 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
bb339d06
BB
54 if grep -q Modules.symvers $modpost; then
55 LINUX_SYMBOLS=Modules.symvers
56 else
57 LINUX_SYMBOLS=Module.symvers
58 fi
912fd84d
BB
59
60 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
61 AC_MSG_ERROR([
62 *** Please make sure the kernel devel package for your distribution
7a8a6393 63 *** is installed. If you are building with a custom kernel, make sure the
912fd84d
BB
64 *** kernel is configured, built, and the '--with-linux=PATH' configure
65 *** option refers to the location of the kernel source.])
66 fi
86933a6e 67 else
bb339d06 68 LINUX_SYMBOLS=NONE
86933a6e
BB
69 fi
70 AC_MSG_RESULT($LINUX_SYMBOLS)
71 AC_SUBST(LINUX_SYMBOLS)
72])
73
57d86234 74AC_DEFUN([SPL_AC_KERNEL], [
57d86234 75 AC_ARG_WITH([linux],
76 AS_HELP_STRING([--with-linux=PATH],
77 [Path to kernel source]),
39a3d2a4 78 [kernelsrc="$withval"])
57d86234 79
80 AC_ARG_WITH([linux-obj],
81 AS_HELP_STRING([--with-linux-obj=PATH],
82 [Path to kernel build objects]),
83 [kernelbuild="$withval"])
84
85 AC_MSG_CHECKING([kernel source directory])
86 if test -z "$kernelsrc"; then
22ccfaa8
BB
87 if test -e "/lib/modules/$(uname -r)/source"; then
88 headersdir="/lib/modules/$(uname -r)/source"
89 sourcelink=$(readlink -f "$headersdir")
90 elif test -e "/lib/modules/$(uname -r)/build"; then
91 headersdir="/lib/modules/$(uname -r)/build"
534c4e38
BM
92 sourcelink=$(readlink -f "$headersdir")
93 else
94 sourcelink=$(ls -1d /usr/src/kernels/* \
723aa3b0 95 /usr/src/linux-* \
534c4e38
BM
96 2>/dev/null | grep -v obj | tail -1)
97 fi
57d86234 98
8fd4e3af 99 if test -n "$sourcelink" && test -e ${sourcelink}; then
d4326403 100 kernelsrc=`readlink -f ${sourcelink}`
d4326403 101 else
251677e9 102 kernelsrc="[Not found]"
57d86234 103 fi
c5f70460
BB
104 else
105 if test "$kernelsrc" = "NONE"; then
106 kernsrcver=NONE
107 fi
57d86234 108 fi
109
110 AC_MSG_RESULT([$kernelsrc])
251677e9
BB
111 if test ! -d "$kernelsrc"; then
112 AC_MSG_ERROR([
113 *** Please make sure the kernel devel package for your distribution
7a8a6393 114 *** is installed and then try again. If that fails, you can specify the
251677e9
BB
115 *** location of the kernel source with the '--with-linux=PATH' option.])
116 fi
117
57d86234 118 AC_MSG_CHECKING([kernel build directory])
39a3d2a4 119 if test -z "$kernelbuild"; then
22ccfaa8
BB
120 if test -e "/lib/modules/$(uname -r)/build"; then
121 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
122 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
e2d28a37
BB
123 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
124 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
125 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
126 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
127 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
39a3d2a4
BB
128 else
129 kernelbuild=${kernelsrc}
130 fi
bf338d8d 131 fi
57d86234 132 AC_MSG_RESULT([$kernelbuild])
133
134 AC_MSG_CHECKING([kernel source version])
fd921c2e
BB
135 utsrelease1=$kernelbuild/include/linux/version.h
136 utsrelease2=$kernelbuild/include/linux/utsrelease.h
137 utsrelease3=$kernelbuild/include/generated/utsrelease.h
138 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
139 utsrelease=linux/version.h
140 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
141 utsrelease=linux/utsrelease.h
142 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
143 utsrelease=generated/utsrelease.h
144 fi
57d86234 145
fd921c2e
BB
146 if test "$utsrelease"; then
147 kernsrcver=`(echo "#include <$utsrelease>";
57d86234 148 echo "kernsrcver=UTS_RELEASE") |
d4326403 149 cpp -I $kernelbuild/include |
57d86234 150 grep "^kernsrcver=" | cut -d \" -f 2`
57d86234 151
fd921c2e
BB
152 if test -z "$kernsrcver"; then
153 AC_MSG_RESULT([Not found])
154 AC_MSG_ERROR([*** Cannot determine kernel version.])
155 fi
156 else
57d86234 157 AC_MSG_RESULT([Not found])
0408008b
ED
158 if test "x$enable_linux_builtin" != xyes; then
159 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
160 else
161 AC_MSG_ERROR([
162 *** Cannot find UTS_RELEASE definition.
163 *** Please run 'make prepare' inside the kernel source tree.])
164 fi
57d86234 165 fi
166
167 AC_MSG_RESULT([$kernsrcver])
168
57d86234 169 LINUX=${kernelsrc}
170 LINUX_OBJ=${kernelbuild}
c5f70460
BB
171 LINUX_VERSION=${kernsrcver}
172
57d86234 173 AC_SUBST(LINUX)
174 AC_SUBST(LINUX_OBJ)
c5f70460 175 AC_SUBST(LINUX_VERSION)
57d86234 176
86933a6e 177 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
178])
179
287b2fb1
BB
180dnl #
181dnl # Default SPL user configuration
182dnl #
ad35b6a6 183AC_DEFUN([SPL_AC_CONFIG_USER], [])
287b2fb1
BB
184
185dnl #
186dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
7a8a6393 187dnl # are missing, it is non-fatal, but you will not be able to build
287b2fb1
BB
188dnl # RPM packages and will be warned if you try too.
189dnl #
7a8a6393 190dnl # By default, the generic spec file will be used because it requires
493972c8
BB
191dnl # minimal dependencies. Distribution specific spec files can be
192dnl # placed under the 'rpm/<distribution>' directory and enabled using
193dnl # the --with-spec=<distribution> configure option.
194dnl #
287b2fb1
BB
195AC_DEFUN([SPL_AC_RPM], [
196 RPM=rpm
197 RPMBUILD=rpmbuild
198
199 AC_MSG_CHECKING([whether $RPM is available])
200 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
201 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
202 HAVE_RPM=yes
203 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
204 ],[
205 HAVE_RPM=no
206 AC_MSG_RESULT([$HAVE_RPM])
207 ])
208
209 AC_MSG_CHECKING([whether $RPMBUILD is available])
210 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
211 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
212 HAVE_RPMBUILD=yes
213 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
214 ],[
215 HAVE_RPMBUILD=no
216 AC_MSG_RESULT([$HAVE_RPMBUILD])
217 ])
218
8d9a23e8 219 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
493972c8
BB
220 RPM_DEFINE_UTIL=
221 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
222 RPM_DEFINE_DKMS=
223
224 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
225 SRPM_DEFINE_UTIL=
226 SRPM_DEFINE_KMOD=
227 SRPM_DEFINE_DKMS=
228
229 RPM_SPEC_DIR="rpm/generic"
230 AC_ARG_WITH([spec],
231 AS_HELP_STRING([--with-spec=SPEC],
72998c2c 232 [Spec files 'generic']),
493972c8
BB
233 [RPM_SPEC_DIR="rpm/$withval"])
234
235 AC_MSG_CHECKING([whether spec files are available])
236 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
237
287b2fb1
BB
238 AC_SUBST(HAVE_RPM)
239 AC_SUBST(RPM)
240 AC_SUBST(RPM_VERSION)
241
242 AC_SUBST(HAVE_RPMBUILD)
243 AC_SUBST(RPMBUILD)
244 AC_SUBST(RPMBUILD_VERSION)
493972c8
BB
245
246 AC_SUBST(RPM_SPEC_DIR)
247 AC_SUBST(RPM_DEFINE_UTIL)
248 AC_SUBST(RPM_DEFINE_KMOD)
249 AC_SUBST(RPM_DEFINE_DKMS)
250 AC_SUBST(RPM_DEFINE_COMMON)
251 AC_SUBST(SRPM_DEFINE_UTIL)
252 AC_SUBST(SRPM_DEFINE_KMOD)
253 AC_SUBST(SRPM_DEFINE_DKMS)
254 AC_SUBST(SRPM_DEFINE_COMMON)
287b2fb1
BB
255])
256
257dnl #
258dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
259dnl # tools are missing it is non-fatal but you will not be able to build
260dnl # DEB packages and will be warned if you try too.
261dnl #
262AC_DEFUN([SPL_AC_DPKG], [
263 DPKG=dpkg
264 DPKGBUILD=dpkg-buildpackage
265
266 AC_MSG_CHECKING([whether $DPKG is available])
267 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
268 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
269 HAVE_DPKG=yes
270 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
271 ],[
272 HAVE_DPKG=no
273 AC_MSG_RESULT([$HAVE_DPKG])
274 ])
275
276 AC_MSG_CHECKING([whether $DPKGBUILD is available])
277 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
278 DPKGBUILD_VERSION=$(echo $tmp | \
279 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
280 HAVE_DPKGBUILD=yes
281 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
282 ],[
283 HAVE_DPKGBUILD=no
284 AC_MSG_RESULT([$HAVE_DPKGBUILD])
285 ])
286
287 AC_SUBST(HAVE_DPKG)
288 AC_SUBST(DPKG)
289 AC_SUBST(DPKG_VERSION)
290
291 AC_SUBST(HAVE_DPKGBUILD)
292 AC_SUBST(DPKGBUILD)
293 AC_SUBST(DPKGBUILD_VERSION)
294])
295
296dnl #
297dnl # Until native packaging for various different packing systems
298dnl # can be added the least we can do is attempt to use alien to
299dnl # convert the RPM packages to the needed package type. This is
300dnl # a hack but so far it has worked reasonable well.
301dnl #
302AC_DEFUN([SPL_AC_ALIEN], [
303 ALIEN=alien
304
305 AC_MSG_CHECKING([whether $ALIEN is available])
306 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
307 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
308 HAVE_ALIEN=yes
309 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
310 ],[
311 HAVE_ALIEN=no
312 AC_MSG_RESULT([$HAVE_ALIEN])
313 ])
314
315 AC_SUBST(HAVE_ALIEN)
316 AC_SUBST(ALIEN)
317 AC_SUBST(ALIEN_VERSION)
318])
319
320dnl #
321dnl # Using the VENDOR tag from config.guess set the default
322dnl # package type for 'make pkg': (rpm | deb | tgz)
323dnl #
324AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
73fc084e 325 AC_MSG_CHECKING([linux distribution])
a3a69b74
BB
326 if test -f /etc/toss-release ; then
327 VENDOR=toss ;
73fc084e
BB
328 elif test -f /etc/fedora-release ; then
329 VENDOR=fedora ;
a3a69b74
BB
330 elif test -f /etc/redhat-release ; then
331 VENDOR=redhat ;
332 elif test -f /etc/gentoo-release ; then
333 VENDOR=gentoo ;
cd2817f8
PS
334 elif test -f /etc/arch-release ; then
335 VENDOR=arch ;
73fc084e
BB
336 elif test -f /etc/SuSE-release ; then
337 VENDOR=sles ;
338 elif test -f /etc/slackware-version ; then
339 VENDOR=slackware ;
a3a69b74
BB
340 elif test -f /etc/lunar.release ; then
341 VENDOR=lunar ;
342 elif test -f /etc/lsb-release ; then
343 VENDOR=ubuntu ;
344 elif test -f /etc/debian_version ; then
345 VENDOR=debian ;
73fc084e
BB
346 else
347 VENDOR= ;
348 fi
349 AC_MSG_RESULT([$VENDOR])
350 AC_SUBST(VENDOR)
287b2fb1
BB
351
352 AC_MSG_CHECKING([default package type])
353 case "$VENDOR" in
a3a69b74
BB
354 toss) DEFAULT_PACKAGE=rpm ;;
355 redhat) DEFAULT_PACKAGE=rpm ;;
356 fedora) DEFAULT_PACKAGE=rpm ;;
357 gentoo) DEFAULT_PACKAGE=tgz ;;
5f0a4b08 358 arch) DEFAULT_PACKAGE=tgz ;;
a3a69b74
BB
359 sles) DEFAULT_PACKAGE=rpm ;;
360 slackware) DEFAULT_PACKAGE=tgz ;;
361 lunar) DEFAULT_PACKAGE=tgz ;;
362 ubuntu) DEFAULT_PACKAGE=deb ;;
363 debian) DEFAULT_PACKAGE=deb ;;
364 *) DEFAULT_PACKAGE=rpm ;;
287b2fb1
BB
365 esac
366
367 AC_MSG_RESULT([$DEFAULT_PACKAGE])
368 AC_SUBST(DEFAULT_PACKAGE)
369])
370
371dnl #
372dnl # Default SPL user configuration
373dnl #
374AC_DEFUN([SPL_AC_PACKAGE], [
0b14b9f3 375 SPL_AC_DEFAULT_PACKAGE
287b2fb1
BB
376 SPL_AC_RPM
377 SPL_AC_DPKG
378 SPL_AC_ALIEN
287b2fb1
BB
379])
380
6a1c3d41 381AC_DEFUN([SPL_AC_LICENSE], [
62032954
BB
382 AC_MSG_CHECKING([spl author])
383 AC_MSG_RESULT([$SPL_META_AUTHOR])
384
86933a6e 385 AC_MSG_CHECKING([spl license])
62032954 386 AC_MSG_RESULT([$SPL_META_LICENSE])
86933a6e
BB
387])
388
389AC_DEFUN([SPL_AC_CONFIG], [
0408008b
ED
390 SPL_CONFIG=all
391 AC_ARG_WITH([config],
392 AS_HELP_STRING([--with-config=CONFIG],
393 [Config file 'kernel|user|all|srpm']),
394 [SPL_CONFIG="$withval"])
395 AC_ARG_ENABLE([linux-builtin],
396 [AC_HELP_STRING([--enable-linux-builtin],
397 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
398 [],
399 [enable_linux_builtin=no])
400
401 AC_MSG_CHECKING([spl config])
402 AC_MSG_RESULT([$SPL_CONFIG]);
403 AC_SUBST(SPL_CONFIG)
404
405 case "$SPL_CONFIG" in
406 kernel) SPL_AC_CONFIG_KERNEL ;;
407 user) SPL_AC_CONFIG_USER ;;
408 all) SPL_AC_CONFIG_KERNEL
409 SPL_AC_CONFIG_USER ;;
c1541dfe 410 srpm) ;;
0408008b
ED
411 *)
412 AC_MSG_RESULT([Error!])
413 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
414 user kernel|user|all|srpm]) ;;
415 esac
416
417 AM_CONDITIONAL([CONFIG_USER],
418 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
419 AM_CONDITIONAL([CONFIG_KERNEL],
420 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
421 [test "x$enable_linux_builtin" != xyes ])
6a1c3d41 422])
423
055ffd98
BB
424dnl #
425dnl # Enable if the SPL should be compiled with internal debugging enabled.
426dnl # By default this support is disabled.
427dnl #
57d86234 428AC_DEFUN([SPL_AC_DEBUG], [
c950d148 429 AC_MSG_CHECKING([whether debugging is enabled])
055ffd98
BB
430 AC_ARG_ENABLE([debug],
431 [AS_HELP_STRING([--enable-debug],
432 [Enable generic debug support @<:@default=no@:>@])],
433 [],
434 [enable_debug=no])
435
436 AS_IF([test "x$enable_debug" = xyes],
c950d148 437 [
c950d148
BB
438 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
439 DEBUG_CFLAGS="-DDEBUG -Werror"
3c208a54
BB
440 DEBUG_SPL="_with_debug"
441 ], [
c950d148
BB
442 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
443 DEBUG_CFLAGS="-DNDEBUG"
3c208a54 444 DEBUG_SPL="_without_debug"
c950d148 445 ])
055ffd98 446
c950d148 447 AC_SUBST(DEBUG_CFLAGS)
3c208a54 448 AC_SUBST(DEBUG_SPL)
055ffd98 449 AC_MSG_RESULT([$enable_debug])
57d86234 450])
451
055ffd98
BB
452dnl #
453dnl # Enabled by default it provides a minimal level of memory tracking.
454dnl # A total count of bytes allocated is kept for each alloc and free.
455dnl # Then at module unload time a report to the console will be printed
456dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
457dnl # and provide an easy way to inspect the kmem based slab.
458dnl #
57d86234 459AC_DEFUN([SPL_AC_DEBUG_KMEM], [
055ffd98
BB
460 AC_ARG_ENABLE([debug-kmem],
461 [AS_HELP_STRING([--enable-debug-kmem],
462 [Enable basic kmem accounting @<:@default=yes@:>@])],
463 [],
464 [enable_debug_kmem=yes])
57d86234 465
055ffd98 466 AS_IF([test "x$enable_debug_kmem" = xyes],
3c208a54
BB
467 [
468 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
469 DEBUG_KMEM="_with_debug_kmem"
470 AC_DEFINE([DEBUG_KMEM], [1],
055ffd98 471 [Define to 1 to enable basic kmem accounting])
3c208a54
BB
472 ], [
473 DEBUG_KMEM="_without_debug_kmem"
474 ])
055ffd98 475
3c208a54 476 AC_SUBST(DEBUG_KMEM)
055ffd98
BB
477 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
478 AC_MSG_RESULT([$enable_debug_kmem])
57d86234 479])
480
055ffd98
BB
481dnl #
482dnl # Disabled by default it provides detailed memory tracking. This
483dnl # feature also requires --enable-debug-kmem to be set. When enabled
484dnl # not only will total bytes be tracked but also the location of every
485dnl # alloc and free. When the SPL module is unloaded a list of all leaked
486dnl # addresses and where they were allocated will be dumped to the console.
487dnl # Enabling this feature has a significant impact on performance but it
488dnl # makes finding memory leaks pretty straight forward.
489dnl #
490AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
491 AC_ARG_ENABLE([debug-kmem-tracking],
492 [AS_HELP_STRING([--enable-debug-kmem-tracking],
493 [Enable detailed kmem tracking @<:@default=no@:>@])],
494 [],
495 [enable_debug_kmem_tracking=no])
496
497 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
3c208a54
BB
498 [
499 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
500 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
501 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
055ffd98 502 [Define to 1 to enable detailed kmem tracking])
3c208a54
BB
503 ], [
504 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
505 ])
055ffd98 506
3c208a54 507 AC_SUBST(DEBUG_KMEM_TRACKING)
055ffd98
BB
508 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
509 AC_MSG_RESULT([$enable_debug_kmem_tracking])
57d86234 510])
511
512dnl #
513dnl # SPL_LINUX_CONFTEST
514dnl #
515AC_DEFUN([SPL_LINUX_CONFTEST], [
dbe561d8 516cat confdefs.h - <<_ACEOF >conftest.c
57d86234 517$1
518_ACEOF
519])
520
521dnl #
522dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
523dnl #
524m4_define([SPL_LANG_PROGRAM], [
525$1
526int
527main (void)
528{
529dnl Do *not* indent the following line: there may be CPP directives.
530dnl Don't move the `;' right after for the same reason.
531$2
532 ;
533 return 0;
534}
535])
536
537dnl #
538dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
539dnl #
540AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460 541 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
df7cc5bc 542 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
c5f70460 543 echo "obj-m := conftest.o" >build/Makefile
df7cc5bc
ED
544 modpost_flag=''
545 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
c5f70460 546 AS_IF(
df7cc5bc
ED
547 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
548 [$4],
549 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
c5f70460
BB
550 )
551 rm -Rf build
57d86234 552])
553
554dnl #
555dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
556dnl #
557AC_DEFUN([SPL_LINUX_TRY_COMPILE],
558 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 559 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
560 [modules],
561 [test -s build/conftest.o],
562 [$3], [$4])
57d86234 563])
564
57d86234 565dnl #
566dnl # SPL_CHECK_SYMBOL_EXPORT
567dnl # check symbol exported or not
568dnl #
723aa3b0 569AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
2e0e7e69
BB
570 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
571 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 572 rc=$?
573 if test $rc -ne 0; then
574 export=0
575 for file in $2; do
2e0e7e69
BB
576 grep -q -E "EXPORT_SYMBOL.*($1)" \
577 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 578 rc=$?
723aa3b0
ED
579 if test $rc -eq 0; then
580 export=1
581 break;
582 fi
57d86234 583 done
723aa3b0 584 if test $export -eq 0; then :
57d86234 585 $4
723aa3b0 586 else :
57d86234 587 $3
588 fi
723aa3b0 589 else :
57d86234 590 $3
591 fi
592])
593
723aa3b0
ED
594dnl #
595dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
596dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
597dnl # is called if not compiling for builtin
598dnl #
599AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
600 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
601 if test $rc -ne 0; then :
602 $6
603 else
604 if test "x$enable_linux_builtin" != xyes; then
605 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
606 fi
607 if test $rc -ne 0; then :
608 $6
609 else :
610 $5
611 fi
612 fi
613])
614
12ff95ff
BB
615dnl #
616dnl # SPL_CHECK_SYMBOL_HEADER
617dnl # check if a symbol prototype is defined in listed headers.
618dnl #
619AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
620 AC_MSG_CHECKING([whether symbol $1 exists in header])
621 header=0
622 for file in $3; do
623 grep -q "$2" "$LINUX/$file" 2>/dev/null
624 rc=$?
723aa3b0
ED
625 if test $rc -eq 0; then
626 header=1
627 break;
628 fi
12ff95ff
BB
629 done
630 if test $header -eq 0; then
631 AC_MSG_RESULT([no])
632 $5
633 else
634 AC_MSG_RESULT([yes])
635 $4
636 fi
637])
638
86de8532 639dnl #
640dnl # SPL_CHECK_HEADER
641dnl # check whether header exists and define HAVE_$2_HEADER
642dnl #
643AC_DEFUN([SPL_CHECK_HEADER],
644 [AC_MSG_CHECKING([whether header $1 exists])
645 SPL_LINUX_TRY_COMPILE([
d50bd9e2 646 #include <$1>
86de8532 647 ],[
648 return 0;
649 ],[
650 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
651 AC_MSG_RESULT(yes)
652 $3
653 ],[
654 AC_MSG_RESULT(no)
655 $4
656 ])
657])
6a6cafbe 658
0408008b 659dnl #
62032954
BB
660dnl # Basic toolchain sanity check. Verify that kernel modules can
661dnl # be built and which symbols can be used.
0408008b
ED
662dnl #
663AC_DEFUN([SPL_AC_TEST_MODULE],
664 [AC_MSG_CHECKING([whether modules can be built])
665 SPL_LINUX_TRY_COMPILE([],[],[
666 AC_MSG_RESULT([yes])
667 ],[
668 AC_MSG_RESULT([no])
669 if test "x$enable_linux_builtin" != xyes; then
670 AC_MSG_ERROR([*** Unable to build an empty module.])
671 else
672 AC_MSG_ERROR([
673 *** Unable to build an empty module.
674 *** Please run 'make scripts' inside the kernel source tree.])
675 fi
676 ])
62032954
BB
677
678 AC_RUN_IFELSE([
679 AC_LANG_PROGRAM([
680 #include "$LINUX/include/linux/license.h"
681 ], [
682 return !license_is_gpl_compatible("$SPL_META_LICENSE");
683 ])
684 ], [
685 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
686 [Define to 1 if GPL-only symbols can be used])
687 ], [
688 ])
0408008b
ED
689])
690
57d86234 691dnl #
d04c8a56
BB
692dnl # Use the atomic implemenation based on global spinlocks. This
693dnl # should only be needed by 32-bit kernels which do not provide
694dnl # the atomic64_* API. It may be optionally enabled as a fallback
695dnl # if problems are observed with the direct mapping to the native
696dnl # Linux atomic operations. You may not disable atomic spinlocks
697dnl # if you kernel does not an atomic64_* API.
57d86234 698dnl #
d04c8a56
BB
699AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
700 AC_ARG_ENABLE([atomic-spinlocks],
701 [AS_HELP_STRING([--enable-atomic-spinlocks],
702 [Atomic types use spinlocks @<:@default=check@:>@])],
703 [],
704 [enable_atomic_spinlocks=check])
57d86234 705
a0f6da3d 706 SPL_LINUX_TRY_COMPILE([
dd3678fc 707 #include <linux/fs.h>
a0f6da3d 708 ],[
03318641 709 atomic64_t *ptr __attribute__ ((unused));
a0f6da3d 710 ],[
d04c8a56 711 have_atomic64_t=yes
a0f6da3d 712 AC_DEFINE(HAVE_ATOMIC64_T, 1,
d04c8a56 713 [kernel defines atomic64_t])
a0f6da3d 714 ],[
d04c8a56
BB
715 have_atomic64_t=no
716 ])
717
718 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
719 AS_IF([test "x$have_atomic64_t" = xyes], [
720 enable_atomic_spinlocks=no
721 ],[
722 enable_atomic_spinlocks=yes
723 ])
a0f6da3d 724 ])
d04c8a56
BB
725
726 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
727 AC_DEFINE([ATOMIC_SPINLOCK], [1],
728 [Atomic types use spinlocks])
729 ],[
730 AS_IF([test "x$have_atomic64_t" = xno], [
731 AC_MSG_FAILURE(
732 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
733 ])
734 ])
735
736 AC_MSG_CHECKING([whether atomic types use spinlocks])
737 AC_MSG_RESULT([$enable_atomic_spinlocks])
738
739 AC_MSG_CHECKING([whether kernel defines atomic64_t])
740 AC_MSG_RESULT([$have_atomic64_t])
a0f6da3d 741])
742
c3d9c0df 743AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
23aa63cb
BB
744 tmp_flags="$EXTRA_KCFLAGS"
745 EXTRA_KCFLAGS="-Werror"
c3d9c0df
RY
746 dnl #
747 dnl # 2.6.23 to 2.6.34 API change
748 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
749 dnl #
750 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
23aa63cb
BB
751 SPL_LINUX_TRY_COMPILE([
752 #include <linux/mm.h>
753
c3d9c0df 754 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
23aa63cb
BB
755 ],[
756 struct shrinker cache_shrinker = {
757 .shrink = shrinker_cb,
758 .seeks = DEFAULT_SEEKS,
759 };
760 register_shrinker(&cache_shrinker);
761 ],[
762 AC_MSG_RESULT(yes)
c3d9c0df
RY
763 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
764 [old shrinker callback wants 2 args])
23aa63cb
BB
765 ],[
766 AC_MSG_RESULT(no)
c3d9c0df
RY
767 dnl #
768 dnl # 2.6.35 - 2.6.39 API change
769 dnl # ->shrink(struct shrinker *,
770 dnl # int nr_to_scan, gfp_t gfp_mask)
771 dnl #
772 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
773 SPL_LINUX_TRY_COMPILE([
774 #include <linux/mm.h>
775
776 int shrinker_cb(struct shrinker *, int nr_to_scan,
777 gfp_t gfp_mask);
778 ],[
779 struct shrinker cache_shrinker = {
780 .shrink = shrinker_cb,
781 .seeks = DEFAULT_SEEKS,
782 };
783 register_shrinker(&cache_shrinker);
784 ],[
785 AC_MSG_RESULT(yes)
786 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
787 [old shrinker callback wants 3 args])
788 ],[
789 AC_MSG_RESULT(no)
790 dnl #
791 dnl # 3.0 - 3.11 API change
792 dnl # ->shrink(struct shrinker *,
793 dnl # struct shrink_control *sc)
794 dnl #
795 AC_MSG_CHECKING(
796 [whether new 2-argument shrinker exists])
797 SPL_LINUX_TRY_COMPILE([
798 #include <linux/mm.h>
799
800 int shrinker_cb(struct shrinker *,
801 struct shrink_control *sc);
802 ],[
803 struct shrinker cache_shrinker = {
804 .shrink = shrinker_cb,
805 .seeks = DEFAULT_SEEKS,
806 };
807 register_shrinker(&cache_shrinker);
808 ],[
809 AC_MSG_RESULT(yes)
810 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
811 [new shrinker callback wants 2 args])
812 ],[
813 AC_MSG_RESULT(no)
814 dnl #
815 dnl # 3.12 API change,
816 dnl # ->shrink() is logically split in to
817 dnl # ->count_objects() and ->scan_objects()
818 dnl #
819 AC_MSG_CHECKING(
820 [whether ->count_objects callback exists])
821 SPL_LINUX_TRY_COMPILE([
822 #include <linux/mm.h>
823
824 unsigned long shrinker_cb(
825 struct shrinker *,
826 struct shrink_control *sc);
827 ],[
828 struct shrinker cache_shrinker = {
829 .count_objects = shrinker_cb,
830 .scan_objects = shrinker_cb,
831 .seeks = DEFAULT_SEEKS,
832 };
833 register_shrinker(&cache_shrinker);
834 ],[
835 AC_MSG_RESULT(yes)
836 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
837 1, [->count_objects exists])
838 ],[
839 AC_MSG_ERROR(error)
840 ])
841 ])
842 ])
23aa63cb
BB
843 ])
844 EXTRA_KCFLAGS="$tmp_flags"
845])
846
79a3bf13
BB
847dnl #
848dnl # 2.6.33 API change,
849dnl # Removed .ctl_name from struct ctl_table.
850dnl #
851AC_DEFUN([SPL_AC_CTL_NAME], [
852 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
853 SPL_LINUX_TRY_COMPILE([
854 #include <linux/sysctl.h>
855 ],[
03318641 856 struct ctl_table ctl __attribute__ ((unused));
79a3bf13
BB
857 ctl.ctl_name = 0;
858 ],[
859 AC_MSG_RESULT(yes)
860 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
861 ],[
862 AC_MSG_RESULT(no)
863 ])
864])
865
1ddf9722
YS
866dnl #
867dnl # 3.10 API change,
868dnl # PDE is replaced by PDE_DATA
869dnl #
870AC_DEFUN([SPL_AC_PDE_DATA], [
871 AC_MSG_CHECKING([whether PDE_DATA() is available])
872 SPL_LINUX_TRY_COMPILE_SYMBOL([
873 #include <linux/proc_fs.h>
874 ], [
875 PDE_DATA(NULL);
876 ], [PDE_DATA], [], [
877 AC_MSG_RESULT(yes)
878 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
879 ],[
880 AC_MSG_RESULT(no)
881 ])
882])
883
a54718cf
RY
884dnl #
885dnl # 3.9 API change
886dnl # set_fs_pwd takes const struct path *
887dnl #
888AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
a54718cf
RY
889 tmp_flags="$EXTRA_KCFLAGS"
890 EXTRA_KCFLAGS="-Werror"
891 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
892 SPL_LINUX_TRY_COMPILE([
893 #include <linux/spinlock.h>
894 #include <linux/fs_struct.h>
895 #include <linux/path.h>
896 void (*const set_fs_pwd_func)
897 (struct fs_struct *, const struct path *)
898 = set_fs_pwd;
899 ],[
900 return 0;
901 ],[
902 AC_MSG_RESULT(yes)
903 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
904 [set_fs_pwd() needs const path *])
905 ],[
906 SPL_LINUX_TRY_COMPILE([
907 #include <linux/spinlock.h>
908 #include <linux/fs_struct.h>
909 #include <linux/path.h>
910 void (*const set_fs_pwd_func)
911 (struct fs_struct *, struct path *)
912 = set_fs_pwd;
913 ],[
914 return 0;
915 ],[
916 AC_MSG_RESULT(no)
917 ],[
918 AC_MSG_ERROR(unknown)
919 ])
920 ])
921 EXTRA_KCFLAGS="$tmp_flags"
a54718cf
RY
922])
923
e39174ed
BB
924dnl #
925dnl # 3.13 API change
926dnl # vfs_unlink() updated to take a third delegated_inode argument.
927dnl #
a093c6a4
BB
928AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
929 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
930 SPL_LINUX_TRY_COMPILE([
931 #include <linux/fs.h>
932 ],[
50a0749e 933 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
a093c6a4
BB
934 ],[
935 AC_MSG_RESULT(yes)
936 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
937 [vfs_unlink() wants 2 args])
938 ],[
939 AC_MSG_RESULT(no)
50a0749e
RY
940 dnl #
941 dnl # Linux 3.13 API change
942 dnl # Added delegated inode
943 dnl #
944 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
945 SPL_LINUX_TRY_COMPILE([
946 #include <linux/fs.h>
947 ],[
948 vfs_unlink((struct inode *) NULL,
949 (struct dentry *) NULL,
950 (struct inode **) NULL);
951 ],[
952 AC_MSG_RESULT(yes)
953 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
954 [vfs_unlink() wants 3 args])
955 ],[
956 AC_MSG_ERROR(no)
957 ])
958
a093c6a4
BB
959 ])
960])
961
e39174ed
BB
962dnl #
963dnl # 3.13 and 3.15 API changes
964dnl # Added delegated inode and flags argument.
965dnl #
a093c6a4
BB
966AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
967 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
968 SPL_LINUX_TRY_COMPILE([
969 #include <linux/fs.h>
970 ],[
50a0749e
RY
971 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
972 (struct inode *) NULL, (struct dentry *) NULL);
a093c6a4
BB
973 ],[
974 AC_MSG_RESULT(yes)
975 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
976 [vfs_rename() wants 4 args])
977 ],[
978 AC_MSG_RESULT(no)
50a0749e
RY
979 dnl #
980 dnl # Linux 3.13 API change
981 dnl # Added delegated inode
982 dnl #
983 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
984 SPL_LINUX_TRY_COMPILE([
985 #include <linux/fs.h>
986 ],[
987 vfs_rename((struct inode *) NULL,
988 (struct dentry *) NULL,
989 (struct inode *) NULL,
990 (struct dentry *) NULL,
991 (struct inode **) NULL);
992 ],[
993 AC_MSG_RESULT(yes)
994 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
995 [vfs_rename() wants 5 args])
996 ],[
ad3412ef
CC
997 AC_MSG_RESULT(no)
998 dnl #
999 dnl # Linux 3.15 API change
1000 dnl # Added flags
1001 dnl #
1002 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1003 SPL_LINUX_TRY_COMPILE([
1004 #include <linux/fs.h>
1005 ],[
1006 vfs_rename((struct inode *) NULL,
1007 (struct dentry *) NULL,
1008 (struct inode *) NULL,
1009 (struct dentry *) NULL,
1010 (struct inode **) NULL,
1011 (unsigned int) 0);
1012 ],[
1013 AC_MSG_RESULT(yes)
1014 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1015 [vfs_rename() wants 6 args])
1016 ],[
1017 AC_MSG_ERROR(no)
1018 ])
50a0749e 1019 ])
a093c6a4
BB
1020 ])
1021])
ec7d53e9 1022
9b2048c2
BB
1023dnl #
1024dnl # 2.6.36 API change,
1025dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1026dnl # a spinlock_t to improve the fastpath performance.
1027dnl #
1028AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1029 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
97fd6a07
BB
1030 tmp_flags="$EXTRA_KCFLAGS"
1031 EXTRA_KCFLAGS="-Werror"
9b2048c2
BB
1032 SPL_LINUX_TRY_COMPILE([
1033 #include <linux/sched.h>
1034 #include <linux/fs_struct.h>
1035 ],[
abb642b9 1036 static struct fs_struct fs;
9b2048c2
BB
1037 spin_lock_init(&fs.lock);
1038 ],[
1039 AC_MSG_RESULT(yes)
1040 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1041 [struct fs_struct uses spinlock_t])
1042 ],[
1043 AC_MSG_RESULT(no)
1044 ])
97fd6a07 1045 EXTRA_KCFLAGS="$tmp_flags"
9b2048c2
BB
1046])
1047
f7fd6ddd
RY
1048dnl #
1049dnl # User namespaces, use kuid_t in place of uid_t
1050dnl # where available. Not strictly a user namespaces thing
1051dnl # but it should prevent surprises
1052dnl #
1053AC_DEFUN([SPL_AC_KUIDGID_T], [
1054 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/uidgid.h>
1057 ], [
1058 kuid_t userid = KUIDT_INIT(0);
1059 kgid_t groupid = KGIDT_INIT(0);
1060 ],[
1061 SPL_LINUX_TRY_COMPILE([
1062 #include <linux/uidgid.h>
1063 ], [
1064 kuid_t userid = 0;
1065 kgid_t groupid = 0;
1066 ],[
1067 AC_MSG_RESULT(yes; optional)
1068 ],[
1069 AC_MSG_RESULT(yes; mandatory)
1070 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1071 ])
1072 ],[
1073 AC_MSG_RESULT(no)
1074 ])
1075])
1076
e811949a 1077dnl #
e03119e8
BB
1078dnl # 2.6.39 API change,
1079dnl # __put_task_struct() was exported by the mainline kernel.
e811949a 1080dnl #
723aa3b0
ED
1081AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1082 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1083 SPL_LINUX_TRY_COMPILE_SYMBOL([
1084 #include <linux/sched.h>
1085 ], [
1086 __put_task_struct(NULL);
1087 ], [__put_task_struct], [], [
1088 AC_MSG_RESULT(yes)
1089 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1090 [__put_task_struct() is available])
1091 ], [
1092 AC_MSG_RESULT(no)
1093 ])
e811949a 1094])
3977f837 1095
f0ff89fc
BB
1096dnl #
1097dnl # 2.6.35 API change,
0d0b5237 1098dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
f0ff89fc 1099dnl #
0d0b5237
BB
1100AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1101 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
f0ff89fc 1102 SPL_LINUX_TRY_COMPILE([
0d0b5237 1103 #include <linux/fs.h>
f0ff89fc 1104 ],[
0d0b5237 1105 vfs_fsync(NULL, 0);
f0ff89fc
BB
1106 ],[
1107 AC_MSG_RESULT(yes)
0d0b5237 1108 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
f0ff89fc
BB
1109 ],[
1110 AC_MSG_RESULT(no)
1111 ])
1112])
46aa7b39 1113
bbdc6ae4
ED
1114dnl #
1115dnl # 3.5 API change,
1116dnl # inode_operations.truncate_range removed
bbdc6ae4
ED
1117dnl #
1118AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1119 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1120 SPL_LINUX_TRY_COMPILE([
1121 #include <linux/fs.h>
1122 ],[
1123 struct inode_operations ops;
1124 ops.truncate_range = NULL;
1125 ],[
1126 AC_MSG_RESULT(yes)
1127 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1128 [truncate_range() inode operation is available])
1129 ],[
1130 AC_MSG_RESULT(no)
1131 ])
1c7b3eaf
BB
1132])
1133
1134dnl #
1135dnl # Linux 2.6.38 - 3.x API
1136dnl #
1137AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1138 AC_MSG_CHECKING([whether fops->fallocate() exists])
1139 SPL_LINUX_TRY_COMPILE([
1140 #include <linux/fs.h>
1141 ],[
1142 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1143 struct file_operations fops __attribute__ ((unused)) = {
1144 .fallocate = fallocate,
1145 };
1146 ],[
1147 AC_MSG_RESULT(yes)
1148 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1149 ],[
1150 AC_MSG_RESULT(no)
1151 ])
1152])
1153
1154dnl #
1155dnl # Linux 2.6.x - 2.6.37 API
1156dnl #
1157AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1158 AC_MSG_CHECKING([whether iops->fallocate() exists])
1159 SPL_LINUX_TRY_COMPILE([
1160 #include <linux/fs.h>
1161 ],[
1162 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1163 struct inode_operations fops __attribute__ ((unused)) = {
1164 .fallocate = fallocate,
1165 };
1166 ],[
1167 AC_MSG_RESULT(yes)
1168 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1169 ],[
1170 AC_MSG_RESULT(no)
1171 ])
1172])
1173
1174dnl #
1175dnl # PaX Linux 2.6.38 - 3.x API
1176dnl #
1177AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1178 AC_MSG_CHECKING([whether fops->fallocate() exists])
1179 SPL_LINUX_TRY_COMPILE([
1180 #include <linux/fs.h>
1181 ],[
1182 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1183 struct file_operations_no_const fops __attribute__ ((unused)) = {
1184 .fallocate = fallocate,
1185 };
1186 ],[
1187 AC_MSG_RESULT(yes)
1188 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1189 ],[
1190 AC_MSG_RESULT(no)
1191 ])
1192])
1193
1194dnl #
1195dnl # The fallocate callback was moved from the inode_operations
1196dnl # structure to the file_operations structure.
1197dnl #
1198AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1199 SPL_AC_KERNEL_FILE_FALLOCATE
1200 SPL_AC_KERNEL_INODE_FALLOCATE
1201 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1202])
bbdc6ae4 1203
46aa7b39
NB
1204dnl #
1205dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1206dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1207dnl # condition. The fixed version is exported as a symbol. The race
1208dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1209dnl # call that version while holding sem->wait_lock.
1210dnl #
723aa3b0
ED
1211AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1212 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1213 SPL_LINUX_TRY_COMPILE_SYMBOL([
1214 #include <linux/rwsem.h>
1215 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1216 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1217 AC_MSG_RESULT(yes)
1218 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1219 [rwsem_is_locked() acquires sem->wait_lock])
1220 ], [
1221 AC_MSG_RESULT(no)
723aa3b0 1222 ])
e76f4bf1 1223])
b1cbc461 1224
42b3ce62
BB
1225dnl #
1226dnl # zlib inflate compat,
1227dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1228dnl #
1229AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1230 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1231 SPL_LINUX_TRY_COMPILE([
1232 #if !defined(CONFIG_ZLIB_INFLATE) && \
1233 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1234 #error CONFIG_ZLIB_INFLATE not defined
1235 #endif
1236 ],[ ],[
1237 AC_MSG_RESULT([yes])
1238 ],[
1239 AC_MSG_RESULT([no])
1240 AC_MSG_ERROR([
1241 *** This kernel does not include the required zlib inflate support.
1242 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1243 ])
1244])
1245
1246dnl #
1247dnl # zlib deflate compat,
1248dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1249dnl #
1250AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1251 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1252 SPL_LINUX_TRY_COMPILE([
1253 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1254 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1255 #error CONFIG_ZLIB_DEFLATE not defined
1256 #endif
1257 ],[ ],[
1258 AC_MSG_RESULT([yes])
1259 ],[
1260 AC_MSG_RESULT([no])
1261 AC_MSG_ERROR([
1262 *** This kernel does not include the required zlib deflate support.
1263 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1264 ])
1265])
1266
3dfc591a
BB
1267dnl #
1268dnl # 2.6.39 API compat,
1269dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1270dnl # This was done to avoid always having to allocate the maximum size
1271dnl # workspace (268K). The caller can now specific the windowBits and
1272dnl # memLevel compression parameters to get a smaller workspace.
1273dnl #
1274AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1275 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1276 SPL_LINUX_TRY_COMPILE([
1277 #include <linux/zlib.h>
1278 ],[
1279 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1280 ],[
1281 AC_MSG_RESULT(yes)
1282 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1283 [zlib_deflate_workspacesize() wants 2 args])
1284 ],[
1285 AC_MSG_RESULT(no)
1286 ])
1287])
a55bcaad
BB
1288
1289dnl #
1290dnl # 2.6.39 API change,
1291dnl # Shrinker adjust to use common shrink_control structure.
1292dnl #
1293AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1294 AC_MSG_CHECKING([whether struct shrink_control exists])
1295 SPL_LINUX_TRY_COMPILE([
1296 #include <linux/mm.h>
1297 ],[
1298 struct shrink_control sc __attribute__ ((unused));
1299
1300 sc.nr_to_scan = 0;
1301 sc.gfp_mask = GFP_KERNEL;
1302 ],[
1303 AC_MSG_RESULT(yes)
1304 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1305 [struct shrink_control exists])
1306 ],[
1307 AC_MSG_RESULT(no)
1308 ])
1309])
588d9004
DH
1310
1311dnl #
1312dnl # 3.1 API Change
1313dnl #
1314dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1315dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1316dnl #
1317AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1318 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1319 tmp_flags="$EXTRA_KCFLAGS"
1320 EXTRA_KCFLAGS="-Werror"
1321 SPL_LINUX_TRY_COMPILE([
1322 #include <linux/rwsem.h>
1323 ],[
1324 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1325 raw_spinlock_t dummy_lock __attribute__ ((unused));
1326 dummy_semaphore.wait_lock = dummy_lock;
1327 ],[
1328 AC_MSG_RESULT(yes)
1329 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1330 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1331 ],[
1332 AC_MSG_RESULT(no)
1333 ])
1334 EXTRA_KCFLAGS="$tmp_flags"
1335])
10087fe1
RY
1336
1337dnl #
1338dnl # 3.9 API change,
1339dnl # Moved things from linux/sched.h to linux/sched/rt.h
1340dnl #
1341AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1342 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1343 SPL_LINUX_TRY_COMPILE([
1344 #include <linux/sched.h>
1345 #include <linux/sched/rt.h>
1346 ],[
1347 return 0;
1348 ],[
1349 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1350 AC_MSG_RESULT(yes)
1351 ],[
1352 AC_MSG_RESULT(no)
1353 ])
1354])
2a305c34
RY
1355
1356dnl #
1357dnl # 3.9 API change,
1358dnl # vfs_getattr() uses 2 args
1359dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1360dnl #
1361AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1362 AC_MSG_CHECKING([whether vfs_getattr() wants])
1363 SPL_LINUX_TRY_COMPILE([
1364 #include <linux/fs.h>
1365 ],[
1366 vfs_getattr((struct path *) NULL,
1367 (struct kstat *)NULL);
1368 ],[
1369 AC_MSG_RESULT(2 args)
1370 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1371 [vfs_getattr wants 2 args])
1372 ],[
1373 SPL_LINUX_TRY_COMPILE([
1374 #include <linux/fs.h>
1375 ],[
1376 vfs_getattr((struct vfsmount *)NULL,
1377 (struct dentry *)NULL,
1378 (struct kstat *)NULL);
1379 ],[
1380 AC_MSG_RESULT(3 args)
1381 ],[
1382 AC_MSG_ERROR(unknown)
1383 ])
1384 ])
1385])
184c6873
NB
1386
1387dnl #
1388dnl # 2.6.36 API compatibility.
1389dnl # Added usleep_range timer.
1390dnl # usleep_range is a finer precision implementation of msleep
1391dnl # designed to be a drop-in replacement for udelay where a precise
1392dnl # sleep / busy-wait is unnecessary.
1393dnl #
1394AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1395 AC_MSG_CHECKING([whether usleep_range() is available])
1396 SPL_LINUX_TRY_COMPILE([
1397 #include <linux/delay.h>
1398 ],[
1399 usleep_range(0, 0);
1400 ],[
1401 AC_MSG_RESULT(yes)
1402 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1403 [usleep_range is available])
1404 ],[
1405 AC_MSG_RESULT(no)
1406 ])
1407])
a073aeb0
BB
1408
1409dnl #
1410dnl # 2.6.35 API change,
1411dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1412dnl # private allocation flags which are applied when allocating a new slab
1413dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1414dnl # non-default flags.
1415dnl #
1416AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1417 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1418 SPL_LINUX_TRY_COMPILE([
1419 #include <linux/slab.h>
1420 ],[
1421 struct kmem_cache cachep __attribute__ ((unused));
1422 cachep.allocflags = GFP_KERNEL;
1423 ],[
1424 AC_MSG_RESULT(yes)
1425 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1426 [struct kmem_cache has allocflags])
1427 ],[
1428 AC_MSG_RESULT(no)
1429
1430 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1431 SPL_LINUX_TRY_COMPILE([
1432 #include <linux/slab.h>
1433 ],[
1434 struct kmem_cache cachep __attribute__ ((unused));
1435 cachep.gfpflags = GFP_KERNEL;
1436 ],[
1437 AC_MSG_RESULT(yes)
1438 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1439 [struct kmem_cache has gfpflags])
1440 ],[
1441 AC_MSG_RESULT(no)
1442 ])
1443 ])
1444])
2fc44f66
NB
1445
1446dnl #
1447dnl # 3.17 API change,
1448dnl # wait_on_bit() no longer requires an action argument. The former
1449dnl # "wait_on_bit" interface required an 'action' function to be provided
1450dnl # which does the actual waiting. There were over 20 such functions in the
1451dnl # kernel, many of them identical, though most cases can be satisfied by one
1452dnl # of just two functions: one which uses io_schedule() and one which just
1453dnl # uses schedule(). This API change was made to consolidate all of those
1454dnl # redundant wait functions.
1455dnl #
1456AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1457 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1458 SPL_LINUX_TRY_COMPILE([
1459 #include <linux/wait.h>
1460 ],[
1461 int (*action)(void *) = NULL;
1462 wait_on_bit(NULL, 0, action, 0);
1463 ],[
1464 AC_MSG_RESULT(yes)
1465 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1466 ],[
1467 AC_MSG_RESULT(no)
1468 ])
1469])