Fix build.sh script.

Change-Id: Iadd03c2dd1e77d8ccc034aa8eb4b495bb9bb6e96
diff --git a/build.sh b/build.sh
index 6b8a296..6a65bd4 100755
--- a/build.sh
+++ b/build.sh
@@ -14,11 +14,29 @@
 	export BUILD_STD_LIBC=glibc
 fi
 
-MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
-if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
-	export MBTK_SOURCE_VERSION=2
+if [ -n "$1" ] ;then
+	case "$1" in
+		v1)
+			export MBTK_SOURCE_VERSION=1
+			;;
+		v2)
+			export MBTK_SOURCE_VERSION=2
+			;;
+		*)
+			MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
+			if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
+				export MBTK_SOURCE_VERSION=2
+			else
+				export MBTK_SOURCE_VERSION=1
+			fi
+	esac
 else
-	export MBTK_SOURCE_VERSION=1
+	MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
+	if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
+		export MBTK_SOURCE_VERSION=2
+	else
+		export MBTK_SOURCE_VERSION=1
+	fi
 fi
 
 function build()
@@ -129,33 +147,39 @@
 
 function main()
 {
-	if [ -n "$1" ] ;then
-		build $1
-		exit 0
-	fi
-
-	if [ -d out/bin -a -d out/lib ];then
-		build
-		
-		print_arg
-
-		file_copy
-	else
-		if [ ! -d out/lib ];then
-			mkdir -p out/lib
-		fi
-		
-		if [ ! -d out/bin ];then
-			mkdir -p out/bin
-		fi
-
-		build
-		
-		print_arg
-
-		file_copy
+	if [ ! -d out/lib ];then
+		mkdir -p out/lib
 	fi
 	
+	if [ ! -d out/bin ];then
+		mkdir -p out/bin
+	fi
+
+	if [ -n "$1" ] ;then
+		if [ "$1" == "v1" -o "$1" == "v2" ];then
+			build clean
+			
+			
+		else
+			build $1
+			exit 0
+		fi
+	fi
+	
+	if [ ! -d out/lib ];then
+		mkdir -p out/lib
+	fi
+	
+	if [ ! -d out/bin ];then
+		mkdir -p out/bin
+	fi
+
+	build
+	
+	print_arg
+
+	file_copy
+
 	temp_mbtk_copy
 }