http://blog.csdn.net/niepengpeng333/article/details/7046306
- #!/bin/bash
- CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}') #处理起数量
- CLIENT=$(whoami) #当前的用户
- ROOT_DIR=$(pwd) #当前路径
- KERNEL_DIR=./kernel
- #SEC_PRODUCT='generic' #Enable for generic build
- SEC_PRODUCT='smdkv210' #Enable for smdk build
- #Modify the below path suitably as per your requirements
- OUT_DIR="$ROOT_DIR/out/target/product/$SEC_PRODUCT" #输出目录
- OUT_HOSTBIN_DIR="$ROOT_DIR/out/host/linux-x86/bin" #用到的命令目录
- function check_exit()
- {
- if [ $? != 0 ]
- then
- exit $?
- fi
- }
- function build_android()
- {
- echo
- echo '[[[[[[[ Build android platform ]]]]]]]'
- echo
- START_TIME=`date +%s` #获取系统时间
- if [ $SEC_PRODUCT = "generic" ] #判断输出的目录,如果是默认的目录
- then
- echo make -j$CPU_JOB_NUM #输出提示
- echo
- make -j$CPU_JOB_NUM #开始编译
- else
- echo make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-eng #输出提示
- echo
- make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-eng #开始编译
- fi
- check_exit
- END_TIME=`date +%s` #结束时间
- let "ELAPSED_TIME=$END_TIME-$START_TIME" #计算消耗时间
- echo "Total compile time is $ELAPSED_TIME seconds"
- }
- function make_uboot_img() #编译u-boot文件
- {
- cd $OUT_DIR #进入输出的文件目录
- echo
- echo '[[[[[[[ Make ramdisk image for u-boot ]]]]]]]'
- echo
- $OUT_HOSTBIN_DIR/mkyaffs2image root ramdisk-yaffs.img
- check_exit
- echo
- cd ../../../..
- }
- function make_fastboot_img()
- {
- echo
- echo '[[[[[[[ Make additional images for fastboot ]]]]]]]'
- echo
- if [ ! -f $KERNEL_DIR/arch/arm/boot/zImage ]
- then
- echo "No zImage is found at $KERNEL_DIR/arch/arm/boot"
- echo ' Please set KERNEL_DIR if you want to make additional images'
- echo " Ex.) export KERNEL_DIR=~ID/android_kernel_$SEC_PRODUCT"
- echo
- return
- fi
- echo 'boot.img ->' $OUT_DIR
- cp $KERNEL_DIR/arch/arm/boot/zImage $OUT_DIR/zImage
- $OUT_HOSTBIN_DIR/mkbootimg --kernel $OUT_DIR/zImage --ramdisk $OUT_DIR/ramdisk-uboot.img -o $OUT_DIR/boot.img
- check_exit
- echo 'update.zip ->' $OUT_DIR
- zip -j $OUT_DIR/update.zip $OUT_DIR/android-info.txt $OUT_DIR/boot.img $OUT_DIR/system.img
- check_exit
- echo
- }
- echo
- echo ' Build android for '$SEC_PRODUCT''
- echo
- case "$SEC_PRODUCT" in #根据目录的不同,选择不同的编译过程
- smdkc110)
- build_android
- make_uboot_img
- make_fastboot_img
- ;;
- smdkv210)
- build_android
- make_uboot_img
- #make_fastboot_img
- ;;
- generic)
- build_android
- make_uboot_img
- ;;
- *)
- echo "Please, set SEC_PRODUCT"
- echo " export SEC_PRODUCT=smdkc100 or SEC_PRODUCT=smdkc110 or SEC_PRODUCT=smdkv210 or SEC_PRODUCT=smdk6440"
- echo " or "
- echo " export SEC_PRODUCT=generic"
- exit 1
- ;;
- esac
- echo ok success !!!
- exit 0