Split renderscript java code from test apps.  Update makefiles.
diff --git a/Android.mk b/Android.mk
index 6ff39a4..00aaadd 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,11 +1,11 @@
 # Only build if BUILD_RENDERSCRIPT is defined to true in the environment.
 ifeq ($(BUILD_RENDERSCRIPT),true)
 
-TOP_LOCAL_PATH:=$(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_PATH:= $(TOP_LOCAL_PATH)
+LOCAL_PATH:=$(call my-dir)
 
-# Build rsg-generator
+
+# Build rsg-generator ====================
+include $(CLEAR_VARS)
 
 LOCAL_MODULE := rsg-generator
 
@@ -14,7 +14,7 @@
 
 LOCAL_IS_HOST_MODULE := true
 LOCAL_MODULE_CLASS := EXECUTABLES
-intermediates:= $(local-intermediates-dir)
+intermediates := $(local-intermediates-dir)
 
 GEN := $(addprefix $(intermediates)/, \
             lex.yy.c \
@@ -28,21 +28,21 @@
 
 LOCAL_SRC_FILES:= \
     rsg_generator.c
-	
+
 include $(BUILD_HOST_EXECUTABLE)
 
+# TODO: This should go into build/core/config.mk
 RSG_GENERATOR:=$(LOCAL_BUILT_MODULE)
 
-# Build render script lib
 
+
+# Build render script lib ====================
 include $(CLEAR_VARS)
 LOCAL_MODULE := libRS
 
 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
 intermediates:= $(local-intermediates-dir)
 
-RS_GENERATED_INCLUDE_DIR:=$(intermediates)
-
 # Generate custom headers
 
 GEN := $(addprefix $(intermediates)/, \
@@ -50,12 +50,13 @@
             rsgApiFuncDecl.h \
         )
 
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(TOP_LOCAL_PATH)/rs.spec
+$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(LOCAL_PATH)/rs.spec
 $(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
 $(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.h.rsg
 	$(transform-generated-source)
 
-RS_GENERATED_SOURCES += $(GEN)
+# used in jni/Android.mk
+rs_generated_source += $(GEN)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 # Generate custom source files
@@ -65,12 +66,13 @@
             rsgApiReplay.cpp \
         )
 
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(TOP_LOCAL_PATH)/rs.spec
+$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(LOCAL_PATH)/rs.spec
 $(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
 $(GEN): $(intermediates)/%.cpp : $(LOCAL_PATH)/%.cpp.rsg
 	$(transform-generated-source)
 
-RS_GENERATED_SOURCES += $(GEN)
+# used in jni/Android.mk
+rs_generated_source += $(GEN)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 LOCAL_SRC_FILES:= \
@@ -99,45 +101,15 @@
 LOCAL_MODULE:= libRS
 LOCAL_PRELINK_MODULE := false
 
-#LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
 
-# Build JNI library
 
-LOCAL_PATH:= $(TOP_LOCAL_PATH)/jni
-include $(CLEAR_VARS)
+# Include the subdirectories ====================
+include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk,\
+            jni \
+            java \
+    	))
 
-LOCAL_SRC_FILES:= \
-	RenderScript_jni.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-	libandroid_runtime \
-	libacc \
-	libnativehelper \
-	libRS \
-	libcutils \
-    libsgl \
-	libutils \
-	libui
-
-LOCAL_STATIC_LIBRARIES :=
-
-LOCAL_C_INCLUDES += \
-	$(JNI_H_INCLUDE) \
-	$(RS_GENERATED_INCLUDE_DIR) \
-	$(call include-path-for, corecg graphics)
-
-LOCAL_CFLAGS +=
-
-LOCAL_LDLIBS := -lpthread
-
-LOCAL_MODULE:= libRS_jni
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_ADDITIONAL_DEPENDENCIES += $(RS_GENERATED_SOURCES)
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(call all-subdir-makefiles)
 endif # BUILD_RENDERSCRIPT
diff --git a/java/Fountain/Android.mk b/java/Fountain/Android.mk
index cf08467..af3d5fc 100644
--- a/java/Fountain/Android.mk
+++ b/java/Fountain/Android.mk
@@ -18,14 +18,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
 
 LOCAL_PACKAGE_NAME := Fountain
 
 include $(BUILD_PACKAGE)
-##################################################
-include $(CLEAR_VARS)
-
-include $(BUILD_MULTI_PREBUILT)
-
-# Use the folloing include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/java/Fountain/src/com/android/fountain/Fountain.java b/java/Fountain/src/com/android/fountain/Fountain.java
index 0d66966..58c78fa 100644
--- a/java/Fountain/src/com/android/fountain/Fountain.java
+++ b/java/Fountain/src/com/android/fountain/Fountain.java
@@ -16,6 +16,9 @@
 
 package com.android.fountain;
 
+import android.renderscript.RSSurfaceView;
+import android.renderscript.RenderScript;
+
 import android.app.Activity;
 import android.content.res.Configuration;
 import android.os.Bundle;
diff --git a/java/Fountain/src/com/android/fountain/FountainView.java b/java/Fountain/src/com/android/fountain/FountainView.java
index 0a6f7c5..f8b488a 100644
--- a/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/java/Fountain/src/com/android/fountain/FountainView.java
@@ -20,6 +20,9 @@
 import java.util.ArrayList;
 import java.util.concurrent.Semaphore;
 
+import android.renderscript.RSSurfaceView;
+import android.renderscript.RenderScript;
+
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -109,9 +112,9 @@
         mParams[2] = 0;
         mParams[3] = 0;
         mParams[4] = 0;
-        mParams[5] = mPartAlloc.mID;
-        mParams[6] = mPF.mID;
-        mParams[7] = mPF2.mID;
+        mParams[5] = mPartAlloc.getID();
+        mParams[6] = mPF.getID();
+        mParams[7] = mPF2.getID();
         mIntAlloc.data(mParams);
 
         int t2[] = new int[partCount * 4*3];
diff --git a/java/RenderScript/Android.mk b/java/RenderScript/Android.mk
new file mode 100644
index 0000000..616fbd2
--- /dev/null
+++ b/java/RenderScript/Android.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2008 Esmertec AG.
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+# the library
+# ============================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+            $(call all-subdir-java-files) 
+
+LOCAL_MODULE:= android.renderscript
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/java/Fountain/src/com/android/fountain/RSSurfaceView.java b/java/RenderScript/android/renderscript/RSSurfaceView.java
similarity index 98%
rename from java/Fountain/src/com/android/fountain/RSSurfaceView.java
rename to java/RenderScript/android/renderscript/RSSurfaceView.java
index a8b3bca..3d37c13 100644
--- a/java/Fountain/src/com/android/fountain/RSSurfaceView.java
+++ b/java/RenderScript/android/renderscript/RSSurfaceView.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.fountain;
+package android.renderscript;
 
 import java.io.Writer;
 import java.util.ArrayList;
diff --git a/java/Fountain/src/com/android/fountain/RenderScript.java b/java/RenderScript/android/renderscript/RenderScript.java
similarity index 99%
rename from java/Fountain/src/com/android/fountain/RenderScript.java
rename to java/RenderScript/android/renderscript/RenderScript.java
index fcfb82d..da54822 100644
--- a/java/Fountain/src/com/android/fountain/RenderScript.java
+++ b/java/RenderScript/android/renderscript/RenderScript.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.fountain;
+package android.renderscript;
 
 import java.io.InputStream;
 import java.io.IOException;
@@ -169,6 +169,10 @@
             mID = 0;
         }
 
+        public int getID() {
+            return mID;
+        }
+
         int mID;
         String mName;
 
diff --git a/jni/Android.mk b/jni/Android.mk
new file mode 100644
index 0000000..b3142ae
--- /dev/null
+++ b/jni/Android.mk
@@ -0,0 +1,36 @@
+LOCAL_PATH:=$(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	RenderScript_jni.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+        libandroid_runtime \
+        libacc \
+        libnativehelper \
+        libRS \
+        libcutils \
+        libsgl \
+        libutils \
+        libui
+
+LOCAL_STATIC_LIBRARIES :=
+
+rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS,,)
+
+LOCAL_C_INCLUDES += \
+	$(JNI_H_INCLUDE) \
+	$(rs_generated_include_dir) \
+	$(call include-path-for, corecg graphics)
+
+LOCAL_CFLAGS +=
+
+LOCAL_LDLIBS := -lpthread
+
+LOCAL_MODULE:= libRS_jni
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_ADDITIONAL_DEPENDENCIES += $(rs_generated_source)
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/jni/RenderScript_jni.cpp b/jni/RenderScript_jni.cpp
index 2dadf07..dcd6e2f 100644
--- a/jni/RenderScript_jni.cpp
+++ b/jni/RenderScript_jni.cpp
@@ -820,7 +820,7 @@
 // ---------------------------------------------------------------------------
 
 
-static const char *classPathName = "com/android/fountain/RenderScript";
+static const char *classPathName = "android/renderscript/RenderScript";
 
 static JNINativeMethod methods[] = {
 {"_nInit",                         "()V",                                  (void*)_nInit },