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"
59 sed -i.bak '/obj =/d' "$KERNEL_DIR/spl/$MODULE/Makefile"
60 sed -i.bak '/src =/d' "$KERNEL_DIR/spl/$MODULE/Makefile"
63 cat > "$KERNEL_DIR/spl/Kconfig" <<"EOF"
65 tristate "Solaris Porting Layer (SPL)"
67 This is the SPL library from the ZFS On Linux project.
69 See http://zfsonlinux.org/
71 To compile this library as a module, choose M here.
78 SPL_MODULE_CFLAGS = -I$(srctree)/include/spl
79 SPL_MODULE_CFLAGS += -include $(srctree)/spl_config.h
80 export SPL_MODULE_CFLAGS
85 for MODULE in "${MODULES[@]}"
87 echo 'obj-$(CONFIG_SPL) += ' "$MODULE/"
89 } > "$KERNEL_DIR/spl/Kbuild"
98 while IFS='' read -r LINE
102 if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
106 if IFS='' read -r LINE
108 [ "$LINE" != "$NEW" ] && echo "$LINE"
111 done < "$FILE" > "$FILE.new"
113 mv "$FILE.new" "$FILE"
116 add_after "$KERNEL_DIR/Kconfig" 'source "arch/$SRCARCH/Kconfig"' 'source "spl/Kconfig"'
117 # We must take care to build SPL before ZFS, otherwise the symbols required
118 # to link ZFS will not be available.
119 sed -i 's#+= kernel/#+= kernel/ spl/#' "$KERNEL_DIR/Makefile"
122 echo " $0: done." >&2
123 echo " $0: now you can build the kernel with SPL support." >&2
124 echo " $0: make sure you enable SPL support (CONFIG_SPL) before building." >&2