Cleanup linux module kbuild files
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.
Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.
Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.
The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
commit 70835c5b755e ("Unify target_cpu handling")
os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10379
Closes #10421
2020-06-07 21:03:12 +00:00
|
|
|
include Kbuild
|
2010-08-26 18:22:58 +00:00
|
|
|
|
2013-02-17 19:05:11 +00:00
|
|
|
INSTALL_MOD_DIR ?= extra
|
|
|
|
|
2018-02-08 16:16:23 +00:00
|
|
|
SUBDIR_TARGETS = icp lua
|
2016-05-12 14:51:24 +00:00
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
all: modules
|
|
|
|
distclean maintainer-clean: clean
|
|
|
|
install: modules_install
|
|
|
|
uninstall: modules_uninstall
|
|
|
|
check:
|
|
|
|
|
Fix tags targets in module/Makefile.in + cleanup
These targets look to have been copied from an automake-generated
Makefile.in, and can't work since none of the auto-generated automake
variables are defined here.
Moreover, ctags has been overridden in the top-level Makefile, so the
target is pointless anyway, and gtags is not a recursive target.
Fix cscopelist by moving it to the top-level Makefile as well, in line
with ctags and etags.
Also, add -a to ctags command as well, otherwise it won't work if more
than one xargs invocation takes place.
Add assembler files to ctags/etags, prune all dotted-dirs, and restrict
the find to files only.
Cleanup: add .PHONY to module/Makefile.in, and fix one recipe with a
missing continuation character.
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10493
2020-06-22 02:13:02 +00:00
|
|
|
.PHONY: all distclean maintainer-clean install uninstall check distdir \
|
|
|
|
modules modules-Linux modules-FreeBSD modules-unknown \
|
|
|
|
clean clean-Linux clean-FreeBSD \
|
|
|
|
modules_install modules_install-Linux modules_install-FreeBSD \
|
|
|
|
modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD
|
|
|
|
|
2020-06-19 17:33:56 +00:00
|
|
|
# Filter out options that FreeBSD make doesn't understand
|
|
|
|
getflags = ( \
|
|
|
|
set -- \
|
|
|
|
$(filter-out --%,$(firstword $(MFLAGS))) \
|
|
|
|
$(filter -I%,$(MFLAGS)) \
|
|
|
|
$(filter -j%,$(MFLAGS)); \
|
|
|
|
fmakeflags=""; \
|
|
|
|
while getopts :deiI:j:knqrstw flag; do \
|
|
|
|
case $$flag in \
|
|
|
|
\?) :;; \
|
|
|
|
:) if [ $$OPTARG = "j" ]; then \
|
|
|
|
ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \
|
|
|
|
if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \
|
|
|
|
fi;; \
|
|
|
|
d) fmakeflags="$$fmakeflags -dA";; \
|
|
|
|
*) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \
|
|
|
|
esac; \
|
|
|
|
done; \
|
|
|
|
echo $$fmakeflags \
|
|
|
|
)
|
|
|
|
FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags))
|
|
|
|
|
|
|
|
ifneq (@abs_srcdir@,@abs_builddir@)
|
|
|
|
FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@
|
|
|
|
endif
|
|
|
|
FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS)
|
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
modules-Linux:
|
2016-05-12 14:51:24 +00:00
|
|
|
list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
|
|
|
|
$(MAKE) -C $$targetdir; \
|
|
|
|
done
|
2019-09-06 18:26:26 +00:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
|
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
modules-FreeBSD:
|
2020-06-19 17:33:56 +00:00
|
|
|
+$(FMAKE)
|
2020-04-14 18:36:28 +00:00
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
modules-unknown:
|
|
|
|
@true
|
|
|
|
|
|
|
|
modules: modules-@ac_system@
|
2010-08-26 18:22:58 +00:00
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
clean-Linux:
|
2011-04-05 20:13:01 +00:00
|
|
|
@# Only cleanup the kernel build directories when CONFIG_KERNEL
|
|
|
|
@# is defined. This indicates that kernel modules should be built.
|
2019-09-06 18:26:26 +00:00
|
|
|
@CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean
|
2011-04-05 20:13:01 +00:00
|
|
|
|
2010-08-26 18:22:58 +00:00
|
|
|
if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
|
|
|
|
if [ -f Module.markers ]; then $(RM) Module.markers; fi
|
|
|
|
|
2018-05-14 01:59:02 +00:00
|
|
|
find . -name '*.ur-safe' -type f -print | xargs $(RM)
|
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
clean-FreeBSD:
|
2020-06-19 17:33:56 +00:00
|
|
|
+$(FMAKE) clean
|
2020-04-14 18:36:28 +00:00
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
clean: clean-@ac_system@
|
|
|
|
|
|
|
|
modules_install-Linux:
|
2010-09-04 20:26:23 +00:00
|
|
|
@# Install the kernel modules
|
2019-09-06 18:26:26 +00:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
|
2013-02-17 19:05:11 +00:00
|
|
|
INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
|
2014-10-22 18:02:45 +00:00
|
|
|
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
|
|
|
|
KERNELRELEASE=@LINUX_VERSION@
|
2011-07-20 04:44:07 +00:00
|
|
|
@# Remove extraneous build products when packaging
|
2013-02-17 19:05:11 +00:00
|
|
|
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
|
2015-11-20 01:42:41 +00:00
|
|
|
if [ -n "$(DESTDIR)" ]; then \
|
2013-02-17 19:05:11 +00:00
|
|
|
find $$kmoddir -name 'modules.*' | xargs $(RM); \
|
2011-07-20 04:44:07 +00:00
|
|
|
fi
|
2013-02-17 19:05:11 +00:00
|
|
|
sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
|
2010-08-26 18:22:58 +00:00
|
|
|
if [ -f $$sysmap ]; then \
|
|
|
|
depmod -ae -F $$sysmap @LINUX_VERSION@; \
|
|
|
|
fi
|
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
modules_install-FreeBSD:
|
|
|
|
@# Install the kernel modules
|
2020-06-19 17:33:56 +00:00
|
|
|
+$(FMAKE) install
|
2020-04-14 18:36:28 +00:00
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
modules_install: modules_install-@ac_system@
|
|
|
|
|
|
|
|
modules_uninstall-Linux:
|
2010-09-04 20:26:23 +00:00
|
|
|
@# Uninstall the kernel modules
|
Fix tags targets in module/Makefile.in + cleanup
These targets look to have been copied from an automake-generated
Makefile.in, and can't work since none of the auto-generated automake
variables are defined here.
Moreover, ctags has been overridden in the top-level Makefile, so the
target is pointless anyway, and gtags is not a recursive target.
Fix cscopelist by moving it to the top-level Makefile as well, in line
with ctags and etags.
Also, add -a to ctags command as well, otherwise it won't work if more
than one xargs invocation takes place.
Add assembler files to ctags/etags, prune all dotted-dirs, and restrict
the find to files only.
Cleanup: add .PHONY to module/Makefile.in, and fix one recipe with a
missing continuation character.
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10493
2020-06-22 02:13:02 +00:00
|
|
|
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ \
|
2020-06-25 18:04:50 +00:00
|
|
|
for objdir in $(ZFS_MODULES); do \
|
2019-08-19 22:22:52 +00:00
|
|
|
$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
|
2013-02-17 19:05:11 +00:00
|
|
|
done
|
2010-08-26 18:22:58 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
modules_uninstall-FreeBSD:
|
|
|
|
@false
|
|
|
|
|
2019-09-06 18:26:26 +00:00
|
|
|
modules_uninstall: modules_uninstall-@ac_system@
|
|
|
|
|
2010-08-26 18:22:58 +00:00
|
|
|
distdir:
|
2020-06-25 18:04:50 +00:00
|
|
|
(cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \
|
|
|
|
while read path; do \
|
|
|
|
mkdir -p $$distdir/$${path%/*}; \
|
|
|
|
cp @srcdir@/$$path $$distdir/$$path; \
|
|
|
|
done; \
|
|
|
|
cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd
|