1#!/bin/sh 2 3set -ef 4 5usage() 6{ 7 echo "usage: $0 <kernel source tree>" >&2 8 exit 1 9} 10 11if ! [ -d "$1" ] ; then 12 usage 13fi 14KERNEL_DIR="$1" 15 16if ! [ -e 'zfs_config.h' ] 17then 18 echo "$0: you did not run configure, or you're not in the ZFS source directory." 19 echo "$0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." 20 21 exit 1 22fi >&2 23 24make clean ||: 25make gitrev 26 27rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs" 28cp -R include "$KERNEL_DIR/include/zfs" 29cp -R module "$KERNEL_DIR/fs/zfs" 30cp zfs_config.h "$KERNEL_DIR/include/zfs/" 31 32cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<EOF 33config ZFS 34 tristate "ZFS filesystem support" 35 depends on EFI_PARTITION 36 depends on BLOCK 37 select ZLIB_INFLATE 38 select ZLIB_DEFLATE 39 help 40 This is the ZFS filesystem from the OpenZFS project. 41 42 See https://github.com/openzfs/zfs 43 44 To compile this file system support as a module, choose M here. 45 46 If unsure, say N. 47EOF 48 49sed -i '/source "fs\/ext2\/Kconfig\"/i\source "fs/zfs/Kconfig"' "$KERNEL_DIR/fs/Kconfig" 50echo 'obj-$(CONFIG_ZFS) += zfs/' >> "$KERNEL_DIR/fs/Makefile" 51 52echo "$0: done. now you can build the kernel with ZFS support." >&2 53echo "$0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2 54