7 echo "usage: $0 <kernel source tree>" >&2
11 [ "$#" -eq 1 ] || usage
12 KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
15 for MODULE_DIR in module/*
17 [ -d "$MODULE_DIR" ] || continue
18 MODULES+=("${MODULE_DIR##*/}")
21 if ! [ -e 'zfs_config.h' ]
24 echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
25 echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
32 rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
33 cp --recursive include "$KERNEL_DIR/include/zfs"
34 cp --recursive module "$KERNEL_DIR/fs/zfs"
35 cp zfs_config.h "$KERNEL_DIR/"
37 for MODULE in "${MODULES[@]}"
39 sed -i.bak '/obj =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
40 sed -i.bak '/src =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
43 cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
45 tristate "ZFS filesystem support"
47 depends on EFI_PARTITION
51 This is the ZFS filesystem from the ZFS On Linux project.
53 See http://zfsonlinux.org/
55 To compile this file system support as a module, choose M here.
62 ZFS_MODULE_CFLAGS = -I$(srctree)/include/zfs -I$(srctree)/include/spl
63 ZFS_MODULE_CFLAGS += -include $(srctree)/spl_config.h -include $(srctree)/zfs_config.h
64 export ZFS_MODULE_CFLAGS
69 for MODULE in "${MODULES[@]}"
71 echo 'obj-$(CONFIG_ZFS) += ' "$MODULE/"
73 } > "$KERNEL_DIR/fs/zfs/Kbuild"
82 while IFS='' read -r LINE
86 if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
90 if IFS='' read -r LINE
92 [ "$LINE" != "$NEW" ] && echo "$LINE"
95 done < "$FILE" > "$FILE.new"
97 mv "$FILE.new" "$FILE"
100 add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
101 add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
104 echo " $0: done." >&2
105 echo " $0: now you can build the kernel with ZFS support." >&2
106 echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2