转自http://forum.xda-developers.com/showthread.php?t=1552090
Building CM9 From Source On The Epic 4G
I just recently built CM9 for the Epic 4G since Contacts.apk and the Honeycomb Ripple Lockscreen Mod need to be built from source to work properly on our phones. If you follow my instructions exactly, you should have a working CM9 build for the Epic 4G. You can then modify whatever you need to customize your apks, jar files, etc.
Now lets get started. You will need to install Ubuntu 11.10 64-Bit on your computer. It can be a virtual machine, an install using Wubi, or an actual partition for Ubuntu. You will need at least 30gb available for Ubuntu since the repository and the build take up a lot of space.
(Note: It Must Be Ubuntu 11.10 64-Bit And Have A Working Internet Connection!)
Install Java JDK
Once Ubuntu is installed the first thing you will need to do is install Java JDK. Open up a terminal or press Ctrl+Alt+T on the keyboard and copy the following commands:
sudo add-apt-repository ppa:ferramroberto/java sudo apt-get update sudo apt-get install sun-java6-jdk sun-java6-plugin
Install Android SDK For Linux
Next, you will need to install android sdk. Google search android sdk and it should be the first link that pops up. Click on it and download android-sdk_r18-linux.tgz for Linux. Now go back to your terminal and enter the following commands:
cd Downloads tar -xvzf android-sdk_r18-linux.tgz rm *.tgz mv android-sdk-linux/ .. cd ../android-sdk-linux/
Now we need to open the Android SDK Manager and download the necessary packages. In the terminal, copy:
tools/android
cd
The Rest Of The Guide Will Need To Be Done In The Root Terminal!
In the terminal type:
sudo -i
Install Packages
Now we need to install all the necessary packages to make the CM9 build. In the terminal, copy:
apt-get install python git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential pngcrush schedtool gcc-multilib
Configuring USB
Time to set up all devices to work with USB.
gksudo gedit /etc/udev/rules.d/51-android.rules
#Acer SUBSYSTEM==usb, SYSFS{idVendor}==0502, MODE=0666 #ASUS SUBSYSTEM==usb, SYSFS{idVendor}==0b05, MODE=0666 #Dell SUBSYSTEM==usb, SYSFS{idVendor}==413c, MODE=0666 #Foxconn SUBSYSTEM==usb, SYSFS{idVendor}==0489, MODE=0666 #Garmin-Asus SUBSYSTEM==usb, SYSFS{idVendor}==091E, MODE=0666 #Google SUBSYSTEM==usb, SYSFS{idVendor}==18d1, MODE=0666 #HTC SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE=0666 #Huawei SUBSYSTEM==usb, SYSFS{idVendor}==12d1, MODE=0666 #K-Touch SUBSYSTEM==usb, SYSFS{idVendor}==24e3, MODE=0666 #KT Tech SUBSYSTEM==usb, SYSFS{idVendor}==2116, MODE=0666 #Kyocera SUBSYSTEM==usb, SYSFS{idVendor}==0482, MODE=0666 #Lenevo SUBSYSTEM==usb, SYSFS{idVendor}==17EF, MODE=0666 #LG SUBSYSTEM==usb, SYSFS{idVendor}==1004, MODE=0666 #Motorola SUBSYSTEM==usb, SYSFS{idVendor}==22b8, MODE=0666 #NEC SUBSYSTEM==usb, SYSFS{idVendor}==0409, MODE=0666 #Nook SUBSYSTEM==usb, SYSFS{idVendor}==2080, MODE=0666 #Nvidia SUBSYSTEM==usb, SYSFS{idVendor}==0955, MODE=0666 #OTGV SUBSYSTEM==usb, SYSFS{idVendor}==2257, MODE=0666 #Pantech SUBSYSTEM==usb, SYSFS{idVendor}==10A9, MODE=0666 #Philips SUBSYSTEM==usb, SYSFS{idVendor}==0471, MODE=0666 #PMC-Sierra SUBSYSTEM==usb, SYSFS{idVendor}==04da, MODE=0666 #Qualcomm SUBSYSTEM==usb, SYSFS{idVendor}==05c6, MODE=0666 #SK Telesys SUBSYSTEM==usb, SYSFS{idVendor}==1f53, MODE=0666 #Samsung SUBSYSTEM==usb, SYSFS{idVendor}==04e8, MODE=0666 #Sharp SUBSYSTEM==usb, SYSFS{idVendor}==04dd, MODE=0666 #Sony Ericsson SUBSYSTEM==usb, SYSFS{idVendor}==0fce, MODE=0666 #Toshiba SUBSYSTEM==usb, SYSFS{idVendor}==0930, MODE=0666 #ZTE SUBSYSTEM==usb, SYSFS{idVendor}==19D2, MODE=0666
chmod a+r /etc/udev/rules.d/51-android.rules
Next, we need to install the CM9 repository.
mkdir ~/bin gedit /etc/environment
Copy and paste this into the end of the file:
:/home/gooch/android-sdk-linux/tools:/home/gooch/android-sdk-linux/platform-tools:/root/bin
Now Logout and Log back in! This will update your Environment Variables.
Once you're logged back in, open up the terminal and log back in as root:
sudo -i
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo chmod a+x ~/bin/repo mkdir CM9 cd CM9 repo init -u git://github.com/CyanogenMod/android.git -b ics repo sync
(Note: If your download freezes or hangs, close the terminal and open up a new one. Log back into root and repeat these steps)
cd CM9 repo sync
nautilus
brunch epicmtd
This should gather the epicmtd folder for you. If it starts to build, exit the terminal Immediately!
Open another terminal, log into root, and open up the root file explorer again:
nautilus
Copy Proprietary Files
Next you need to download the proprietary files from your phone. You must have a working CM9 ROM currently on your phone. Make sure USB Debugging is on and plug your phone into your computer. (You can find this under Settings-Developer Options-USB Debugging)
In the terminal, navigate the the "CM9" folder if you're not already there:
cd CM9
cd device/samsung/epicmtd ./extract-files.sh
cd cd CM9
vendor/cm/get-prebuilts
Build Source
Finally, We can build the CM9 Source Code.
In the terminal, copy the commands:
. build/envsetup.sh brunch epicmtd
Copy that to your phone's SD Card and reboot into recovery mode. Wipe user data, cache, and dalvik cache, and flash. If it installs and your phone boots up with CM9, You just made a successful build!
You can delete the "epicmtd" folder created in the CM9/out/target/product directory by running in CM9 directory:
make clobber
. build/envsetup.sh brunch epicmtd