| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 |
|
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 |
|
| 26 | |
| 27 | |
| 28 | |
| 29 | is_enabled()
|
| 30 | {
|
| 31 | grep -q "^$1=y$" include/config/auto.conf
|
| 32 | }
|
| 33 |
|
| 34 | |
| 35 | |
| 36 | XZ_VERSION=$($XZ --robot --version) || exit
|
| 37 | XZ_VERSION=$(printf '%s\n' "$XZ_VERSION" | sed -n 's/^XZ_VERSION=//p')
|
| 38 |
|
| 39 | |
| 40 | BCJ=
|
| 41 |
|
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | case $SRCARCH in
|
| 47 | arm)
|
| 48 | if is_enabled CONFIG_THUMB2_KERNEL; then
|
| 49 | ALIGN=2
|
| 50 | BCJ=--armthumb
|
| 51 | else
|
| 52 | ALIGN=4
|
| 53 | BCJ=--arm
|
| 54 | fi
|
| 55 | ;;
|
| 56 |
|
| 57 | arm64)
|
| 58 | ALIGN=4
|
| 59 |
|
| 60 | |
| 61 | if [ "$XZ_VERSION" -ge 50040002 ]; then
|
| 62 | BCJ=--arm64
|
| 63 | else
|
| 64 | echo "$0: Upgrading to xz >= 5.4.0" \
|
| 65 | "would enable the ARM64 filter" \
|
| 66 | "for better compression" >&2
|
| 67 | fi
|
| 68 | ;;
|
| 69 |
|
| 70 | csky)
|
| 71 | ALIGN=2
|
| 72 | ;;
|
| 73 |
|
| 74 | loongarch)
|
| 75 | ALIGN=4
|
| 76 | ;;
|
| 77 |
|
| 78 | mips)
|
| 79 | if is_enabled CONFIG_CPU_MICROMIPS; then
|
| 80 | ALIGN=2
|
| 81 | else
|
| 82 | ALIGN=4
|
| 83 | fi
|
| 84 | ;;
|
| 85 |
|
| 86 | parisc)
|
| 87 | ALIGN=4
|
| 88 | ;;
|
| 89 |
|
| 90 | powerpc)
|
| 91 | ALIGN=4
|
| 92 |
|
| 93 | |
| 94 | if is_enabled CONFIG_CPU_BIG_ENDIAN; then
|
| 95 | BCJ=--powerpc
|
| 96 | fi
|
| 97 | ;;
|
| 98 |
|
| 99 | riscv)
|
| 100 | if is_enabled CONFIG_RISCV_ISA_C; then
|
| 101 | ALIGN=2
|
| 102 | else
|
| 103 | ALIGN=4
|
| 104 | fi
|
| 105 |
|
| 106 | |
| 107 | if [ "$XZ_VERSION" -ge 50060002 ]; then
|
| 108 | BCJ=--riscv
|
| 109 | else
|
| 110 | echo "$0: Upgrading to xz >= 5.6.0" \
|
| 111 | "would enable the RISC-V filter" \
|
| 112 | "for better compression" >&2
|
| 113 | fi
|
| 114 | ;;
|
| 115 |
|
| 116 | s390)
|
| 117 | ALIGN=2
|
| 118 | ;;
|
| 119 |
|
| 120 | sh)
|
| 121 | ALIGN=2
|
| 122 | ;;
|
| 123 |
|
| 124 | sparc)
|
| 125 | ALIGN=4
|
| 126 | BCJ=--sparc
|
| 127 | ;;
|
| 128 |
|
| 129 | x86)
|
| 130 | ALIGN=1
|
| 131 | BCJ=--x86
|
| 132 | ;;
|
| 133 |
|
| 134 | *)
|
| 135 | echo "$0: Arch-specific tuning is missing for '$SRCARCH'" >&2
|
| 136 |
|
| 137 | |
| 138 | |
| 139 | ALIGN=2
|
| 140 | ;;
|
| 141 | esac
|
| 142 |
|
| 143 | |
| 144 | case $ALIGN in
|
| 145 | 1) LZMA2OPTS= ;;
|
| 146 | 2) LZMA2OPTS=lp=1 ;;
|
| 147 | 4) LZMA2OPTS=lp=2,lc=2 ;;
|
| 148 | *) echo "$0: ALIGN wrong or missing" >&2; exit 1 ;;
|
| 149 | esac
|
| 150 |
|
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | exec $XZ --check=crc32 --threads=1 $BCJ --lzma2=$LZMA2OPTS,dict=128MiB
|