本文给出了android4.0 x86版源码在Ubuntu下的编译说明,因个人技术能力有限,文中的错误还请多交流指出。在后续文章中将继续对android 4.0 x86内核编译,系统镜像定制裁剪,API裁剪等方面做介绍。
原文链接:http://www.cnblogs.com/sunshinewill/archive/2012/05/26/2519081.html
本文结构:编译环境配置,安装编译依赖,下载源码,编译目标选择,编译及生成文件。
编译环境配置:
系统使用64位Ubuntu 10.04以上,硬盘空闲空间25G以上,本篇使用Ubuntu11.10 64位系统,对Android 4.0系统进行编译
Ubuntu下载,选择Ubuntu11.10 64-bit版本点击下载:
http://www.ubuntu.org.cn/download/ubuntu/download
下载后安装不做介绍。保留硬盘空间25G。推荐CPU使用i5以上,内存4G以上(最低配置2G+2Gswap)。
安装编译依赖:
Python 2.5-2.7
GNU Make 3.81-3.82
JDK 6 对于姜饼或更新版系统,其他版本JDK 5
Git 1.7或更新
更新源:
sudo gedit /etc/apt/sources.list (编辑源列表)
将下列代码粘贴进文件(北理ubuntu源):
deb http://mirror.bjtu.edu.cn/ubuntu/ oneiric main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ oneiric-backports main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ oneiric-proposed main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ oneiric-security main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ oneiric-updates main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ oneiric main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ oneiric-backports main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ oneiric-proposed main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ oneiric-security main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ oneiric-updates main multiverse restricted universe
如下图:
完成保存后:
sudo apt-get update
安装各依赖:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc libx11-dev:i386
安装JDK1.6
$ sudo apt-get install sun-java6-jdk
下载源码:
关于源码分支如下图:
- android-x86-v0.9 (obsolete)
Based on Android 1.5 release (Cupcake). - donut-x86
Based on Android 1.6 release (Donut). - eclair-x86
Based on Android 2.1 release (Eclair). - froyo-x86
Based on Android 2.2 release (Froyo). - gingerbread-x86
Based on Android 2.3 release (Gingerbread). - honeycomb-x86
Based on Android 3.2 release (Honeycomb). - ics-x86
Based on Android 4.0 release (Ice Cream Sandwich).
使用repo下载源码:
1)确定在home目录中拥有bin/目录,并添加到path中:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
2)下载repo:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
3)下载
$ mkdir android-x86
$ cd android-x86
$ repo init -u http://git.android-x86.org/manifest -b $branch
$ repo sync
或使用其他源:
$ repo init -u git://android-x86.git.sf.net/gitroot/android-x86/x86/platform/manifest.git -b $branch
如果在下载过程中停止或同步冲突,使用以下命令使下载继续:
git rebase --skip
下载好的目录树:(源码目录功能介绍将在以后文章中做介绍)
编译目标:
以下列举了可以选择的编译目标文件,即为市面上主流x86平板电脑、上网本型号、处理器型号的选择。
donut-x86:
eeepc: for ASUS EeePC family
q1u: for Samsung Q1U
s5: for Viliv S5
eclair-x86:
generic_x86: for generic x86 PC/notebook
eeepc: for ASUS EeePC family only
q1u: for Samsung Q1U
s5: for Viliv S5
froyo-x86 / gingerbread-x86:
generic_x86: for generic x86 PC/notebook
eeepc: for ASUS EeePC family only
asus_laptop: for some ASUS laptops
tegav2: for Tegatech Tegav2 (may work with other Atom N45x based tablets)
sparta: for Dell Inspiron Mini Duo platform
vm: for virtual machine (virtual box, qemu, vmware)
motion_m1400: for Motion M1400 (Intel Centrino M based with Intel PRO/Wireless)
honeycomb-x86 / ics-x86:
generic_x86: for generic x86 PC/notebook
amd_brazos: for AMD Brazos platform
eeepc: for ASUS EeePC family only
asus_laptop: for some ASUS laptops
tegav2: for Tegatech Tegav2 (may work with other Atom N45x based tablets)
编译及生成文件:
$ make iso_img TARGET_PRODUCT=tegav2
其中TARGET_PRODUCT即为编译目标文件
out/target/product/$TARGET_PRODUCT/$TARGET_PRODUCT.iso测试该镜像文件可以简单的通过虚拟机或是制作U盘镜像:
$ dd if=out/target/product/eeepc/eeepc.iso of=/dev/sdX
可通过fdisk -ls 查看所要烧制的U盘
生成目录结构:
囧事:下载了SDK,再次生成iso过程中,硬盘空间没了,确定有较充足空间,建议不少于25G,该平台是p7350/2G,大量的时间耗费在了换入换出。