71504277ae
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
80 lines
1.7 KiB
Bash
Executable File
80 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
usage()
|
|
{
|
|
echo "usage: $0 <kernel source tree>" >&2
|
|
exit 1
|
|
}
|
|
|
|
[ "$#" -eq 1 ] || usage
|
|
KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
|
|
|
|
if ! [ -e 'zfs_config.h' ]
|
|
then
|
|
echo >&2
|
|
echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
|
|
echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
|
|
echo >&2
|
|
exit 1
|
|
fi
|
|
|
|
make clean || true
|
|
scripts/make_gitrev.sh || true
|
|
|
|
rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
|
|
cp --recursive include "$KERNEL_DIR/include/zfs"
|
|
cp --recursive module "$KERNEL_DIR/fs/zfs"
|
|
cp zfs_config.h "$KERNEL_DIR/include/zfs/"
|
|
|
|
cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
|
|
config ZFS
|
|
tristate "ZFS filesystem support"
|
|
depends on EFI_PARTITION
|
|
select ZLIB_INFLATE
|
|
select ZLIB_DEFLATE
|
|
help
|
|
This is the ZFS filesystem from the ZFS On Linux project.
|
|
|
|
See https://zfsonlinux.org/
|
|
|
|
To compile this file system support as a module, choose M here.
|
|
|
|
If unsure, say N.
|
|
EOF
|
|
|
|
add_after()
|
|
{
|
|
local FILE="$1"
|
|
local MARKER="$2"
|
|
local NEW="$3"
|
|
local LINE
|
|
|
|
while IFS='' read -r LINE
|
|
do
|
|
echo "$LINE"
|
|
|
|
if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
|
|
then
|
|
echo "$NEW"
|
|
MARKER=''
|
|
if IFS='' read -r LINE
|
|
then
|
|
[ "$LINE" != "$NEW" ] && echo "$LINE"
|
|
fi
|
|
fi
|
|
done < "$FILE" > "$FILE.new"
|
|
|
|
mv "$FILE.new" "$FILE"
|
|
}
|
|
|
|
add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
|
|
add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
|
|
|
|
echo >&2
|
|
echo " $0: done." >&2
|
|
echo " $0: now you can build the kernel with ZFS support." >&2
|
|
echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2
|
|
echo >&2
|