While most of ioctl-related kernel headers are now exported by kernel's
headers_install, some are still modules_install only. The kernel's
headers installed into /usr/include/ are usually headers_install'ed and
therefore don't contain some internal headers we need. The solution is
to look for modules_install'ed headers for the running kernel, and fall
back to old behavior if they aren't found.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner --mode=go-w,go+rX
-IOCTLDIR = /usr/include
-IOCTLASM = asm
-IOCTLSORT_INCLUDEDIR = $(IOCTLDIR)
+INCLUDEDIR = /usr/include
+KERNEL_RELEASE = $(shell uname -r)
+# Candidates for the kernel headers tree.
+KERNEL_INCLUDE = \
+ /lib/modules/$(KERNEL_RELEASE)/build/include \
+ /usr/src/linux-$(KERNEL_RELEASE)/include \
+ $(INCLUDEDIR)
+IOCTLDIR = $(shell find $(KERNEL_INCLUDE) -maxdepth 0 -type d -print -quit 2>/dev/null)
+IOCTLASM = $(INCLUDEDIR)/asm
+IOCTLSORT_INCLUDEDIR = $(INCLUDEDIR)
ioctlent_h_in = linux/ioctlent.h.in