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-08 00:03:12 +03:00
|
|
|
include Kbuild
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2013-02-17 23:05:11 +04:00
|
|
|
INSTALL_MOD_DIR ?= extra
|
|
|
|
|
2018-02-08 19:16:23 +03:00
|
|
|
SUBDIR_TARGETS = icp lua
|
2016-05-12 17:51:24 +03:00
|
|
|
|
2019-09-06 21:26:26 +03: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 05:13:02 +03: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 20:33:56 +03: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 21:26:26 +03:00
|
|
|
modules-Linux:
|
2016-05-12 17:51:24 +03:00
|
|
|
list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
|
|
|
|
$(MAKE) -C $$targetdir; \
|
|
|
|
done
|
2019-09-06 21:26:26 +03:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules-FreeBSD:
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE)
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules-unknown:
|
|
|
|
@true
|
|
|
|
|
|
|
|
modules: modules-@ac_system@
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
clean-Linux:
|
2011-04-06 00:13:01 +04:00
|
|
|
@# Only cleanup the kernel build directories when CONFIG_KERNEL
|
|
|
|
@# is defined. This indicates that kernel modules should be built.
|
2019-09-06 21:26:26 +03:00
|
|
|
@CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean
|
2011-04-06 00:13:01 +04:00
|
|
|
|
2010-08-26 22:22:58 +04:00
|
|
|
if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
|
|
|
|
if [ -f Module.markers ]; then $(RM) Module.markers; fi
|
|
|
|
|
2018-05-14 04:59:02 +03:00
|
|
|
find . -name '*.ur-safe' -type f -print | xargs $(RM)
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
clean-FreeBSD:
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE) clean
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
clean: clean-@ac_system@
|
|
|
|
|
|
|
|
modules_install-Linux:
|
2010-09-05 00:26:23 +04:00
|
|
|
@# Install the kernel modules
|
2019-09-06 21:26:26 +03:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
|
2013-02-17 23:05:11 +04:00
|
|
|
INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
|
2014-10-22 22:02:45 +04:00
|
|
|
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
|
|
|
|
KERNELRELEASE=@LINUX_VERSION@
|
2011-07-20 08:44:07 +04:00
|
|
|
@# Remove extraneous build products when packaging
|
2013-02-17 23:05:11 +04:00
|
|
|
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
|
2015-11-20 04:42:41 +03:00
|
|
|
if [ -n "$(DESTDIR)" ]; then \
|
2013-02-17 23:05:11 +04:00
|
|
|
find $$kmoddir -name 'modules.*' | xargs $(RM); \
|
2011-07-20 08:44:07 +04:00
|
|
|
fi
|
2013-02-17 23:05:11 +04:00
|
|
|
sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
|
2010-08-26 22:22:58 +04:00
|
|
|
if [ -f $$sysmap ]; then \
|
|
|
|
depmod -ae -F $$sysmap @LINUX_VERSION@; \
|
|
|
|
fi
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules_install-FreeBSD:
|
|
|
|
@# Install the kernel modules
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE) install
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules_install: modules_install-@ac_system@
|
|
|
|
|
|
|
|
modules_uninstall-Linux:
|
2010-09-05 00:26:23 +04: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 05:13:02 +03:00
|
|
|
kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ \
|
2020-06-25 21:04:50 +03:00
|
|
|
for objdir in $(ZFS_MODULES); do \
|
2019-08-20 01:22:52 +03:00
|
|
|
$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
|
2013-02-17 23:05:11 +04:00
|
|
|
done
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules_uninstall-FreeBSD:
|
|
|
|
@false
|
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules_uninstall: modules_uninstall-@ac_system@
|
|
|
|
|
2010-08-26 22:22:58 +04:00
|
|
|
distdir:
|
2020-06-25 21:04:50 +03: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
|