Merge "Revert "Convert libcore native code to Android.bp""
diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 2230ac7..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,3 +0,0 @@
-build = [
-    "NativeCode.bp",
-]
diff --git a/Android.mk b/Android.mk
index 1427f4b..3c25583 100644
--- a/Android.mk
+++ b/Android.mk
@@ -29,6 +29,11 @@
 include $(LOCAL_PATH)/JavaLibrary.mk
 
 #
+# Include the definitions to build the native code.
+#
+
+include $(LOCAL_PATH)/NativeCode.mk
+
 # Disable test modules if LIBCORE_SKIP_TESTS environment variable is set.
 #
 
diff --git a/NativeCode.bp b/NativeCode.bp
deleted file mode 100644
index 3b63072..0000000
--- a/NativeCode.bp
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright (C) 2007 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.
-
-//
-// Definitions for building the native code needed for the core library.
-//
-
-// Defaults that apply to all of the modules
-cc_defaults {
-    name: "core_native_defaults",
-    host_supported: true,
-    local_include_dirs: ["include"],
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-    ],
-    cppflags = ["-DU_USING_ICU_NAMESPACE=0"],
-
-    static_libs: [
-        "libbase",
-        "libfdlibm",
-    ],
-
-    shared_libs: [
-        "liblog",
-        "libnativehelper",
-    ],
-
-    host_ldlibs: [
-        "-ldl",
-        "-lpthread",
-    ],
-
-    target: {
-        linux: {
-            host_ldlibs: ["-lrt"],
-        },
-        darwin: {
-            enabled: false,
-        },
-    },
-}
-
-cc_library_shared {
-    name: "libjavacore",
-    defaults: ["core_native_defaults"],
-    srcs: [
-        ":luni_native_srcs",
-        "dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp"
-    ],
-
-    shared_libs: [
-        "libcrypto",
-        "libexpat",
-        "libicuuc",
-        "libicui18n",
-        "libnativehelper",
-    ],
-    static_libs: [
-        "libziparchive",
-        "libbase",
-    ],
-    target: {
-        android: {
-            shared_libs: [
-                "libutils",
-                "libz",
-            ],
-        },
-        host: {
-            shared_libs: [
-                "libz-host",
-            ],
-        },
-    },
-}
-
-cc_defaults {
-    name: "libopenjdk_native_defaults",
-    defaults: ["core_native_defaults"],
-    srcs: [":libopenjdk_native_srcs"],
-    cflags: [
-        // TODO(narayan): Prune down this list of exclusions once the underlying
-        // issues have been fixed. Most of these are small changes except for
-        // -Wunused-parameter.
-        "-Wno-unused-parameter",
-        "-Wno-unused-variable",
-        "-Wno-parentheses-equality",
-        "-Wno-constant-logical-operand",
-        "-Wno-sometimes-uninitialized",
-
-        // TODO(http://b/64362645): remove when upstream replaces readdir_r with readdir.
-        "-Wno-deprecated-declarations",
-    ],
-
-    shared_libs: [
-        "libcrypto",
-        "libicuuc",
-        "libssl",
-
-        "libnativehelper",
-    ],
-    static_libs: ["libfdlibm"],
-
-    target: {
-        linux: {
-            cflags: [ // Sigh.
-                "-D_LARGEFILE64_SOURCE",
-                "-D_GNU_SOURCE",
-                "-DLINUX",
-                "-D__GLIBC__",
-            ],
-        },
-        android: {
-            shared_libs: ["libz"],
-        },
-        host: {
-            shared_libs: ["libz-host"],
-        },
-    },
-
-    notice: "ojluni/NOTICE",
-}
-
-cc_library_shared {
-    name: "libopenjdk",
-    defaults: ["libopenjdk_native_defaults"],
-    shared_libs: [
-        "libopenjdkjvm",
-    ],
-}
-
-// Debug version of libopenjdk. Depends on libopenjdkjvmd.
-cc_library_shared {
-    name: "libopenjdkd",
-    defaults: ["libopenjdk_native_defaults"],
-    shared_libs: [
-        "libopenjdkjvmd",
-    ],
-}
-
-// Test JNI library.
-cc_library_shared {
-    name: "libjavacoretests",
-    defaults: ["core_native_defaults"],
-    host_supported:true,
-
-    srcs: [
-        "luni/src/test/native/dalvik_system_JniTest.cpp",
-        "luni/src/test/native/libcore_java_io_FileTest.cpp",
-        "luni/src/test/native/libcore_java_lang_ThreadTest.cpp",
-        "luni/src/test/native/libcore_java_nio_BufferTest.cpp",
-        "luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp",
-    ],
-    target: {
-        android: {
-            shared_libs: ["libnativehelper_compat_libc++"],
-        },
-    },
-
-    strip: {
-        keep_symbols: true,
-    },
-}
-
-// Set of gtest unit tests.
-cc_test {
-    name: "libjavacore-unit-tests",
-    defaults: ["core_native_defaults"],
-
-    // Add -fno-builtin so that the compiler doesn't attempt to inline
-    // memcpy calls that are not really aligned.
-    cflags: ["-fno-builtin"],
-    srcs: ["luni/src/test/native/libcore_io_Memory_test.cpp"],
-
-    shared_libs: ["libnativehelper"],
-}
-
-// Set of benchmarks for libjavacore functions.
-cc_benchmark {
-    name: "libjavacore-benchmarks",
-    defaults: ["core_native_defaults"],
-
-    srcs: ["luni/src/benchmark/native/libcore_io_Memory_bench.cpp"],
-    test_suites: ["device-tests"],
-
-    shared_libs: ["libnativehelper"],
-}
-
-subdirs = [
-    "luni/src/main/native",
-    "ojluni/src/main/native",
-]
diff --git a/NativeCode.mk b/NativeCode.mk
new file mode 100644
index 0000000..cedc69b
--- /dev/null
+++ b/NativeCode.mk
@@ -0,0 +1,293 @@
+# -*- mode: makefile -*-
+# Copyright (C) 2007 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.
+
+#
+# Definitions for building the native code needed for the core library.
+#
+
+#
+# Common definitions for host and target.
+#
+
+# These two definitions are used to help sanity check what's put in
+# sub.mk. See, the "error" directives immediately below.
+core_magic_local_target := ...//::default:://...
+core_local_path := $(LOCAL_PATH)
+
+# Include a submakefile, resolve its source file locations,
+# and stick them on core_src_files.  The submakefiles are
+# free to append to LOCAL_SRC_FILES, LOCAL_C_INCLUDES,
+# LOCAL_SHARED_LIBRARIES, or LOCAL_STATIC_LIBRARIES, but nothing
+# else. All other LOCAL_* variables will be ignored.
+#
+# $(1): directory containing the makefile to include
+define include-core-native-dir
+    LOCAL_SRC_FILES :=
+    include $(LOCAL_PATH)/$(1)/sub.mk
+    ifneq ($$(LOCAL_MODULE),$(core_magic_local_target))
+        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \
+            or define LOCAL_MODULE)
+    endif
+    ifneq ($$(LOCAL_PATH),$(core_local_path))
+        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
+    endif
+    core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
+    LOCAL_SRC_FILES :=
+endef
+
+define include-openjdk-native-dir
+    LOCAL_SRC_FILES :=
+    include $(LOCAL_PATH)/$(1)/openjdksub.mk
+    openjdk_core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
+    LOCAL_SRC_FILES :=
+endef
+
+# Set up the default state. Note: We use CLEAR_VARS here, even though
+# we aren't quite defining a new rule yet, to make sure that the
+# sub.mk files don't see anything stray from the last rule that was
+# set up.
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := $(core_magic_local_target)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+core_src_files :=
+openjdk_core_src_files :=
+
+#Include the sub.mk for openjdk.
+$(foreach dir, \
+    ojluni/src/main/native, \
+    $(eval $(call include-openjdk-native-dir,$(dir))))
+
+# Include the sub.mk files.
+$(foreach dir, \
+    dalvik/src/main/native luni/src/main/native, \
+    $(eval $(call include-core-native-dir,$(dir))))
+
+# Extract out the allowed LOCAL_* variables.
+core_c_includes := libcore/include $(LOCAL_C_INCLUDES)
+core_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+core_static_libraries := $(LOCAL_STATIC_LIBRARIES)
+libart_cflags := $(LOCAL_CFLAGS) -Wall -Wextra -Werror
+core_cppflags += -DU_USING_ICU_NAMESPACE=0
+# TODO(narayan): Prune down this list of exclusions once the underlying
+# issues have been fixed. Most of these are small changes except for
+# -Wunused-parameter.
+openjdk_cflags := $(libart_cflags) \
+    -Wno-unused-parameter \
+    -Wno-unused-variable \
+    -Wno-parentheses-equality \
+    -Wno-constant-logical-operand \
+    -Wno-sometimes-uninitialized
+
+# TODO(http://b/64362645): remove when upstream replaces readdir_r with readdir.
+openjdk_cflags += -Wno-deprecated-declarations
+
+core_test_files := \
+  luni/src/test/native/dalvik_system_JniTest.cpp \
+  luni/src/test/native/libcore_java_io_FileTest.cpp \
+  luni/src/test/native/libcore_java_lang_ThreadTest.cpp \
+  luni/src/test/native/libcore_java_nio_BufferTest.cpp \
+  luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp \
+
+#
+# Build for the target (device).
+#
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+LOCAL_SRC_FILES += $(core_src_files)
+LOCAL_C_INCLUDES += $(core_c_includes)
+LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libdl libexpat libicuuc libicui18n libnativehelper libz libutils
+LOCAL_STATIC_LIBRARIES += $(core_static_libraries) libziparchive libbase
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libjavacore
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+LOCAL_CXX_STL := libc++
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+ifeq ($(TARGET_ARCH),arm)
+# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
+LOCAL_CFLAGS += -Wno-psabi
+endif
+
+# Define the rules.
+LOCAL_CFLAGS += $(openjdk_cflags)
+LOCAL_SRC_FILES := $(openjdk_core_src_files)
+LOCAL_C_INCLUDES := $(core_c_includes)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libcrypto libicuuc libssl libz
+LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper libdl
+LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libopenjdk
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
+LOCAL_CXX_STL := libc++
+include $(BUILD_SHARED_LIBRARY)
+
+# Debug version of libopenjdk. Depends on libopenjdkjvmd.
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+ifeq ($(TARGET_ARCH),arm)
+# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
+LOCAL_CFLAGS += -Wno-psabi
+endif
+
+LOCAL_CFLAGS += $(openjdk_cflags)
+LOCAL_SRC_FILES := $(openjdk_core_src_files)
+LOCAL_C_INCLUDES := $(core_c_includes)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libcrypto libicuuc libssl libz
+LOCAL_SHARED_LIBRARIES += libopenjdkjvmd libnativehelper libdl
+LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libopenjdkd
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
+LOCAL_CXX_STL := libc++
+include $(BUILD_SHARED_LIBRARY)
+
+# Test JNI library.
+ifeq ($(LIBCORE_SKIP_TESTS),)
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+LOCAL_SRC_FILES += $(core_test_files)
+LOCAL_C_INCLUDES += libcore/include
+LOCAL_SHARED_LIBRARIES += libnativehelper_compat_libc++
+LOCAL_MODULE_TAGS := optional
+LOCAL_STRIP_MODULE := keep_symbols
+LOCAL_MODULE := libjavacoretests
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+LOCAL_CXX_STL := libc++
+include $(BUILD_SHARED_LIBRARY)
+
+endif # LIBCORE_SKIP_TESTS
+
+# Set of gtest unit tests.
+include $(CLEAR_VARS)
+# Add -fno-builtin so that the compiler doesn't attempt to inline
+# memcpy calls that are not really aligned.
+LOCAL_CFLAGS += $(libart_cflags) -fno-builtin
+LOCAL_CPPFLAGS += $(core_cppflags)
+LOCAL_SRC_FILES += \
+  luni/src/test/native/libcore_io_Memory_test.cpp \
+
+LOCAL_C_INCLUDES += libcore/include
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libjavacore-unit-tests
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+LOCAL_SHARED_LIBRARIES := libnativehelper
+LOCAL_CXX_STL := libc++
+include $(BUILD_NATIVE_TEST)
+
+# Set of benchmarks for libjavacore functions.
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+LOCAL_SRC_FILES += \
+  luni/src/benchmark/native/libcore_io_Memory_bench.cpp \
+
+LOCAL_C_INCLUDES += libcore/include
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libjavacore-benchmarks
+LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+LOCAL_SHARED_LIBRARIES := libnativehelper
+LOCAL_CXX_STL := libc++
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+include $(BUILD_NATIVE_BENCHMARK)
+
+
+#
+# Build for the host.
+#
+
+ifeq ($(HOST_OS),linux)
+
+include $(CLEAR_VARS)
+LOCAL_CLANG := true
+LOCAL_SRC_FILES += $(core_src_files)
+LOCAL_CFLAGS += $(libart_cflags)
+LOCAL_C_INCLUDES += $(core_c_includes)
+LOCAL_CPPFLAGS += $(core_cppflags)
+LOCAL_LDLIBS += -ldl -lpthread
+ifeq ($(HOST_OS),linux)
+LOCAL_LDLIBS += -lrt
+endif
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libjavacore
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat libicuuc libicui18n libcrypto libz-host libziparchive
+LOCAL_STATIC_LIBRARIES += $(core_static_libraries)
+LOCAL_MULTILIB := both
+LOCAL_CXX_STL := libc++
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+# Debug version of libopenjdk (host). Depends on libopenjdkjvmd.
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(openjdk_core_src_files)
+LOCAL_C_INCLUDES := $(core_c_includes)
+LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DLINUX -D__GLIBC__ # Sigh.
+LOCAL_CFLAGS += $(openjdk_cflags)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libicuuc libcrypto libz-host
+LOCAL_SHARED_LIBRARIES += libopenjdkjvmd libnativehelper
+LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
+LOCAL_MODULE_TAGS := optional
+LOCAL_LDLIBS += -ldl -lpthread -lrt
+LOCAL_MODULE := libopenjdkd
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
+LOCAL_MULTILIB := both
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(openjdk_core_src_files)
+LOCAL_C_INCLUDES := $(core_c_includes)
+LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DLINUX -D__GLIBC__ # Sigh.
+LOCAL_CFLAGS += $(openjdk_cflags)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libicuuc libcrypto libz-host
+LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper
+LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
+LOCAL_MODULE_TAGS := optional
+LOCAL_LDLIBS += -ldl -lpthread -lrt
+LOCAL_MODULE := libopenjdk
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
+LOCAL_MULTILIB := both
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+ifeq ($(LIBCORE_SKIP_TESTS),)
+    include $(CLEAR_VARS)
+    LOCAL_CLANG := true
+    LOCAL_SRC_FILES += $(core_test_files)
+    LOCAL_CFLAGS += $(libart_cflags)
+    LOCAL_C_INCLUDES += libcore/include
+    LOCAL_CPPFLAGS += $(core_cppflags)
+    LOCAL_LDLIBS += -ldl -lpthread
+    LOCAL_MODULE_TAGS := optional
+    LOCAL_MODULE := libjavacoretests
+    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
+    LOCAL_SHARED_LIBRARIES := libnativehelper
+    LOCAL_MULTILIB := both
+    LOCAL_CXX_STL := libc++
+    include $(BUILD_HOST_SHARED_LIBRARY)
+endif # LIBCORE_SKIP_TESTS
+
+endif # HOST_OS == linux
diff --git a/dalvik/src/main/native/sub.mk b/dalvik/src/main/native/sub.mk
new file mode 100644
index 0000000..4adc8a1
--- /dev/null
+++ b/dalvik/src/main/native/sub.mk
@@ -0,0 +1,17 @@
+# -*- mode: makefile -*-
+# This file is included by the top-level libcore Android.mk.
+# It's not a normal makefile, so we don't include CLEAR_VARS
+# or BUILD_*_LIBRARY.
+
+LOCAL_SRC_FILES := \
+	org_apache_harmony_dalvik_NativeTestTarget.cpp
+
+#LOCAL_C_INCLUDES +=
+
+# Any shared/static libs that are listed here must also
+# be listed in libs/nativehelper/Android.mk.
+# TODO: fix this requirement
+
+#LOCAL_SHARED_LIBRARIES +=
+
+#LOCAL_STATIC_LIBRARIES +=
diff --git a/luni/src/main/native/Android.bp b/luni/src/main/native/Android.bp
deleted file mode 100644
index a8e7ee7..0000000
--- a/luni/src/main/native/Android.bp
+++ /dev/null
@@ -1,28 +0,0 @@
-filegroup {
-    name: "luni_native_srcs",
-    srcs: [
-        "ExecStrings.cpp",
-        "IcuUtilities.cpp",
-        "JniException.cpp",
-        "NetworkUtilities.cpp",
-        "Register.cpp",
-        "ZipUtilities.cpp",
-        "android_system_OsConstants.cpp",
-        "cbigint.cpp",
-        "java_lang_StringToReal.cpp",
-        "java_lang_invoke_MethodHandle.cpp",
-        "java_math_NativeBN.cpp",
-        "java_util_regex_Matcher.cpp",
-        "java_util_regex_Pattern.cpp",
-        "libcore_icu_ICU.cpp",
-        "libcore_icu_NativeConverter.cpp",
-        "libcore_icu_TimeZoneNames.cpp",
-        "libcore_io_AsynchronousCloseMonitor.cpp",
-        "libcore_io_Linux.cpp",
-        "libcore_io_Memory.cpp",
-        "libcore_util_NativeAllocationRegistry.cpp",
-        "org_apache_harmony_xml_ExpatParser.cpp",
-        "sun_misc_Unsafe.cpp",
-        "valueOf.cpp",
-    ],
-}
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
new file mode 100644
index 0000000..0706ce8
--- /dev/null
+++ b/luni/src/main/native/sub.mk
@@ -0,0 +1,37 @@
+# -*- mode: makefile -*-
+# This file is included by the top-level libcore Android.mk.
+# It's not a normal makefile, so we don't include CLEAR_VARS
+# or BUILD_*_LIBRARY.
+
+LOCAL_SRC_FILES := \
+    ExecStrings.cpp \
+    IcuUtilities.cpp \
+    JniException.cpp \
+    NetworkUtilities.cpp \
+    Register.cpp \
+    ZipUtilities.cpp \
+    android_system_OsConstants.cpp \
+    cbigint.cpp \
+    java_lang_StringToReal.cpp \
+    java_lang_invoke_MethodHandle.cpp \
+    java_math_NativeBN.cpp \
+    java_util_regex_Matcher.cpp \
+    java_util_regex_Pattern.cpp \
+    libcore_icu_ICU.cpp \
+    libcore_icu_NativeConverter.cpp \
+    libcore_icu_TimeZoneNames.cpp \
+    libcore_io_AsynchronousCloseMonitor.cpp \
+    libcore_io_Linux.cpp \
+    libcore_io_Memory.cpp \
+    libcore_util_NativeAllocationRegistry.cpp \
+    org_apache_harmony_xml_ExpatParser.cpp \
+    sun_misc_Unsafe.cpp \
+    valueOf.cpp \
+
+LOCAL_STATIC_LIBRARIES += \
+    libbase \
+    libfdlibm \
+
+LOCAL_SHARED_LIBRARIES += \
+    liblog \
+    libnativehelper \
diff --git a/ojluni/src/main/native/Android.bp b/ojluni/src/main/native/Android.bp
deleted file mode 100644
index 71546ca..0000000
--- a/ojluni/src/main/native/Android.bp
+++ /dev/null
@@ -1,65 +0,0 @@
-filegroup {
-    name: "libopenjdk_native_srcs",
-    srcs: [
-        "java_util_zip_ZipFile.c",
-        "java_util_zip_Inflater.c",
-        "java_util_zip_Deflater.c",
-        "java_util_zip_CRC32.c",
-        "Adler32.c",
-        "zip_util.c",
-        "jni_util.c",
-        "jni_util_md.c",
-        "io_util.c",
-        "canonicalize_md.c",
-        "FileDescriptor_md.c",
-        "DatagramChannelImpl.c",
-        "DatagramDispatcher.c",
-        "Console_md.c",
-        "IOUtil.c",
-        "PollArrayWrapper.c",
-        "SocketChannelImpl.c",
-        "FileChannelImpl.c",
-        "FileDispatcherImpl.c",
-        "FileOutputStream_md.c",
-        "FileInputStream.c",
-        "FileSystemPreferences.c",
-        "EPoll.c",
-        "EPollPort.c",
-        "UnixAsynchronousServerSocketChannelImpl.c",
-        "UnixAsynchronousSocketChannelImpl.c",
-        "io_util_md.c",
-        "NativeThread.c",
-        "FileKey.c",
-        "UnixFileSystem_md.c",
-        "ObjectStreamClass.c",
-        "ObjectOutputStream.c",
-        "ObjectInputStream.c",
-        "LinuxNativeDispatcher.c",
-        "LinuxWatchService.c",
-        "UnixCopyFile.c",
-        "UnixNativeDispatcher.c",
-        "InetAddress.c",
-        "net_util.c",
-        "net_util_md.c",
-        "Net.c",
-        "MappedByteBuffer.c",
-        "Inet6Address.c",
-        "Inet4Address.c",
-        "linux_close.cpp",
-        "ServerSocketChannelImpl.c",
-        "SocketInputStream.c",
-        "SocketOutputStream.c",
-        "Float.c",
-        "Double.c",
-        "StrictMath.c",
-        "Math.c",
-        "ProcessEnvironment_md.c",
-        "System.c",
-        "Runtime.c",
-        "UNIXProcess_md.c",
-        "Bits.c",
-        "Character.cpp",
-        "Register.cpp",
-        "socket_tagger_util.cpp",
-    ],
-}
diff --git a/ojluni/src/main/native/openjdksub.mk b/ojluni/src/main/native/openjdksub.mk
new file mode 100644
index 0000000..d60bc09
--- /dev/null
+++ b/ojluni/src/main/native/openjdksub.mk
@@ -0,0 +1,73 @@
+# -*- mode: makefile -*-
+# This file is included by the top-level libcore Android.mk.
+# It's not a normal makefile, so we don't include CLEAR_VARS
+# or BUILD_*_LIBRARY.
+
+srcdir := ojluni/src/main/native
+LOCAL_SRC_FILES := \
+    java_util_zip_ZipFile.c \
+    java_util_zip_Inflater.c \
+    java_util_zip_Deflater.c \
+    java_util_zip_CRC32.c \
+    Adler32.c \
+    zip_util.c \
+    jni_util.c \
+    jni_util_md.c \
+    io_util.c \
+    canonicalize_md.c \
+    FileDescriptor_md.c \
+    DatagramChannelImpl.c \
+    DatagramDispatcher.c \
+    Console_md.c \
+    IOUtil.c \
+    PollArrayWrapper.c \
+    SocketChannelImpl.c \
+    FileChannelImpl.c \
+    FileDispatcherImpl.c \
+    FileOutputStream_md.c \
+    FileInputStream.c \
+    FileSystemPreferences.c \
+    EPoll.c \
+    EPollPort.c \
+    UnixAsynchronousServerSocketChannelImpl.c \
+    UnixAsynchronousSocketChannelImpl.c \
+    io_util_md.c \
+    NativeThread.c \
+    FileKey.c \
+    UnixFileSystem_md.c \
+    ObjectStreamClass.c \
+    ObjectOutputStream.c \
+    ObjectInputStream.c \
+    LinuxNativeDispatcher.c \
+    LinuxWatchService.c \
+    UnixCopyFile.c \
+    UnixNativeDispatcher.c \
+    InetAddress.c \
+    net_util.c \
+    net_util_md.c \
+    Net.c \
+    MappedByteBuffer.c \
+    Inet6Address.c \
+    Inet4Address.c \
+    linux_close.cpp \
+    ServerSocketChannelImpl.c \
+    SocketInputStream.c \
+    SocketOutputStream.c \
+    Float.c \
+    Double.c \
+    StrictMath.c \
+    Math.c \
+    ProcessEnvironment_md.c \
+    System.c \
+    Runtime.c \
+    UNIXProcess_md.c \
+    Bits.c \
+    Character.cpp \
+    Register.cpp \
+    socket_tagger_util.cpp \
+
+LOCAL_C_INCLUDES += \
+       libcore/$(srcdir) \
+       external/fdlibm \
+       external/zlib \
+       external/icu/icu4c/source/common \