xmurp-ua/compile.md

95 lines
3.8 KiB
Markdown
Raw Normal View History

2019-10-18 21:22:41 +08:00
以下,我假定你至少稍有一点命令行基础,搞不清当前目录或者 `cp`、`rm` 都不会用的话,自己找资料。
#### 一般的编译方法
对于 18.06 以上的 SDK照这个方法就行了。
* 在电脑上安装一个 64 位的 Linux 系统。安装成虚拟机或双系统都可以。嫌麻烦的话,推荐使用 Win10 的 Ubuntu 子系统WSL。如果想要顺便体验实体机强烈推荐 deepin。我使用的是 kubuntu 19.10。
* 安装编译依赖项。
```bash
sudo apt-get update && sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk subversion mercurial ccache tar ssh
```
记得开代理,或者换源。
* 准备 SDK。
必须使用与镜像完全对应的 SDK而不能只是架构相同或者内核版本前三位相同。
官方 OpenWrt 的 SDK 和固件放在同一个目录下。比如WNDR4300 的固件下载地址为:
```
http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/nand/openwrt-18.06.1-ar71xx-nand-wndr4300-ubi-factory.img
```
打开网站:
```
http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/nand/
```
就可以找到对应 SDK 的下载地址。
下载好 SDK 后,放到用户目录下,解压 SDK 并进入。
```bash
cd ~ && tar xvf openwrt-sdk*.tar.xz && cd openwrt-sdk*
```
2019-10-18 21:38:51 +08:00
(如果使用 WSL可以将 SDK 放到 C 盘根目录,然后使用命令 `cd ~ && cp /mnt/c/*.tar.xz .` 将它复制到 WSL 中。)
2019-10-18 21:22:41 +08:00
* 下载 `xmurp-ua` 的源代码,并编译。
```bash
git clone https://github.com/CHN-beta/xmurp-ua.git package/xmurp-ua
make defconfig
make package/xmurp-ua/compile V=sc
```
编译好的包在 `bin` 中。
#### 增加编译参数
对于 18.06 以前的 SDK编译的时候需要手动指定一些参数。参考[这篇文章](https://blog.csdn.net/wr132/article/details/78946200)。按照我的经验,一般来说,指定 `ARCH``CROSS-COMPILE` 就足够了。例如:
```bash
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```
#### 使用旧版 Makefile
对于 Openwrt 15.05Chaos CalmerMakefile 的格式与最新版本不同。使用 `Makefile.cc` 代替 `Makefile` 再编译。
```bash
cp package/xmurp-ua/Makefile.cc package/xmurp-ua/Makefile
```
#### 失效的 host 命令
我还遇到过这样的情况:
```
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
MODPOST 0 modules
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.sed.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
Aborted (core dumped)
```
解决办法就是,用自己电脑上的来替换 SDK 里给的那些命令,然后重新编译。
```bash
rm -r staging_dir/host/bin
ln -s /usr/bin staging_dir/host/
rm -r build_dir/target-mips_24kc_musl-1.1.16/linux-ar71xx_generic/xmurp-ua
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dirtoolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```