一.
1. 用git管理代码
1.1 用git管理代码
-
cong@msi:/work/busybox$ git init
-
Initialized empty Git repository in /work/busybox/.git/
-
cong@msi:/work/busybox$ git add ./
-
cong@msi:/work/busybox$ git commit -m 'busybox project init'
-
[master (root-commit) f641676] busybox project init
1.2 将临时文件重定向到_install目录
中间编译的.o文件及编译配置文件(.config.in)会频繁改动,为了避免这些临时文件的干扰,
需要将所有的临时文件定向到_install目录中, 加上O=./_install选项就可以了。
-
cong@msi:/work/busybox$ mkdir _install
-
cong@msi:/work/busybox$ make O=./_install/ menuconfig
-
-
cong@msi:/work/busybox$ make O=./_install/ -j16
1.3 过滤
生一利必有一弊,这儿需要将新建的_install目录过滤掉,同时将.gitignore添加到工程
-
cong@msi:/work/busybox$ git status
-
On branch master
-
Untracked files:
-
(use "git add ..." to include in what will be committed)
-
-
_install/
-
-
-
cong@msi:/work/busybox$ vi .gitignore //新建一个.gitignore文件
-
cong@msi:/work/busybox$ cat .gitignore //这个.gitignore文件的内容就是要过滤的文件或目录
-
readme
-
_install/
-
docs/
-
-
cong@msi:/work/busybox$ git status //再将.gitignore添加到工程就可以了
-
On branch master
-
Untracked files:
-
(use "git add ..." to include in what will be committed)
-
-
.gitignore
2.编译
2.1 参写INSTALL
-
The BusyBox build process is similar to the Linux kernel build:
-
-
make menuconfig # This creates a file called ".config"
-
make # This creates the "busybox" executable
-
make install # or make CONFIG_PREFIX=/path/from/root install
2.2 编译脚本
-
cong@msi:/work/busybox$ cat readme
-
#!/bin/sh
-
my_build()
-
{
-
if [ ! -d ./_install ]; then
-
mkdir ./_install
-
make O=./_install/ menuconfig
-
fi
-
make O=./_install/ -j16
-
}
-
-
case "$1" in
-
build)
-
my_build
-
;;
-
*)
-
my_build
-
;;
-
esac
这样编译时直接运行 . readme就可以了,多快好省
3. 添加打印
-
在include/libbb.h的最后L2085
-
#define dbmsg(fmt, args ...) printf("%s:%s[%d]: "fmt"\n", __FILE__,__FUNCTION__, __LINE__,##args)
注:如果make menuconfig通不过,需要库
-
cong@msi:/work/busybox$ sudo apt-get install libncurses5-dev
三. ndk编译buysbox
1. 下载busybox-1.20.2在源码的configs目录下有android_ndk_defconfig
-
cong@msi:/work/busybox-1.20.2$ ls configs/
-
android2_defconfig android_defconfig android_ndk_defconfig
-
cygwin_defconfig freebsd_defconfig TEST_nommu_defconfig TEST_noprintf_defconfig TEST_rh9_defconfig
2. 编译过程
-
a. 修改Makefile指定ARCH与CROSS_COMPILE
-
vi Makefile
-
164 CROSS_COMPILE ?=/work/bak/android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
-
-
190 #ARCH ?= $(SUBARCH)
-
191 ARCH ?=arm
-
-
b.修改config文件指定sys_root
-
vi ./configs/android_ndk_defconfig
-
68 CONFIG_SYSROOT="/work/bak/android/android-ndk-r10e/platforms/android-9/arch-arm"
-
-
cong@msi:/work/busybox-1.20.2$ make android_ndk_defconfig
-
cong@msi:/work/busybox-1.20.2$ make
3. 最后链接不过的解决方法
-
Then it dies with "ld: internal error in do_print_to_mapfile, at
-
/s/ndk-toolchain/src/build/../binutils/binutils-2.25/gold/output.h:395" due to
-
Google changing it to use gold linker by default.
-
Fixed by appending -fuse-ld=bfd to CFLAGS
-
-
Updated android_ndk_defconfig and patch for udhcpc attached.
vi Makefile
319 CFLAGS := $(CFLAGS)
-fuse-ld=bfd
参考文章:
阅读(1777) | 评论(0) | 转发(0) |