add DM1 build:

From: Anthony Chang <anthony_chang@openmoko.com>

modify Makefile
	replace: gta02-dm1/rootfs/rootfs.tar.gz
		 gta02-dm1/GTA02-P-version.tar.gz
---

 Makefile                         |  122 ++++++++++++++++++++++++++------------
 gta02-dm1/GTA02-P-version.tar.gz |  Bin
 gta02-dm1/rootfs/rootfs.tar.gz   |  Bin
 3 files changed, 82 insertions(+), 40 deletions(-)

diff --git a/Makefile b/Makefile
index 3f8d8b0..4d758ff 100644
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,15 @@ GTA02_DM_RELEASE_VERSION = ""
 
 BASE_DIR = ${PWD}
 GTA02_DM1_DIR = ${BASE_DIR}/gta02-dm1
-GTA02_DM1_TARGET = GTA02-P${GTA02_DM_RELEASE_VERSION}.tar.gz
+GTA02_DM1_TARGET = GTA02-DM1-${GTA02_DM_RELEASE_VERSION}.tar.gz
 GTA02_DM2_DIR = ${BASE_DIR}/gta02-dm2
 GTA02_DM2_TARGET = dm2.bin
 GTA02_RELEASE_DIR = ${BASE_DIR}/release_data
 GTA02_VERSION_FILE = ${BASE_DIR}/setting_dm_version
 
 BI_KERNEL_VER = 2.6.22.5
-DL_KERNEL_SRC = http://www.kernel.org/pub/linux/kernel/v2.6/linux-${BI_KERNEL_VER}.tar.bz2 
+BI_KERNEL_SITE = http://www.kernel.org
+DL_KERNEL_SRC = ${BI_KERNEL_SITE}/pub/linux/kernel/v2.6/linux-${BI_KERNEL_VER}.tar.bz2 
 
 export GTA02_VERSION_FILE ;
 
@@ -47,18 +48,24 @@ dump_setting:
 	@echo ""
 
 # all ##########
-.PHONY: gta02-dm1-build-kernel-include-rootfs
-gta02-dm1-build-kernel-include-rootfs:
-	if [ ! -d ${GTA02_DM1_DIR}/tmp ]; then \
+.PHONY: gta02-dm1-mkdir-tmp
+gta02-dm1-mkdir-tmp:
+	@if [ ! -d ${GTA02_DM1_DIR}/tmp ]; then \
 		mkdir ${GTA02_DM1_DIR}/tmp; \
-	fi && \
+	fi
+
+.PHONY: gta02-dm1-build-kernel-include-rootfs
+gta02-dm1-build-kernel-include-rootfs: gta02-dm1-mkdir-tmp
 	if [ ! -e ${GTA02_DM1_DIR}/tmp/rootfs/bin/busybox ]; then \
-		tar -xzf ${GTA02_DM1_DIR}/rootfs/rootfs.tar.gz \
-			-C ${GTA02_DM1_DIR}/tmp; \
+		echo "##### maybe you need input password for sudo #####" && \
+		sudo tar -xzf ${GTA02_DM1_DIR}/rootfs/rootfs.tar.gz \
+			-C ${GTA02_DM1_DIR}/tmp && \
+		sudo chown -R root:root ${GTA02_DM1_DIR}/tmp/rootfs/*; \
 	fi && \
 	cd ${GTA02_DM1_DIR}/user_space && make && \
-	cp main libgsmd-tool gsmd \
-		${GTA02_DM1_DIR}/tmp/rootfs/bin && \
+	echo "##### maybe you need input password for sudo #####" && \
+	sudo cp main \
+		${GTA02_DM1_DIR}/tmp/rootfs/sbin && \
 	cd ${GTA02_DM1_DIR}/tmp && \
 	if [ ! -e ./linux-2.6.22.5.tar.bz2 ]; then \
 		wget ${DL_KERNEL_SRC}; \
@@ -67,7 +74,7 @@ gta02-dm1-build-kernel-include-rootfs:
 		svn co http://svn.openmoko.org/trunk/src/target/kernel && \
 		mv -f kernel svn_kernel; \
 	fi
-	cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
+	@cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
 	if [ ! -e ./scripts/build.modify_for_dm1 ]; then \
 		cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
 		sed  's/# KERNEL=${BI_KERNEL_VER}/KERNEL=${BI_KERNEL_VER}/g' \
@@ -83,12 +90,12 @@ gta02-dm1-build-kernel-include-rootfs:
 			./scripts/build.modify_for_dm1 && \
 		chmod 755 ./scripts/build.modify_for_dm1; \
 	fi
-	cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
+	@cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
 	if [ ! -e ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER}/first-patch-done ]; then \
 		./scripts/build.modify_for_dm1 && \
 		echo "done" > ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER}/first-patch-done; \
 	fi
-	cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
+	@cd ${GTA02_DM1_DIR}/tmp/svn_kernel && \
 	if [ ! -d linux-${BI_KERNEL_VER} ]; then \
 		tar -xjf ${GTA02_DM1_DIR}/tmp/linux-${BI_KERNEL_VER}.tar.bz2; \
 	fi && \
@@ -98,22 +105,28 @@ gta02-dm1-build-kernel-include-rootfs:
 		cd ${GTA02_DM1_DIR}/kernel_module && \
 		./setup-kernel.sh ../tmp/svn_kernel/linux-${BI_KERNEL_VER} && \
 		cd ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER} && \
-		echo "${GTA02_DM1_DIR}/tmp/rootfs" > pwd.txt &&  sed 's/\//\\\//g' pwd.txt > pwd.txt.done && \
+		echo "${GTA02_DM1_DIR}/tmp/rootfs" > pwd.txt && \
+			sed 's/\//\\\//g' pwd.txt > pwd.txt.done && \
 		sed "s/\/gta02\/pbe\/rootfs/`cat pwd.txt.done`/g" .config \
 		> config.modifyed && mv config.modifyed .config && \
 		rm pwd.txt pwd.txt.done && \
 		echo "done" > ./.dm1_patched_done; \
 	fi
-	cd ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER} && \
+	@cd ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER} && \
 	export PATH=${PATH}:${GTA02_DM1_DIR}/tmp/u-boot/tools && \
 	if [ ! -e .load_oldconfig_done ]; then \
-		make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- oldconfig && \
+		make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} oldconfig && \
 		touch .load_oldconfig_done; \
 	fi && \
-	make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage -j 2 && \
-	if [ ! -e arch/arm/boot/uImage ]; then \
+	make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} uImage -j 2 && \
+	${GTA02_CROSS}objcopy -O binary -R .note -R .comment \
+		-S arch/arm/boot/compressed/vmlinux linux.bin && \
+	mkimage -A arm -O linux -T kernel -C none -a 30008000 \
+		-e 30008000 -n "Openmoko Kernel Image Neo1973(GTA02)" \
+		-d linux.bin uImage.bin && \
+	if [ ! -e uImage.bin ]; then \
 		echo "" && \
-		echo "##### ${PWD}/arch/arm/boot/uImage is not Built Done #####" && \
+		echo "##### ${PWD}/uImage.bin is not Built Done #####" && \
 		echo "" && \
 		false; \
 	fi
@@ -121,12 +134,9 @@ gta02-dm1-build-kernel-include-rootfs:
 	@echo " ##### kernel and include rootfs is Ready!! #####" 
 	@echo ""
 
-.PHONY: gta02-dm1-build-nor-uboot
-gta02-dm1-build-nor-uboot:
-	@if [ ! -d ${GTA02_DM1_DIR}/tmp ]; then \
-		mkdir ${GTA02_DM1_DIR}/tmp; \
-	fi
-	cd ${GTA02_DM1_DIR}/tmp && \
+.PHONY: gta02-dm1-build-nor-uboot 
+gta02-dm1-build-nor-uboot: gta02-dm1-mkdir-tmp
+	@cd ${GTA02_DM1_DIR}/tmp && \
 	if [ ! -e ./devirginator/.svn/entries ]; then \
 		svn co http://svn.openmoko.org/trunk/src/host/devirginator; \
 	fi && \
@@ -135,15 +145,18 @@ gta02-dm1-build-nor-uboot:
 	fi && \
 	if [ ! -e ./u-boot/.git/HEAD ]; then \
 		git clone git://git.openmoko.org/git/u-boot.git && \
-		cd u-boot && git checkout origin/stable && \
+		cd u-boot && git checkout origin/andy && \
 		cd ${GTA02_DM1_DIR}/tmp; \
 	fi && \
 	if [ ! -e ./devirginator/System_boot.png ]; then \
 		cd ./devirginator && \
 		wget http://wiki.openmoko.org/images/c/c2/System_boot.png; \
+	fi
+	@cd ${GTA02_DM1_DIR}/tmp/u-boot && \
+	if [ ! -e ${GTA02_DM1_DIR}/tmp/u-boot/.config_done ]; then \
+		make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} gta02v5_config && \
+		touch ${GTA02_DM1_DIR}/tmp/u-boot/.config_done; \
 	fi && \
-	cd ${GTA02_DM1_DIR}/tmp/u-boot && \
-	make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} gta02v5_config && \
 	make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} u-boot.udfu -j 2 && \
 	cd ${GTA02_DM1_DIR}/tmp/devirginator && \
 	./mknor -D QUIET -s ./System_boot.png \
@@ -152,8 +165,31 @@ gta02-dm1-build-nor-uboot:
 	@echo " ##### u-boot.udfu.nor for NOR Ready!! #####" 
 	@echo ""
 
+.PHONY: gta02-dm1
+gta02-dm1: gta02-dm1-mkdir-tmp gta02-dm1-build-nor-uboot \
+		gta02-dm1-build-kernel-include-rootfs
+	@echo "##### build ${GTA02_DM1_TARGET} #####"
+	@echo ""
+	@if [ ! -e ${GTA02_VERSION_FILE} ]; then \
+		echo "" && \
+		echo "\tERROR!!! Please Setting GTA02_DM_RELEASE_VERSION in Makefile" && \
+		echo "" && \
+		false; \
+	fi
+	@cd ${GTA02_DM1_DIR}/tmp && \
+	tar -xzf ../GTA02-P-version.tar.gz && \
+	echo ${GTA02_DM_RELEASE_VERSION} > GTA02-DM1/version && \
+	cp ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER}/uImage.bin \
+		GTA02-DM1/tmp/uImage.bin && \
+	cp ${GTA02_DM1_DIR}/tmp/u-boot/u-boot.udfu \
+		./GTA02-DM1/tmp/u-boot.bin && \
+	echo "I am Live" > GTA02-DM1/.make_identify && \
+	tar -czf ${GTA02_DM1_DIR}/${GTA02_DM1_TARGET} \
+		GTA02-DM1 && \
+	cd ${BASE_DIR}
+
 .PHONY: gta02-dm1-dummy
-gta02-dm1-dummy: 
+gta02-dm1-dummy:
 	@echo "##### build ${GTA02_DM1_TARGET} #####"
 	@echo ""
 	@if [ ! -e ${GTA02_VERSION_FILE} ]; then \
@@ -165,10 +201,13 @@ gta02-dm1-dummy:
 	@if [ ! -d ${GTA02_DM1_DIR}/tmp ]; then \
 		mkdir ${GTA02_DM1_DIR}/tmp; \
 	fi
-	@rm -fr ${GTA02_DM1_DIR}/tmp/* && \
+	rm -fr ${GTA02_DM1_DIR}/tmp/GTA02-DM1 && \
 	cd ${GTA02_DM1_DIR}/tmp && \
 	tar -xzf ../GTA02-P-version.tar.gz && \
 	echo ${GTA02_DM_RELEASE_VERSION} > GTA02-DM1/version && \
+	cp GTA02-DM1/tmp/u-boot.bin.Ver_0.0.27 GTA02-DM1/tmp/u-boot.bin && \
+	cp GTA02-DM1/tmp/uImage.bin.Ver_0.0.27 GTA02-DM1/tmp/uImage.bin && \
+	echo "I am Dummy" > GTA02-DM1/.make_identify && \
 	tar -czf ${GTA02_DM1_DIR}/${GTA02_DM1_TARGET} \
 		GTA02-DM1 && \
 	cd ${BASE_DIR}
@@ -195,8 +234,8 @@ mkdir_release_dir:
 		mkdir ${GTA02_RELEASE_DIR}/gta02-dm2; \
 	fi
 
-.PHONY: install-gta02-dm1-dammy
-install-gta02-dm1-dammy: mkdir_release_dir
+.PHONY: install-gta02-dm1
+install-gta02-dm1: mkdir_release_dir
 	@if [ -e ${GTA02_DM1_DIR}/${GTA02_DM1_TARGET} ]; then \
 		mv ${GTA02_DM1_DIR}/${GTA02_DM1_TARGET} \
 			${GTA02_RELEASE_DIR}/${GTA02_DM1_TARGET}; \
@@ -212,17 +251,17 @@ install-gta02-dm2: mkdir_release_dir
 	fi
 
 
-install: mkdir_release_dir install-gta02-dm1-dammy install-gta02-dm2
+install: mkdir_release_dir install-gta02-dm1 install-gta02-dm2
 
 # clean ##########
 .PHONY: gta02-dm1-build-kernel-include-rootfs-clean
 gta02-dm1-build-kernel-include-rootfs-clean:
 	cd ${GTA02_DM1_DIR}/user_space && make clean && \
 	if [ -d ${GTA02_DM1_DIR}/tmp/rootfs ]; then \
-		rm -fr ${GTA02_DM1_DIR}/tmp/rootfs; \
+		sudo rm -fr ${GTA02_DM1_DIR}/tmp/rootfs; \
 	fi
 	cd ${GTA02_DM1_DIR}/tmp/svn_kernel/linux-${BI_KERNEL_VER} && \
-	make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- clean
+	make ARCH=arm CROSS_COMPILE=${GTA02_CROSS} clean
 
 .PHONY: gta02-dm1-build-nor-uboot-clean
 gta02-dm1-build-nor-uboot-clean:
@@ -246,13 +285,16 @@ clean-release-data:
 		rmdir ${GTA02_RELEASE_DIR}; \
 	fi
 
-.PHONY: clean-gta02-dm1-dammy
+.PHONY: clean-gta02-dm1
+clean-gta02-dm1: gta02-dm1-build-kernel-include-rootfs-clean \
+		gta02-dm1-build-nor-uboot-clean clean-gta02-dm1-dummy
+
+.PHONY: clean-gta02-dm1-dummy
 clean-gta02-dm1-dammy:
+	rm ${GTA02_DM1_DIR}/${GTA02_DM1_TARGET} && \
+	rm -fr ${GTA02_DM1_DIR}/tmp/GTA02-DM1 
 	@echo "##### clean dm1 #####"
 	@echo ""
-	#@if [ -d ${GTA02_DM1_DIR}/tmp ]; then \
-		rm -fr ${GTA02_DM1_DIR}/tmp; \
-	fi
 
 .PHONY: clean-gta02-dm2
 clean-gta02-dm2:
@@ -260,7 +302,7 @@ clean-gta02-dm2:
 	@cd ${GTA02_DM2_DIR} && make clean && rm -fr staging \
 		&& cd ${BASE_DIR} 
 
-clean: clean-release-data clean-gta02-dm1-dammy clean-gta02-dm2
+clean: clean-release-data clean-gta02-dm1-dummy clean-gta02-dm2
 	@if [ -e ${GTA02_VERSION_FILE} ]; then \
 		rm ${GTA02_VERSION_FILE}; \
 	fi
diff --git a/gta02-dm1/GTA02-P-version.tar.gz b/gta02-dm1/GTA02-P-version.tar.gz
index 4cc3566..ad68101 100644
Binary files a/gta02-dm1/GTA02-P-version.tar.gz and b/gta02-dm1/GTA02-P-version.tar.gz differ
diff --git a/gta02-dm1/rootfs/rootfs.tar.gz b/gta02-dm1/rootfs/rootfs.tar.gz
index 2dac75c..3a3c972 100644
Binary files a/gta02-dm1/rootfs/rootfs.tar.gz and b/gta02-dm1/rootfs/rootfs.tar.gz differ
