]>
git.proxmox.com Git - mirror_zfs.git/blob - copy-builtin
7 echo "usage: $0 <kernel source tree>" >&2
11 [ "$#" -eq 1 ] || usage
12 KERNEL_DIR
="$(readlink --canonicalize-existing "$1")"
16 # When integrated in to a monolithic kernel the spl module must appear
17 # first. This ensures its module initialization function is run before
18 # any of the other module initialization functions which depend on it.
21 for MODULE_DIR
in module
/* module
/os
/linux
/*
23 [ -d "$MODULE_DIR" ] ||
continue
24 [ "spl" = "${MODULE_DIR##*/}" ] && continue
25 [ "os" = "${MODULE_DIR#*/}" ] && continue
26 MODULES
+=("${MODULE_DIR#*/}")
29 if ! [ -e 'zfs_config.h' ]
32 echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
33 echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
39 scripts
/make_gitrev.sh || true
41 rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
42 cp --recursive include
"$KERNEL_DIR/include/zfs"
43 cp --recursive module
"$KERNEL_DIR/fs/zfs"
44 cp zfs_config.h
"$KERNEL_DIR/include/zfs/"
46 for MODULE
in "${MODULES[@]}"
48 sed -i.bak
'/obj =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
49 sed -i.bak
'/src =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
52 cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
54 tristate "ZFS filesystem support"
55 depends on EFI_PARTITION
59 This is the ZFS filesystem from the ZFS On Linux project.
61 See https://zfsonlinux.org/
63 To compile this file system support as a module, choose M here.
70 ZFS_MODULE_CFLAGS = -I$(srctree)/include/zfs
71 ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/spl
72 ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/zfs
73 ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/kernel
74 ZFS_MODULE_CFLAGS += -include $(srctree)/include/zfs/zfs_config.h
75 ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
76 ZFS_MODULE_CPPFLAGS = -D_KERNEL
77 ZFS_MODULE_CPPFLAGS += -UDEBUG -DNDEBUG
78 export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS
83 for MODULE in "${MODULES[@]}"
85 echo 'obj-$(CONFIG_ZFS) += ' "$MODULE/"
87 } > "$KERNEL_DIR/fs/zfs/Kbuild"
96 while IFS='' read -r LINE
100 if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
104 if IFS='' read -r LINE
106 [ "$LINE" != "$NEW" ] && echo "$LINE"
109 done < "$FILE" > "$FILE.new"
111 mv "$FILE.new" "$FILE"
114 add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
115 add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
118 echo " $0: done." >&2
119 echo " $0: now you can build the kernel with ZFS support." >&2
120 echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2