7 echo "usage: $0 <kernel source tree>" >&2
11 [ "$#" -eq 1 ] || usage
12 KERNEL_DIR
="$(readlink --canonicalize-existing "$1")"
16 for MODULE_DIR
in module
/*
18 [ -d "$MODULE_DIR" ] ||
continue
19 [ "spl" = "${MODULE_DIR##*/}" ] && continue
20 MODULES
+=("${MODULE_DIR##*/}")
23 if ! [ -e 'zfs_config.h' ]
26 echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
27 echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
33 scripts
/make_gitrev.sh || true
35 rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
36 cp --recursive include
"$KERNEL_DIR/include/zfs"
37 cp --recursive module
"$KERNEL_DIR/fs/zfs"
38 cp zfs_config.h
"$KERNEL_DIR/include/zfs/"
40 for MODULE
in "${MODULES[@]}"
42 sed -i.bak
'/obj =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
43 sed -i.bak
'/src =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
46 cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
48 tristate "ZFS filesystem support"
49 depends on EFI_PARTITION
53 This is the ZFS filesystem from the ZFS On Linux project.
55 See http://zfsonlinux.org/
57 To compile this file system support as a module, choose M here.
64 ZFS_MODULE_CFLAGS = -I$(srctree)/include/zfs
65 ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/spl
66 ZFS_MODULE_CFLAGS += -include $(srctree)/include/zfs/zfs_config.h
67 ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
68 ZFS_MODULE_CPPFLAGS = -D_KERNEL
69 ZFS_MODULE_CPPFLAGS += -UDEBUG -DNDEBUG
70 export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS
75 for MODULE in "${MODULES[@]}"
77 echo 'obj-$(CONFIG_ZFS) += ' "$MODULE/"
79 } > "$KERNEL_DIR/fs/zfs/Kbuild"
88 while IFS='' read -r LINE
92 if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
96 if IFS='' read -r LINE
98 [ "$LINE" != "$NEW" ] && echo "$LINE"
101 done < "$FILE" > "$FILE.new"
103 mv "$FILE.new" "$FILE"
106 add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
107 add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
110 echo " $0: done." >&2
111 echo " $0: now you can build the kernel with ZFS support." >&2
112 echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2