Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2116745
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2015-06-25 11:34:21

一.
1. 用git管理代码
1.1 用git管理代码
  1. cong@msi:/work/busybox$ git init
  2. Initialized empty Git repository in /work/busybox/.git/
  3. cong@msi:/work/busybox$ git add ./
  4. cong@msi:/work/busybox$ git commit -m 'busybox project init'
  5. [master (root-commit) f641676] busybox project init
1.2 将临时文件重定向到_install目录
中间编译的.o文件及编译配置文件(.config.in)会频繁改动,为了避免这些临时文件的干扰,
需要将所有的临时文件定向到_install目录中, 加上O=./_install选项就可以了。
  1. cong@msi:/work/busybox$ mkdir _install
  2. cong@msi:/work/busybox$ make O=./_install/ menuconfig

  3. cong@msi:/work/busybox$ make O=./_install/ -j16
1.3 过滤
生一利必有一弊,这儿需要将新建的_install目录过滤掉,同时将.gitignore添加到工程
  1. cong@msi:/work/busybox$ git status
  2. On branch master
  3. Untracked files:
  4.   (use "git add ..." to include in what will be committed)

  5.     _install/


  6. cong@msi:/work/busybox$ vi .gitignore     //新建一个.gitignore文件
  7. cong@msi:/work/busybox$ cat .gitignore    //这个.gitignore文件的内容就是要过滤的文件或目录
  8. readme
  9. _install/
  10. docs/

  11. cong@msi:/work/busybox$ git status       //再将.gitignore添加到工程就可以了
  12. On branch master
  13. Untracked files:
  14.   (use "git add ..." to include in what will be committed)

  15.     .gitignore  

2.编译
2.1 参写INSTALL
  1. The BusyBox build process is similar to the Linux kernel build:

  2.   make menuconfig       # This creates a file called ".config"
  3.   make                  # This creates the "busybox" executable
  4.   make install          # or make CONFIG_PREFIX=/path/from/root install
2.2 编译脚本
  1. cong@msi:/work/busybox$ cat readme
  2. #!/bin/sh
  3. my_build()
  4. {
  5.     if [ ! -d ./_install ]; then
  6.         mkdir ./_install
  7.         make O=./_install/ menuconfig
  8.     fi
  9.     make O=./_install/ -j16
  10. }

  11. case "$1" in
  12.     build)
  13.         my_build
  14.         ;;
  15.     *)
  16.         my_build
  17.         ;;
  18. esac
这样编译时直接运行 . readme就可以了,多快好省
3. 添加打印
  1. 在include/libbb.h的最后L2085
  2. #define dbmsg(fmt, args ...) printf("%s:%s[%d]: "fmt"\n", __FILE__,__FUNCTION__, __LINE__,##args)
注:如果make menuconfig通不过,需要库
  1. cong@msi:/work/busybox$ sudo apt-get install libncurses5-dev


三. ndk编译buysbox
1. 下载busybox-1.20.2在源码的configs目录下有android_ndk_defconfig
  1. cong@msi:/work/busybox-1.20.2$ ls configs/
  2. android2_defconfig android_defconfig android_ndk_defconfig 
  3. cygwin_defconfig freebsd_defconfig TEST_nommu_defconfig TEST_noprintf_defconfig TEST_rh9_defconfig
2. 编译过程
  1. a. 修改Makefile指定ARCH与CROSS_COMPILE
  2.  vi Makefile
  3.  164 CROSS_COMPILE ?=/work/bak/android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-

  4.  190 #ARCH ?= $(SUBARCH)
  5.  191 ARCH ?=arm

  6. b.修改config文件指定sys_root
  7.  vi ./configs/android_ndk_defconfig
  8.    68 CONFIG_SYSROOT="/work/bak/android/android-ndk-r10e/platforms/android-9/arch-arm"

  9. cong@msi:/work/busybox-1.20.2$ make android_ndk_defconfig
  10. cong@msi:/work/busybox-1.20.2$ make 
3. 最后链接不过的解决方法
  1. Then it dies with "ld: internal error in do_print_to_mapfile, at
  2. /s/ndk-toolchain/src/build/../binutils/binutils-2.25/gold/output.h:395" due to
  3. Google changing it to use gold linker by default.
  4. Fixed by appending -fuse-ld=bfd to CFLAGS

  5. Updated android_ndk_defconfig and patch for udhcpc attached.
vi Makefile 
     319 CFLAGS      := $(CFLAGS) -fuse-ld=bfd
参考文章: 
阅读(1725) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~