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 'spl_config.h' ]
24 echo " $0: you did not run configure, or you're not in the SPL source directory." >&2
25 echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
32 rm -rf "$KERNEL_DIR/include/spl" "$KERNEL_DIR/spl"
33 cp --recursive include "$KERNEL_DIR/include/spl"
34 cp --recursive module "$KERNEL_DIR/spl"
35 cp spl_config.h "$KERNEL_DIR/"
36 cp spl.release.in "$KERNEL_DIR/"
43 while IFS='' read -r LINE
45 OBJPATH="${LINE#\$(MODULE)-objs += }"
46 if [ "$OBJPATH" = "$LINE" ]
50 echo "\$(MODULE)-objs += ${OBJPATH##*/}"
52 done < "$FILE" > "$FILE.new"
53 mv "$FILE.new" "$FILE"
56 for MODULE in "${MODULES[@]}"
58 adjust_obj_paths "$KERNEL_DIR/spl/$MODULE/Makefile"
61 cat > "$KERNEL_DIR/spl/Kconfig" <<"EOF"
63 tristate "Solaris Porting Layer (SPL)"
65 This is the SPL library from the ZFS On Linux project.
67 See http://zfsonlinux.org/
69 To compile this library as a module, choose M here.
76 SPL_MODULE_CFLAGS = -I$(srctree)/include/spl
77 SPL_MODULE_CFLAGS += -include $(srctree)/spl_config.h
78 export SPL_MODULE_CFLAGS
83 for MODULE in "${MODULES[@]}"
85 echo 'obj-$(CONFIG_SPL) += ' "$MODULE/"
87 } > "$KERNEL_DIR/spl/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/Kconfig" 'source "arch/$SRCARCH/Kconfig"' 'source "spl/Kconfig"'
115 # We must take care to build SPL before ZFS, else module initialization order will be wrong
116 sed -i 's#kernel/ mm/ fs/#kernel/ mm/ spl/ fs/#' "$KERNEL_DIR/Makefile"
119 echo " $0: done." >&2
120 echo " $0: now you can build the kernel with SPL support." >&2
121 echo " $0: make sure you enable SPL support (CONFIG_SPL) before building." >&2