aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/.gitignore1
-rw-r--r--module/Kbuild.in44
-rw-r--r--module/Makefile.in30
-rw-r--r--module/avl/Makefile.in6
-rw-r--r--module/icp/Makefile.in13
-rw-r--r--module/lua/Makefile.in11
-rw-r--r--module/nvpair/Makefile.in6
-rw-r--r--module/os/Makefile.in1
-rw-r--r--module/os/linux/Makefile.in1
-rw-r--r--module/os/linux/zfs/Makefile.in2
-rw-r--r--module/spl/Makefile.in12
-rw-r--r--module/unicode/Makefile.in6
-rw-r--r--module/zcommon/Makefile.in7
-rw-r--r--module/zfs/Makefile.in15
14 files changed, 86 insertions, 69 deletions
diff --git a/module/.gitignore b/module/.gitignore
index 5f3d70487..7a4bd3673 100644
--- a/module/.gitignore
+++ b/module/.gitignore
@@ -9,6 +9,7 @@
.*.d
*.mod
+/Kbuild
/.cache.mk
/.tmp_versions
/Module.markers
diff --git a/module/Kbuild.in b/module/Kbuild.in
new file mode 100644
index 000000000..b42ce9e6d
--- /dev/null
+++ b/module/Kbuild.in
@@ -0,0 +1,44 @@
+# When integrated in to a monolithic kernel the spl module must appear
+# first. This ensures its module initialization function is run before
+# any of the other module initialization functions which depend on it.
+ZFS_MODULES += spl/
+ZFS_MODULES += avl/
+ZFS_MODULES += icp/
+ZFS_MODULES += lua/
+ZFS_MODULES += nvpair/
+ZFS_MODULES += unicode/
+ZFS_MODULES += zcommon/
+ZFS_MODULES += zfs/
+
+# The rest is only relevant when run by kbuild
+ifneq ($(KERNELRELEASE),)
+
+obj-$(CONFIG_ZFS) := $(ZFS_MODULES)
+
+ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
+ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@
+
+ifneq ($(KBUILD_EXTMOD),)
+zfs_include = @abs_top_srcdir@/include
+ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
+else
+zfs_include = $(srctree)/include/zfs
+ZFS_MODULE_CFLAGS += -include $(zfs_include)/zfs_config.h
+endif
+
+ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/kernel
+ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/spl
+ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/zfs
+ZFS_MODULE_CFLAGS += -I$(zfs_include)
+ZFS_MODULE_CPPFLAGS += -D_KERNEL
+ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
+
+ifneq ($(KBUILD_EXTMOD),)
+@CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
+@CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
+endif
+
+subdir-asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+subdir-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
+endif
diff --git a/module/Makefile.in b/module/Makefile.in
index 39acdac20..3485649dc 100644
--- a/module/Makefile.in
+++ b/module/Makefile.in
@@ -1,31 +1,7 @@
-obj-m += avl/
-obj-m += icp/
-obj-m += lua/
-obj-m += nvpair/
-obj-m += spl/
-obj-m += os/linux/spl/
-obj-m += unicode/
-obj-m += zcommon/
-obj-m += zfs/
-obj-m += os/linux/zfs/
+include Kbuild
INSTALL_MOD_DIR ?= extra
-ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
-ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@
-ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
-ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/kernel
-ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/spl
-ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/zfs
-ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include
-ZFS_MODULE_CPPFLAGS += -D_KERNEL
-ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
-
-@CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
-@CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
-
-export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS
-
SUBDIR_TARGETS = icp lua
all: modules
@@ -119,7 +95,7 @@ modules_install: modules_install-@ac_system@
modules_uninstall-Linux:
@# Uninstall the kernel modules
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@
- list='$(obj-m)'; for objdir in $$list; do \
+ list='$(ZFS_MODULES)'; for objdir in $$list; do \
$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
done
@@ -129,7 +105,7 @@ modules_uninstall-FreeBSD:
modules_uninstall: modules_uninstall-@ac_system@
distdir:
- list='$(obj-m)'; for objdir in $$list; do \
+ list='$(ZFS_MODULES)'; for objdir in $$list os/linux/spl os/linux/zfs; do \
(cd @top_srcdir@/module && find $$objdir -name '*.[chS]' | \
while read path; do \
mkdir -p @abs_top_builddir@/module/$$distdir/$${path%/*}; \
diff --git a/module/avl/Makefile.in b/module/avl/Makefile.in
index 217fa3ca5..991d5f95b 100644
--- a/module/avl/Makefile.in
+++ b/module/avl/Makefile.in
@@ -1,10 +1,10 @@
-src = @abs_top_srcdir@/module/avl
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+endif
MODULE := zavl
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
$(MODULE)-objs += avl.o
diff --git a/module/icp/Makefile.in b/module/icp/Makefile.in
index b6d34d15a..7a01b2f08 100644
--- a/module/icp/Makefile.in
+++ b/module/icp/Makefile.in
@@ -1,14 +1,17 @@
-src = @abs_top_srcdir@/module/icp
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+icp_include = $(src)/include
+else
+icp_include = $(srctree)/$(src)/include
+endif
MODULE := icp
obj-$(CONFIG_ZFS) := $(MODULE).o
-asflags-y := -I@abs_top_srcdir@/module/icp/include
-asflags-y += $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-ccflags-y := -I@abs_top_srcdir@/module/icp/include
-ccflags-y += $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+asflags-y := -I$(icp_include)
+ccflags-y := -I$(icp_include)
$(MODULE)-objs += illumos-crypto.o
$(MODULE)-objs += api/kcf_cipher.o
diff --git a/module/lua/Makefile.in b/module/lua/Makefile.in
index d49065fbe..0a74c17e6 100644
--- a/module/lua/Makefile.in
+++ b/module/lua/Makefile.in
@@ -1,16 +1,13 @@
-src = @abs_top_srcdir@/module/lua
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+endif
MODULE := zlua
obj-$(CONFIG_ZFS) := $(MODULE).o
-asflags-y += $(ZFS_MODULE_CFLAGS)
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-ccflags-y += -DLUA_USE_LONGLONG
-
-# Suppress unused but set variable warnings often due to ASSERTs
-ccflags-y += $(NO_UNUSED_BUT_SET_VARIABLE)
+ccflags-y := -DLUA_USE_LONGLONG
$(MODULE)-objs += lapi.o
$(MODULE)-objs += lauxlib.o
diff --git a/module/nvpair/Makefile.in b/module/nvpair/Makefile.in
index f420ef98b..d81452366 100644
--- a/module/nvpair/Makefile.in
+++ b/module/nvpair/Makefile.in
@@ -1,12 +1,12 @@
-src = @abs_top_srcdir@/module/nvpair
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+endif
MODULE := znvpair
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
$(MODULE)-objs += nvpair.o
$(MODULE)-objs += fnvpair.o
$(MODULE)-objs += nvpair_alloc_spl.o
diff --git a/module/os/Makefile.in b/module/os/Makefile.in
deleted file mode 100644
index b9990d1bc..000000000
--- a/module/os/Makefile.in
+++ /dev/null
@@ -1 +0,0 @@
-subdirs-m = linux
diff --git a/module/os/linux/Makefile.in b/module/os/linux/Makefile.in
deleted file mode 100644
index ab01708a3..000000000
--- a/module/os/linux/Makefile.in
+++ /dev/null
@@ -1 +0,0 @@
-subdirs-m = spl zfs
diff --git a/module/os/linux/zfs/Makefile.in b/module/os/linux/zfs/Makefile.in
index cb4edbbc1..9f493ef16 100644
--- a/module/os/linux/zfs/Makefile.in
+++ b/module/os/linux/zfs/Makefile.in
@@ -5,8 +5,6 @@
# Suppress unused-value warnings in sparc64 architecture headers
ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
-ccflags-y += -I@abs_top_srcdir@/module/os/linux/zfs
-
$(MODULE)-objs += ../os/linux/zfs/abd_os.o
$(MODULE)-objs += ../os/linux/zfs/arc_os.o
$(MODULE)-objs += ../os/linux/zfs/mmp_os.o
diff --git a/module/spl/Makefile.in b/module/spl/Makefile.in
index 8602f4edd..cedbfe92b 100644
--- a/module/spl/Makefile.in
+++ b/module/spl/Makefile.in
@@ -1,11 +1,13 @@
-src = @abs_top_srcdir@/module/spl
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+mfdir = $(obj)
+else
+mfdir = $(srctree)/$(src)
+endif
MODULE := spl
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
-
--include @abs_top_builddir@/module/os/linux/spl/Makefile
+include $(mfdir)/../os/linux/spl/Makefile
diff --git a/module/unicode/Makefile.in b/module/unicode/Makefile.in
index 82c90373a..59c07c455 100644
--- a/module/unicode/Makefile.in
+++ b/module/unicode/Makefile.in
@@ -1,11 +1,11 @@
-src = @abs_top_srcdir@/module/unicode
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
+endif
MODULE := zunicode
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
$(MODULE)-objs += u8_textprep.o
$(MODULE)-objs += uconv.o
diff --git a/module/zcommon/Makefile.in b/module/zcommon/Makefile.in
index 01e0692eb..b5cdf4c0c 100644
--- a/module/zcommon/Makefile.in
+++ b/module/zcommon/Makefile.in
@@ -1,13 +1,12 @@
-src = @abs_top_srcdir@/module/zcommon
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
-target_cpu = @target_cpu@
+endif
MODULE := zcommon
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
# Suppress unused-value warnings in sparc64 architecture headers
ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in
index 3a9663997..7ea976d12 100644
--- a/module/zfs/Makefile.in
+++ b/module/zfs/Makefile.in
@@ -1,16 +1,15 @@
-src = @abs_top_srcdir@/module/zfs
+ifneq ($(KBUILD_EXTMOD),)
+src = @abs_srcdir@
obj = @abs_builddir@
-target_cpu = @target_cpu@
+mfdir = $(obj)
+else
+mfdir = $(srctree)/$(src)
+endif
MODULE := zfs
obj-$(CONFIG_ZFS) := $(MODULE).o
-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
-
-# Suppress unused but set variable warnings often due to ASSERTs
-ccflags-y += $(NO_UNUSED_BUT_SET_VARIABLE)
-
# Suppress unused-value warnings in sparc64 architecture headers
ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
@@ -150,4 +149,4 @@ ifeq ($(CONFIG_ALTIVEC),y)
$(obj)/vdev_raidz_math_powerpc_altivec.o: c_flags += -maltivec
endif
--include @abs_top_builddir@/module/os/linux/zfs/Makefile
+include $(mfdir)/../os/linux/zfs/Makefile