Fix build script

Change-Id: I4fb9ca9594bc9622aba2f92343bb17a5fc50cb84
diff --git a/.gitignore b/.gitignore
index 466e248..dd490d6 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-out/
\ No newline at end of file
+build.log

+out/

+

diff --git a/build.sh b/build.sh
index de85e78..f06ac34 100755
--- a/build.sh
+++ b/build.sh
@@ -10,28 +10,66 @@
 TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
 echo "toolchain : $ROOT_DIR"
 
-if [ ! -d out/bin ];then
-	mkdir -p out/bin
-fi
 
-if [ ! -d out/lib ];then
-	mkdir -p out/lib
-fi
 
-cd mbtk
+function build()
+{
+	cd mbtk
 
-if [ -n "$1" ] ;then
-	case "$1" in
-		clean)
-			make clean
-			;;
-		*)
-			exit 1;;
-	esac
-else	# 无参数
-	make
-fi
+	if [ -n "$1" ] ;then
+		case "$1" in
+			clean)
+				make clean
+				;;
+			*)
+				exit 1;;
+		esac
+	else	# 无参数
+		make || exit 1
+	fi
 
-cd $ROOT_DIR
+	cd $ROOT_DIR
 
-echo "Build complete."
\ No newline at end of file
+	echo "Build MBTK success."
+}
+
+function file_copy()
+{
+	ROOTFS_DIR=$ROOT_DIR/../asr_code/target/linux/mmp/base-files
+
+	if [ -d $ROOTFS_DIR ];then
+		echo "Copy MBTK out files..."
+		if [ ! -d $ROOTFS_DIR/bin ];then
+			mkdir $ROOTFS_DIR/bin
+		fi
+		if [ ! -d $ROOTFS_DIR/lib ];then
+			mkdir $ROOTFS_DIR/lib
+		fi
+		
+		# Copy All SO Files.
+		cp -f out/lib/* $ROOTFS_DIR/lib
+		
+		# Copy All Bin Files.
+		cp -f out/bin/* $ROOTFS_DIR/bin
+		
+	else
+		echo "No found rootfs : $ROOTFS_DIR"
+	fi
+}
+
+function main()
+{
+	if [ ! -d out/bin ];then
+		mkdir -p out/bin
+	fi
+
+	if [ ! -d out/lib ];then
+		mkdir -p out/lib
+	fi
+
+	build
+
+	file_copy
+}
+
+main
\ No newline at end of file
diff --git a/out/bin/aiti_audio_test b/out/bin/aiti_audio_test
deleted file mode 100755
index aa1ce65..0000000
--- a/out/bin/aiti_audio_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/at b/out/bin/at
deleted file mode 100755
index f875642..0000000
--- a/out/bin/at
+++ /dev/null
Binary files differ
diff --git a/out/bin/audio_test b/out/bin/audio_test
deleted file mode 100755
index 75d60b7..0000000
--- a/out/bin/audio_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/framebuffer_demo b/out/bin/framebuffer_demo
deleted file mode 100755
index 83c604a..0000000
--- a/out/bin/framebuffer_demo
+++ /dev/null
Binary files differ
diff --git a/out/bin/gnss_basic_demo b/out/bin/gnss_basic_demo
deleted file mode 100755
index 842a42a..0000000
--- a/out/bin/gnss_basic_demo
+++ /dev/null
Binary files differ
diff --git a/out/bin/gnss_update_demo b/out/bin/gnss_update_demo
deleted file mode 100755
index e4e4f38..0000000
--- a/out/bin/gnss_update_demo
+++ /dev/null
Binary files differ
diff --git a/out/bin/key_ev_demo b/out/bin/key_ev_demo
deleted file mode 100755
index 2e8e6d4..0000000
--- a/out/bin/key_ev_demo
+++ /dev/null
Binary files differ
diff --git a/out/bin/lynq_gnss_test b/out/bin/lynq_gnss_test
deleted file mode 100755
index 6ff1c31..0000000
--- a/out/bin/lynq_gnss_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/lynq_sms_test b/out/bin/lynq_sms_test
deleted file mode 100755
index d6da1db..0000000
--- a/out/bin/lynq_sms_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_adbd b/out/bin/mbtk_adbd
deleted file mode 100755
index f6b7381..0000000
--- a/out/bin/mbtk_adbd
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_adc_test b/out/bin/mbtk_adc_test
deleted file mode 100755
index e7a56f8..0000000
--- a/out/bin/mbtk_adc_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_at_test b/out/bin/mbtk_at_test
deleted file mode 100755
index cf29eaf..0000000
--- a/out/bin/mbtk_at_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_coap_test b/out/bin/mbtk_coap_test
deleted file mode 100755
index 93e60f9..0000000
--- a/out/bin/mbtk_coap_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_dtmf_test b/out/bin/mbtk_dtmf_test
deleted file mode 100755
index 7361085..0000000
--- a/out/bin/mbtk_dtmf_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_ftp_test b/out/bin/mbtk_ftp_test
deleted file mode 100755
index 5c0b2df..0000000
--- a/out/bin/mbtk_ftp_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_http_test b/out/bin/mbtk_http_test
deleted file mode 100755
index 3c01061..0000000
--- a/out/bin/mbtk_http_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_info_test b/out/bin/mbtk_info_test
deleted file mode 100755
index c81b7f1..0000000
--- a/out/bin/mbtk_info_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_logd b/out/bin/mbtk_logd
deleted file mode 100755
index 6425b0a..0000000
--- a/out/bin/mbtk_logd
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_mqtt_aliyun_test b/out/bin/mbtk_mqtt_aliyun_test
deleted file mode 100755
index 69d8189..0000000
--- a/out/bin/mbtk_mqtt_aliyun_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_mqtt_test b/out/bin/mbtk_mqtt_test
deleted file mode 100755
index 2061a4c..0000000
--- a/out/bin/mbtk_mqtt_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_net_control_test b/out/bin/mbtk_net_control_test
deleted file mode 100755
index 417632a..0000000
--- a/out/bin/mbtk_net_control_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/mbtk_ril b/out/bin/mbtk_ril
deleted file mode 100755
index 4424c3f..0000000
--- a/out/bin/mbtk_ril
+++ /dev/null
Binary files differ
diff --git a/out/bin/polarssl_demo b/out/bin/polarssl_demo
deleted file mode 100755
index 6d7ad61..0000000
--- a/out/bin/polarssl_demo
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_DSI_ConnectManager_test b/out/bin/ql_DSI_ConnectManager_test
deleted file mode 100755
index c847b6c..0000000
--- a/out/bin/ql_DSI_ConnectManager_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_adc_test b/out/bin/ql_adc_test
deleted file mode 100755
index d393b67..0000000
--- a/out/bin/ql_adc_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_call_test b/out/bin/ql_call_test
deleted file mode 100755
index 19b61d6..0000000
--- a/out/bin/ql_call_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_dev_test b/out/bin/ql_dev_test
deleted file mode 100755
index 16724b7..0000000
--- a/out/bin/ql_dev_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_gpio_test b/out/bin/ql_gpio_test
deleted file mode 100755
index 5da311b..0000000
--- a/out/bin/ql_gpio_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_i2c_test b/out/bin/ql_i2c_test
deleted file mode 100755
index a86fdd5..0000000
--- a/out/bin/ql_i2c_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_nw_test b/out/bin/ql_nw_test
deleted file mode 100755
index b21682c..0000000
--- a/out/bin/ql_nw_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_sim_test b/out/bin/ql_sim_test
deleted file mode 100755
index 85a1d32..0000000
--- a/out/bin/ql_sim_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_sms_test b/out/bin/ql_sms_test
deleted file mode 100755
index 849f07c..0000000
--- a/out/bin/ql_sms_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_spi_test b/out/bin/ql_spi_test
deleted file mode 100755
index 7056796..0000000
--- a/out/bin/ql_spi_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_uart_test b/out/bin/ql_uart_test
deleted file mode 100755
index 9b219e3..0000000
--- a/out/bin/ql_uart_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/ql_voice_test b/out/bin/ql_voice_test
deleted file mode 100755
index 50b6369..0000000
--- a/out/bin/ql_voice_test
+++ /dev/null
Binary files differ
diff --git a/out/bin/touch_ev_demo b/out/bin/touch_ev_demo
deleted file mode 100755
index 6f65bd3..0000000
--- a/out/bin/touch_ev_demo
+++ /dev/null
Binary files differ
diff --git a/out/lib/liblynq_lib.so b/out/lib/liblynq_lib.so
deleted file mode 100755
index 1f9ade3..0000000
--- a/out/lib/liblynq_lib.so
+++ /dev/null
Binary files differ
diff --git a/out/lib/libmbtk_lib.so b/out/lib/libmbtk_lib.so
deleted file mode 100755
index 4fe980e..0000000
--- a/out/lib/libmbtk_lib.so
+++ /dev/null
Binary files differ
diff --git a/out/lib/libmbtk_mqtt_lib.so b/out/lib/libmbtk_mqtt_lib.so
deleted file mode 100755
index 6046f58..0000000
--- a/out/lib/libmbtk_mqtt_lib.so
+++ /dev/null
Binary files differ
diff --git a/out/lib/libql_lib.so b/out/lib/libql_lib.so
deleted file mode 100755
index 3cf3d1d..0000000
--- a/out/lib/libql_lib.so
+++ /dev/null
Binary files differ