在 x86 平台编译可直接参考官方文档,在 arm 平台编译需要略作修改

X86 平台

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apt update -y
apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache clang cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext gcc-multilib \
g++-multilib git gnutls-dev gperf haveged help2man intltool lib32gcc-s1 libc6-dev-i386 libelf-dev \
libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses-dev libpython3-dev \
libreadline-dev libssl-dev libtool libyaml-dev libz-dev lld llvm lrzsz mkisofs msmtp nano \
ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip python3-ply python3-docutils \
python3-pyelftools qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs \
upx-ucl unzip vim wget xmlto xxd zlib1g-dev zstd

git clone https://github.com/immortalwrt/immortalwrt --depth=1
cd immortalwrt
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig # 非首次编译 make defconfig
make V=s -j$(nproc)

编译后固件位于./bin/targets

ARM 平台

总体上与 X86 一样,安装依赖:

1
2
3
4
5
6
7
8
apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache clang cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf git gnutls-dev gperf haveged help2man intltool lib32gcc-s1-amd64-cross libc6-dev-i386-amd64-cross \
libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses-dev libpython3-dev \
libreadline-dev libssl-dev libtool libyaml-dev libz-dev lld llvm lrzsz mkisofs msmtp nano \
ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip python3-ply python3-docutils \
python3-pyelftools qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs \
upx-ucl unzip vim wget xmlto xxd zlib1g-dev zstd

修改配置Languages > Go > Configuration > External bootstrap Go root directory,填/usr/lib/go

1
(/usr/lib/go) External bootstrap Go root directory

否则编译会报错

参考

https://winger.alundra.uk/index.php/archives/8/

https://github.com/immortalwrt/immortalwrt