Check NDK linking, expose SDK_VERSION to Make

Modules defining sdk_version should only be allowed to link against the
ndk prebuilt libraries and other modules defining sdk_version. Implement
this, and expose the necessary information to Make so that it can be
implemented there as well.

Change-Id: I051498b595f8711883bc120f0394b8bfe2f65bce
diff --git a/cc/androidmk.go b/cc/androidmk.go
index a661c6c..4e35f0e 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -35,6 +35,13 @@
 		if len(c.Properties.AndroidMkSharedLibs) > 0 {
 			fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
 		}
+		if c.Target().Os == android.Android && c.Properties.Sdk_version != "" {
+			fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
+			fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
+		} else {
+			// These are already included in LOCAL_SHARED_LIBRARIES
+			fmt.Fprintln(w, "LOCAL_CXX_STL := none")
+		}
 		return nil
 	})
 
@@ -85,8 +92,6 @@
 
 		fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
 
-		// These are already included in LOCAL_SHARED_LIBRARIES
-		fmt.Fprintln(w, "LOCAL_CXX_STL := none")
 		fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
 
 		return nil