Merge "Revert "Convert libart and dependencies to Android.bp""
diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 835048d..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,6 +0,0 @@
-subdirs = [
-    "build",
-    "compiler",
-    "runtime",
-    "sigchainlib",
-]
diff --git a/Android.mk b/Android.mk
index 9d0062b..4dc84c4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -76,6 +76,9 @@
 ########################################################################
 # product rules
 
+include $(art_path)/runtime/Android.mk
+include $(art_path)/runtime/simulator/Android.mk
+include $(art_path)/compiler/Android.mk
 include $(art_path)/dexdump/Android.mk
 include $(art_path)/dexlist/Android.mk
 include $(art_path)/dex2oat/Android.mk
@@ -89,6 +92,7 @@
 include $(art_path)/tools/ahat/Android.mk
 include $(art_path)/tools/dexfuzz/Android.mk
 include $(art_path)/tools/dmtracedump/Android.mk
+include $(art_path)/sigchainlib/Android.mk
 include $(art_path)/libart_fake/Android.mk
 
 
@@ -551,6 +555,9 @@
 art_test_bother :=
 TEST_ART_TARGET_SYNC_DEPS :=
 
+include $(art_path)/runtime/openjdkjvm/Android.mk
+include $(art_path)/runtime/openjdkjvmti/Android.mk
+
 # Helper target that depends on boot image creation.
 #
 # Can be used, for example, to dump initialization failures:
diff --git a/build/Android.bp b/build/Android.bp
deleted file mode 100644
index 0bb7ea1..0000000
--- a/build/Android.bp
+++ /dev/null
@@ -1,157 +0,0 @@
-bootstrap_go_package {
-    name: "soong-art",
-    pkgPath: "android/soong/art",
-    deps: [
-        "blueprint",
-        "blueprint-pathtools",
-        "soong",
-        "soong-android",
-        "soong-cc",
-    ],
-    srcs: [
-        "art.go",
-        "codegen.go",
-        "makevars.go",
-    ],
-    pluginFor: ["soong_build"],
-}
-
-art_global_defaults {
-    // Additional flags are computed by art.go
-
-    name: "art_defaults",
-    clang: true,
-    cflags: [
-        "-O3",
-
-        // Base set of cflags used by all things ART.
-        "-fno-rtti",
-        "-ggdb3",
-        "-Wall",
-        "-Werror",
-        "-Wextra",
-        "-Wstrict-aliasing",
-        "-fstrict-aliasing",
-        "-Wunreachable-code",
-        "-Wredundant-decls",
-        "-Wshadow",
-        "-Wunused",
-        "-fvisibility=protected",
-
-        // Warn about thread safety violations with clang.
-        "-Wthread-safety",
-        "-Wthread-safety-negative",
-
-        // Warn if switch fallthroughs aren't annotated.
-        "-Wimplicit-fallthrough",
-
-        // Enable float equality warnings.
-        "-Wfloat-equal",
-
-        // Enable warning of converting ints to void*.
-        "-Wint-to-void-pointer-cast",
-
-        // Enable warning of wrong unused annotations.
-        "-Wused-but-marked-unused",
-
-        // Enable warning for deprecated language features.
-        "-Wdeprecated",
-
-        // Enable warning for unreachable break & return.
-        "-Wunreachable-code-break",
-        "-Wunreachable-code-return",
-
-        // Bug: http://b/29823425  Disable -Wconstant-conversion and
-        // -Wundefined-var-template for Clang update to r271374
-        "-Wno-constant-conversion",
-        "-Wno-undefined-var-template",
-
-        "-DART_STACK_OVERFLOW_GAP_arm=8192",
-        "-DART_STACK_OVERFLOW_GAP_arm64=8192",
-        "-DART_STACK_OVERFLOW_GAP_mips=16384",
-        "-DART_STACK_OVERFLOW_GAP_mips64=16384",
-        "-DART_STACK_OVERFLOW_GAP_x86=8192",
-        "-DART_STACK_OVERFLOW_GAP_x86_64=8192",
-    ],
-
-    target: {
-        android: {
-            cflags: [
-                "-DART_TARGET",
-
-                // Enable missing-noreturn only on non-Mac. As lots of things are not implemented
-                // for Apple, it's a pain.
-                "-Wmissing-noreturn",
-
-                // To use oprofile_android --callgraph, uncomment this and recompile with
-                //    mmma -j art
-                // "-fno-omit-frame-pointer",
-                // "-marm",
-                // "-mapcs",
-            ],
-            include_dirs: [
-                // We optimize Thread::Current() with a direct TLS access. This requires access to a
-                //  private Bionic header.
-                "bionic/libc/private",
-            ],
-        },
-        linux: {
-            cflags: [
-                // Enable missing-noreturn only on non-Mac. As lots of things are not implemented for
-                // Apple, it's a pain.
-                "-Wmissing-noreturn",
-            ],
-        },
-        host: {
-            cflags: [
-                // Bug: 15446488. We don't omit the frame pointer to work around
-                // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
-                "-fno-omit-frame-pointer",
-            ],
-        },
-    },
-
-    codegen: {
-        arm: {
-            cflags: ["-DART_ENABLE_CODEGEN_arm"],
-        },
-        arm64: {
-            cflags: ["-DART_ENABLE_CODEGEN_arm64"],
-        },
-        mips: {
-            cflags: ["-DART_ENABLE_CODEGEN_mips"],
-        },
-        mips64: {
-            cflags: ["-DART_ENABLE_CODEGEN_mips64"],
-        },
-        x86: {
-            cflags: ["-DART_ENABLE_CODEGEN_x86"],
-        },
-        x86_64: {
-            cflags: ["-DART_ENABLE_CODEGEN_x86_64"],
-        },
-    },
-
-    include_dirs: [
-        "external/gtest/include",
-        "external/icu/icu4c/source/common",
-        "external/lz4/lib",
-        "external/valgrind/include",
-        "external/valgrind",
-        "external/vixl/src",
-        "external/zlib",
-    ],
-}
-
-cc_defaults {
-    name: "art_debug_defaults",
-    cflags: [
-        "-O2",
-        "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DVIXL_DEBUG",
-        "-UNDEBUG",
-    ],
-    asflags: [
-        "-UNDEBUG",
-    ],
-}
diff --git a/build/art.go b/build/art.go
deleted file mode 100644
index c53a4d6..0000000
--- a/build/art.go
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (C) 2016 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.
-
-package art
-
-import (
-	"android/soong"
-	"android/soong/android"
-	"android/soong/cc"
-	"fmt"
-
-	"github.com/google/blueprint"
-)
-
-var supportedArches = []string{"arm", "arm64", "mips", "mips64", "x86", "x86_64"}
-
-func globalFlags(ctx android.BaseContext) ([]string, []string) {
-	var cflags []string
-	var asflags []string
-
-	tlab := false
-
-	gcType := envDefault(ctx, "ART_DEFAULT_GC_TYPE", "CMS")
-
-	if envTrue(ctx, "ART_TEST_DEBUG_GC") {
-		gcType = "SS"
-		tlab = true
-	}
-
-	cflags = append(cflags, "-DART_DEFAULT_GC_TYPE_IS_"+gcType)
-	if tlab {
-		cflags = append(cflags, "-DART_USE_TLAB=1")
-	}
-
-	imtSize := envDefault(ctx, "ART_IMT_SIZE", "43")
-	cflags = append(cflags, "-DIMT_SIZE="+imtSize)
-
-	if envTrue(ctx, "ART_HEAP_POISIONING") {
-		cflags = append(cflags, "-DART_HEAP_POISONING=1")
-		asflags = append(asflags, "-DART_HEAP_POISONING=1")
-	}
-
-	if envTrue(ctx, "ART_USE_READ_BARRIER") {
-		// Used to change the read barrier type. Valid values are BAKER, BROOKS, TABLELOOKUP.
-		// The default is BAKER.
-		barrierType := envDefault(ctx, "ART_READ_BARRIER_TYPE", "BAKER")
-		cflags = append(cflags,
-			"-DART_USE_READ_BARRIER=1",
-			"-DART_READ_BARRIER_TYPE_IS_"+barrierType+"=1")
-		asflags = append(asflags,
-			"-DART_USE_READ_BARRIER=1",
-			"-DART_READ_BARRIER_TYPE_IS_"+barrierType+"=1")
-
-		// Temporarily override -fstack-protector-strong with -fstack-protector to avoid a major
-		// slowdown with the read barrier config. b/26744236.
-		cflags = append(cflags, "-fstack-protector")
-	}
-
-	return cflags, asflags
-}
-
-func deviceFlags(ctx android.BaseContext) []string {
-	var cflags []string
-	deviceFrameSizeLimit := 1736
-	if len(ctx.AConfig().SanitizeDevice()) > 0 {
-		deviceFrameSizeLimit = 6400
-	}
-	cflags = append(cflags,
-		fmt.Sprintf("-Wframe-larger-than=%d", deviceFrameSizeLimit),
-		fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", deviceFrameSizeLimit),
-	)
-
-	cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.AConfig().LibartImgDeviceBaseAddress())
-	if envTrue(ctx, "ART_TARGET_LINUX") {
-		cflags = append(cflags, "-DART_TARGET_LINUX")
-	} else {
-		cflags = append(cflags, "-DART_TARGET_ANDROID")
-	}
-	minDelta := envDefault(ctx, "LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA", "-0x1000000")
-	maxDelta := envDefault(ctx, "LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA", "0x1000000")
-	cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta)
-	cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta)
-
-	return cflags
-}
-
-func hostFlags(ctx android.BaseContext) []string {
-	var cflags []string
-	hostFrameSizeLimit := 1736
-	cflags = append(cflags,
-		fmt.Sprintf("-Wframe-larger-than=%d", hostFrameSizeLimit),
-		fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", hostFrameSizeLimit),
-	)
-
-	cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.AConfig().LibartImgHostBaseAddress())
-	minDelta := envDefault(ctx, "LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA", "-0x1000000")
-	maxDelta := envDefault(ctx, "LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA", "0x1000000")
-	cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta)
-	cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta)
-
-	return cflags
-}
-
-func (a *artGlobalDefaults) CustomizeProperties(ctx android.CustomizePropertiesContext) {
-	type props struct {
-		Target struct {
-			Android struct {
-				Cflags []string
-			}
-			Host struct {
-				Cflags []string
-			}
-		}
-		Cflags  []string
-		Asflags []string
-	}
-
-	p := &props{}
-	p.Cflags, p.Asflags = globalFlags(ctx)
-	p.Target.Android.Cflags = deviceFlags(ctx)
-	p.Target.Host.Cflags = hostFlags(ctx)
-	ctx.AppendProperties(p)
-}
-
-type artGlobalDefaults struct{}
-
-func init() {
-	soong.RegisterModuleType("art_cc_library", artLibrary)
-	soong.RegisterModuleType("art_cc_defaults", artDefaultsFactory)
-	soong.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory)
-}
-
-func artGlobalDefaultsFactory() (blueprint.Module, []interface{}) {
-	c := &artGlobalDefaults{}
-	module, props := artDefaultsFactory()
-	android.AddCustomizer(module.(android.Module), c)
-
-	return module, props
-}
-
-func artDefaultsFactory() (blueprint.Module, []interface{}) {
-	c := &codegenCustomizer{}
-	module, props := cc.DefaultsFactory(&c.codegenProperties)
-	android.AddCustomizer(module.(android.Module), c)
-
-	return module, props
-}
-
-func artLibrary() (blueprint.Module, []interface{}) {
-	library, _ := cc.NewLibrary(android.HostAndDeviceSupported, true, true)
-	module, props := library.Init()
-
-	c := &codegenCustomizer{}
-	android.AddCustomizer(library, c)
-	props = append(props, &c.codegenProperties)
-	return module, props
-}
-
-func envDefault(ctx android.BaseContext, key string, defaultValue string) string {
-	ret := ctx.AConfig().Getenv(key)
-	if ret == "" {
-		return defaultValue
-	}
-	return ret
-}
-
-func envTrue(ctx android.BaseContext, key string) bool {
-	return ctx.AConfig().Getenv(key) == "true"
-}
diff --git a/build/codegen.go b/build/codegen.go
deleted file mode 100644
index eb2c37d..0000000
--- a/build/codegen.go
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2016 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.
-
-package art
-
-// This file implements the "codegen" property to apply different properties based on the currently
-// selected codegen arches, which defaults to all arches on the host and the primary and secondary
-// arches on the device.
-
-import (
-	"android/soong/android"
-	"sort"
-	"strings"
-)
-
-func (a *codegenCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) {
-	c := &a.codegenProperties.Codegen
-
-	var hostArches, deviceArches []string
-
-	e := envDefault(ctx, "ART_HOST_CODEGEN_ARCHS", "")
-	if e == "" {
-		hostArches = supportedArches
-	} else {
-		hostArches = strings.Split(e, " ")
-	}
-
-	e = envDefault(ctx, "ART_TARGET_CODEGEN_ARCHS", "")
-	if e == "" {
-		deviceArches = defaultDeviceCodegenArches(ctx)
-	} else {
-		deviceArches = strings.Split(e, " ")
-	}
-
-	type props struct {
-		Target struct {
-			Android *codegenArchProperties
-			Host    *codegenArchProperties
-		}
-	}
-
-	addCodegenArchProperties := func(p *props, hod **codegenArchProperties, arch string) {
-		switch arch {
-		case "arm":
-			*hod = &c.Arm
-		case "arm64":
-			*hod = &c.Arm64
-		case "mips":
-			*hod = &c.Mips
-		case "mips64":
-			*hod = &c.Mips64
-		case "x86":
-			*hod = &c.X86
-		case "x86_64":
-			*hod = &c.X86_64
-		default:
-			ctx.ModuleErrorf("Unknown codegen architecture %q", arch)
-			return
-		}
-		ctx.AppendProperties(p)
-	}
-
-	for _, a := range deviceArches {
-		p := &props{}
-		addCodegenArchProperties(p, &p.Target.Android, a)
-		if ctx.Failed() {
-			return
-		}
-	}
-
-	for _, a := range hostArches {
-		p := &props{}
-		addCodegenArchProperties(p, &p.Target.Host, a)
-		if ctx.Failed() {
-			return
-		}
-	}
-}
-
-type codegenArchProperties struct {
-	Srcs   []string
-	Cflags []string
-	Static struct {
-		Whole_static_libs []string
-	}
-	Shared struct {
-		Shared_libs []string
-	}
-}
-
-type codegenProperties struct {
-	Codegen struct {
-		Arm, Arm64, Mips, Mips64, X86, X86_64 codegenArchProperties
-	}
-}
-
-type codegenCustomizer struct {
-	codegenProperties codegenProperties
-}
-
-func defaultDeviceCodegenArches(ctx android.CustomizePropertiesContext) []string {
-	arches := make(map[string]bool)
-	for _, a := range ctx.DeviceConfig().Arches() {
-		arches[a.ArchType.String()] = true
-	}
-	ret := make([]string, 0, len(arches))
-	for a := range arches {
-		ret = append(ret, a)
-	}
-	sort.Strings(ret)
-	return ret
-}
diff --git a/build/makevars.go b/build/makevars.go
deleted file mode 100644
index 5655c55..0000000
--- a/build/makevars.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2016 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.
-
-package art
-
-import "android/soong/android"
-
-var (
-	pctx = android.NewPackageContext("android/soong/art")
-)
-
-func init() {
-	android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
-}
-
-func makeVarsProvider(ctx android.MakeVarsContext) {
-	ctx.Strict("LIBART_IMG_HOST_BASE_ADDRESS", ctx.Config().LibartImgHostBaseAddress())
-	ctx.Strict("LIBART_IMG_TARGET_BASE_ADDRESS", ctx.Config().LibartImgDeviceBaseAddress())
-}
diff --git a/compiler/Android.bp b/compiler/Android.bp
deleted file mode 100644
index 1b6291d..0000000
--- a/compiler/Android.bp
+++ /dev/null
@@ -1,245 +0,0 @@
-//
-// Copyright (C) 2012 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.
-//
-
-// TODO We should really separate out those files that are actually needed for both variants of an
-// architecture into its own category. Currently we just include all of the 32bit variant in the
-// 64bit variant. It also might be good to allow one to compile only the 64bit variant without the
-// 32bit one.
-
-art_cc_defaults {
-    name: "libart-compiler-defaults",
-    defaults: ["art_defaults"],
-    host_supported: true,
-    clang: true,
-    srcs: [
-        "compiled_method.cc",
-        "debug/elf_debug_writer.cc",
-        "dex/dex_to_dex_compiler.cc",
-        "dex/verified_method.cc",
-        "dex/verification_results.cc",
-        "dex/quick_compiler_callbacks.cc",
-        "dex/quick/dex_file_method_inliner.cc",
-        "dex/quick/dex_file_to_method_inliner_map.cc",
-        "driver/compiled_method_storage.cc",
-        "driver/compiler_driver.cc",
-        "driver/compiler_options.cc",
-        "driver/dex_compilation_unit.cc",
-        "linker/buffered_output_stream.cc",
-        "linker/file_output_stream.cc",
-        "linker/multi_oat_relative_patcher.cc",
-        "linker/output_stream.cc",
-        "linker/vector_output_stream.cc",
-        "linker/relative_patcher.cc",
-        "jit/jit_compiler.cc",
-        "jni/quick/calling_convention.cc",
-        "jni/quick/jni_compiler.cc",
-        "optimizing/block_builder.cc",
-        "optimizing/bounds_check_elimination.cc",
-        "optimizing/builder.cc",
-        "optimizing/code_generator.cc",
-        "optimizing/code_generator_utils.cc",
-        "optimizing/constant_folding.cc",
-        "optimizing/dead_code_elimination.cc",
-        "optimizing/graph_checker.cc",
-        "optimizing/graph_visualizer.cc",
-        "optimizing/gvn.cc",
-        "optimizing/induction_var_analysis.cc",
-        "optimizing/induction_var_range.cc",
-        "optimizing/inliner.cc",
-        "optimizing/instruction_builder.cc",
-        "optimizing/instruction_simplifier.cc",
-        "optimizing/intrinsics.cc",
-        "optimizing/licm.cc",
-        "optimizing/load_store_elimination.cc",
-        "optimizing/locations.cc",
-        "optimizing/nodes.cc",
-        "optimizing/optimization.cc",
-        "optimizing/optimizing_compiler.cc",
-        "optimizing/parallel_move_resolver.cc",
-        "optimizing/prepare_for_register_allocation.cc",
-        "optimizing/reference_type_propagation.cc",
-        "optimizing/register_allocation_resolver.cc",
-        "optimizing/register_allocator.cc",
-        "optimizing/register_allocator_graph_color.cc",
-        "optimizing/register_allocator_linear_scan.cc",
-        "optimizing/select_generator.cc",
-        "optimizing/sharpening.cc",
-        "optimizing/side_effects_analysis.cc",
-        "optimizing/ssa_builder.cc",
-        "optimizing/ssa_liveness_analysis.cc",
-        "optimizing/ssa_phi_elimination.cc",
-        "optimizing/stack_map_stream.cc",
-        "trampolines/trampoline_compiler.cc",
-        "utils/assembler.cc",
-        "utils/jni_macro_assembler.cc",
-        "utils/swap_space.cc",
-        "compiler.cc",
-        "elf_writer.cc",
-        "elf_writer_quick.cc",
-        "image_writer.cc",
-        "oat_writer.cc",
-    ],
-
-    codegen: {
-        arm: {
-            srcs: [
-                "jni/quick/arm/calling_convention_arm.cc",
-                "linker/arm/relative_patcher_arm_base.cc",
-                "linker/arm/relative_patcher_thumb2.cc",
-                "optimizing/code_generator_arm.cc",
-                "optimizing/dex_cache_array_fixups_arm.cc",
-                "optimizing/instruction_simplifier_arm.cc",
-                "optimizing/instruction_simplifier_shared.cc",
-                "optimizing/intrinsics_arm.cc",
-                "utils/arm/assembler_arm.cc",
-                "utils/arm/assembler_arm32.cc",
-                "utils/arm/assembler_thumb2.cc",
-                "utils/arm/jni_macro_assembler_arm.cc",
-                "utils/arm/managed_register_arm.cc",
-            ],
-        },
-        arm64: {
-            srcs: [
-                "jni/quick/arm64/calling_convention_arm64.cc",
-                "linker/arm64/relative_patcher_arm64.cc",
-                "optimizing/code_generator_arm64.cc",
-                "optimizing/instruction_simplifier_arm64.cc",
-                "optimizing/intrinsics_arm64.cc",
-                "optimizing/nodes_arm64.cc",
-                "utils/arm64/assembler_arm64.cc",
-                "utils/arm64/jni_macro_assembler_arm64.cc",
-                "utils/arm64/managed_register_arm64.cc",
-            ],
-        },
-        mips: {
-            srcs: [
-                "jni/quick/mips/calling_convention_mips.cc",
-                "linker/mips/relative_patcher_mips.cc",
-                "optimizing/code_generator_mips.cc",
-                "optimizing/dex_cache_array_fixups_mips.cc",
-                "optimizing/intrinsics_mips.cc",
-                "optimizing/pc_relative_fixups_mips.cc",
-                "utils/mips/assembler_mips.cc",
-                "utils/mips/managed_register_mips.cc",
-            ],
-        },
-        mips64: {
-            srcs: [
-                "jni/quick/mips64/calling_convention_mips64.cc",
-                "optimizing/code_generator_mips64.cc",
-                "optimizing/intrinsics_mips64.cc",
-                "utils/mips64/assembler_mips64.cc",
-                "utils/mips64/managed_register_mips64.cc",
-            ],
-        },
-        x86: {
-            srcs: [
-                "jni/quick/x86/calling_convention_x86.cc",
-                "linker/x86/relative_patcher_x86.cc",
-                "linker/x86/relative_patcher_x86_base.cc",
-                "optimizing/code_generator_x86.cc",
-                "optimizing/intrinsics_x86.cc",
-                "optimizing/pc_relative_fixups_x86.cc",
-                "optimizing/x86_memory_gen.cc",
-                "utils/x86/assembler_x86.cc",
-                "utils/x86/jni_macro_assembler_x86.cc",
-                "utils/x86/managed_register_x86.cc",
-            ],
-        },
-        x86_64: {
-            srcs: [
-                "jni/quick/x86_64/calling_convention_x86_64.cc",
-                "linker/x86_64/relative_patcher_x86_64.cc",
-                "optimizing/intrinsics_x86_64.cc",
-                "optimizing/code_generator_x86_64.cc",
-                "utils/x86_64/assembler_x86_64.cc",
-                "utils/x86_64/jni_macro_assembler_x86_64.cc",
-                "utils/x86_64/managed_register_x86_64.cc",
-            ],
-        },
-    },
-    target: {
-        host: {
-            // For compiler driver TLS.
-            host_ldlibs: ["-lpthread"],
-        },
-        android: {
-            // For atrace.
-            shared_libs: ["libcutils"],
-        },
-    },
-    generated_sources: ["art_compiler_operator_srcs"],
-    shared_libs: [
-        "liblz4",
-        "liblzma",
-    ],
-    include_dirs: ["art/disassembler"],
-}
-
-gensrcs {
-    name: "art_compiler_operator_srcs",
-    cmd: "art/tools/generate-operator-out.py art/compiler $in > $out",
-    srcs: [
-        "compiled_method.h",
-        "dex/dex_to_dex_compiler.h",
-        "driver/compiler_driver.h",
-        "driver/compiler_options.h",
-        "image_writer.h",
-        "optimizing/locations.h",
-
-        "utils/arm/constants_arm.h",
-        "utils/mips/assembler_mips.h",
-        "utils/mips64/assembler_mips64.h",
-    ],
-    output_extension: "operator_out.cc",
-}
-
-art_cc_library {
-    name: "libart-compiler",
-    defaults: ["libart-compiler-defaults"],
-    codegen: {
-        arm64: {
-            // VIXL assembly support for ARM64 targets.
-            static: {
-                whole_static_libs: ["libvixl-arm64"],
-            },
-            shared: {
-                shared_libs: ["libvixl-arm64"],
-            },
-        },
-    },
-    shared_libs: ["libart"],
-}
-
-art_cc_library {
-    name: "libartd-compiler",
-    defaults: [
-        "libart-compiler-defaults",
-        "art_debug_defaults",
-    ],
-    codegen: {
-        arm64: {
-            // VIXL assembly support for ARM64 targets.
-            static: {
-                whole_static_libs: ["libvixld-arm64"],
-            },
-            shared: {
-                shared_libs: ["libvixld-arm64"],
-            },
-        },
-    },
-    shared_libs: ["libartd"],
-}
diff --git a/compiler/Android.mk b/compiler/Android.mk
new file mode 100644
index 0000000..16c6a7b
--- /dev/null
+++ b/compiler/Android.mk
@@ -0,0 +1,343 @@
+#
+# Copyright (C) 2012 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)
+
+include art/build/Android.common_build.mk
+
+LIBART_COMPILER_SRC_FILES := \
+	compiled_method.cc \
+	debug/elf_debug_writer.cc \
+	dex/dex_to_dex_compiler.cc \
+	dex/verified_method.cc \
+	dex/verification_results.cc \
+	dex/quick_compiler_callbacks.cc \
+	dex/quick/dex_file_method_inliner.cc \
+	dex/quick/dex_file_to_method_inliner_map.cc \
+	driver/compiled_method_storage.cc \
+	driver/compiler_driver.cc \
+	driver/compiler_options.cc \
+	driver/dex_compilation_unit.cc \
+	linker/buffered_output_stream.cc \
+	linker/file_output_stream.cc \
+	linker/multi_oat_relative_patcher.cc \
+	linker/output_stream.cc \
+	linker/vector_output_stream.cc \
+	linker/relative_patcher.cc \
+	jit/jit_compiler.cc \
+	jni/quick/calling_convention.cc \
+	jni/quick/jni_compiler.cc \
+	optimizing/block_builder.cc \
+	optimizing/bounds_check_elimination.cc \
+	optimizing/builder.cc \
+	optimizing/code_generator.cc \
+	optimizing/code_generator_utils.cc \
+	optimizing/constant_folding.cc \
+	optimizing/dead_code_elimination.cc \
+	optimizing/graph_checker.cc \
+	optimizing/graph_visualizer.cc \
+	optimizing/gvn.cc \
+	optimizing/induction_var_analysis.cc \
+	optimizing/induction_var_range.cc \
+	optimizing/inliner.cc \
+	optimizing/instruction_builder.cc \
+	optimizing/instruction_simplifier.cc \
+	optimizing/intrinsics.cc \
+	optimizing/licm.cc \
+	optimizing/load_store_elimination.cc \
+	optimizing/locations.cc \
+	optimizing/nodes.cc \
+	optimizing/optimization.cc \
+	optimizing/optimizing_compiler.cc \
+	optimizing/parallel_move_resolver.cc \
+	optimizing/prepare_for_register_allocation.cc \
+	optimizing/reference_type_propagation.cc \
+	optimizing/register_allocation_resolver.cc \
+	optimizing/register_allocator.cc \
+	optimizing/register_allocator_graph_color.cc \
+	optimizing/register_allocator_linear_scan.cc \
+	optimizing/select_generator.cc \
+	optimizing/sharpening.cc \
+	optimizing/side_effects_analysis.cc \
+	optimizing/ssa_builder.cc \
+	optimizing/ssa_liveness_analysis.cc \
+	optimizing/ssa_phi_elimination.cc \
+	optimizing/stack_map_stream.cc \
+	trampolines/trampoline_compiler.cc \
+	utils/assembler.cc \
+	utils/jni_macro_assembler.cc \
+	utils/swap_space.cc \
+	compiler.cc \
+	elf_writer.cc \
+	elf_writer_quick.cc \
+	image_writer.cc \
+	oat_writer.cc
+
+LIBART_COMPILER_SRC_FILES_arm := \
+	jni/quick/arm/calling_convention_arm.cc \
+	linker/arm/relative_patcher_arm_base.cc \
+	linker/arm/relative_patcher_thumb2.cc \
+	optimizing/code_generator_arm.cc \
+	optimizing/dex_cache_array_fixups_arm.cc \
+	optimizing/instruction_simplifier_arm.cc \
+	optimizing/instruction_simplifier_shared.cc \
+	optimizing/intrinsics_arm.cc \
+	utils/arm/assembler_arm.cc \
+	utils/arm/assembler_arm32.cc \
+	utils/arm/assembler_thumb2.cc \
+	utils/arm/jni_macro_assembler_arm.cc \
+	utils/arm/managed_register_arm.cc \
+
+# TODO We should really separate out those files that are actually needed for both variants of an
+# architecture into its own category. Currently we just include all of the 32bit variant in the
+# 64bit variant. It also might be good to allow one to compile only the 64bit variant without the
+# 32bit one.
+LIBART_COMPILER_SRC_FILES_arm64 := \
+    $(LIBART_COMPILER_SRC_FILES_arm) \
+	jni/quick/arm64/calling_convention_arm64.cc \
+	linker/arm64/relative_patcher_arm64.cc \
+	optimizing/nodes_arm64.cc \
+	optimizing/code_generator_arm64.cc \
+	optimizing/instruction_simplifier_arm64.cc \
+	optimizing/instruction_simplifier_shared.cc \
+	optimizing/intrinsics_arm64.cc \
+	utils/arm64/assembler_arm64.cc \
+	utils/arm64/jni_macro_assembler_arm64.cc \
+	utils/arm64/managed_register_arm64.cc \
+
+LIBART_COMPILER_SRC_FILES_mips := \
+	jni/quick/mips/calling_convention_mips.cc \
+	linker/mips/relative_patcher_mips.cc \
+	optimizing/code_generator_mips.cc \
+	optimizing/dex_cache_array_fixups_mips.cc \
+	optimizing/intrinsics_mips.cc \
+	optimizing/pc_relative_fixups_mips.cc \
+	utils/mips/assembler_mips.cc \
+	utils/mips/managed_register_mips.cc \
+
+LIBART_COMPILER_SRC_FILES_mips64 := \
+    $(LIBART_COMPILER_SRC_FILES_mips) \
+	jni/quick/mips64/calling_convention_mips64.cc \
+	optimizing/code_generator_mips64.cc \
+	optimizing/intrinsics_mips64.cc \
+	utils/mips64/assembler_mips64.cc \
+	utils/mips64/managed_register_mips64.cc \
+
+
+LIBART_COMPILER_SRC_FILES_x86 := \
+	jni/quick/x86/calling_convention_x86.cc \
+	linker/x86/relative_patcher_x86.cc \
+	linker/x86/relative_patcher_x86_base.cc \
+	optimizing/code_generator_x86.cc \
+	optimizing/intrinsics_x86.cc \
+	optimizing/pc_relative_fixups_x86.cc \
+	optimizing/x86_memory_gen.cc \
+	utils/x86/assembler_x86.cc \
+	utils/x86/jni_macro_assembler_x86.cc \
+	utils/x86/managed_register_x86.cc \
+
+LIBART_COMPILER_SRC_FILES_x86_64 := \
+    $(LIBART_COMPILER_SRC_FILES_x86) \
+	jni/quick/x86_64/calling_convention_x86_64.cc \
+	linker/x86_64/relative_patcher_x86_64.cc \
+	optimizing/intrinsics_x86_64.cc \
+	optimizing/code_generator_x86_64.cc \
+	utils/x86_64/assembler_x86_64.cc \
+	utils/x86_64/jni_macro_assembler_x86_64.cc \
+	utils/x86_64/managed_register_x86_64.cc \
+
+
+LIBART_COMPILER_CFLAGS :=
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES := \
+  compiled_method.h \
+  dex/dex_to_dex_compiler.h \
+  driver/compiler_driver.h \
+  driver/compiler_options.h \
+  image_writer.h \
+  optimizing/locations.h
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm := \
+  utils/arm/constants_arm.h
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm64 := \
+  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm)
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips := \
+  utils/mips/assembler_mips.h
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips64 := \
+  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips) \
+  utils/mips64/assembler_mips64.h
+
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86 :=
+LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86_64 := \
+  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86)
+
+# $(1): target or host
+# $(2): ndebug or debug
+# $(3): static or shared (empty means shared, applies only for host)
+define build-libart-compiler
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+  ifneq ($(2),ndebug)
+    ifneq ($(2),debug)
+      $$(error expected ndebug or debug for argument 2, received $(2))
+    endif
+  endif
+
+  art_target_or_host := $(1)
+  art_ndebug_or_debug := $(2)
+  art_static_or_shared := $(3)
+
+  include $(CLEAR_VARS)
+  ifeq ($$(art_target_or_host),host)
+    LOCAL_IS_HOST_MODULE := true
+    art_codegen_targets := $(ART_HOST_CODEGEN_ARCHS)
+  else
+    art_codegen_targets := $(ART_TARGET_CODEGEN_ARCHS)
+  endif
+  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+  ifeq ($$(art_ndebug_or_debug),ndebug)
+    LOCAL_MODULE := libart-compiler
+    ifeq ($$(art_static_or_shared), static)
+      LOCAL_STATIC_LIBRARIES += libart liblz4 liblzma
+    else
+      LOCAL_SHARED_LIBRARIES += libart liblz4 liblzma
+    endif
+    ifeq ($$(art_target_or_host),target)
+      LOCAL_FDO_SUPPORT := true
+    endif
+  else # debug
+    LOCAL_MODULE := libartd-compiler
+    ifeq ($$(art_static_or_shared), static)
+      LOCAL_STATIC_LIBRARIES += libartd liblz4 liblzma
+    else
+      LOCAL_SHARED_LIBRARIES += libartd liblz4 liblzma
+    endif
+  endif
+
+  LOCAL_MODULE_TAGS := optional
+  ifeq ($$(art_static_or_shared), static)
+    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+  else
+    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+  endif
+
+  # Sort removes duplicates.
+  LOCAL_SRC_FILES := $$(LIBART_COMPILER_SRC_FILES) \
+    $$(sort $$(foreach arch,$$(art_codegen_targets), $$(LIBART_COMPILER_SRC_FILES_$$(arch))))
+
+  GENERATED_SRC_DIR := $$(call local-generated-sources-dir)
+  ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,\
+                                $$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES) \
+                                $$(sort $$(foreach arch,$$(art_codegen_targets), $$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_$$(arch)))))
+  ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES))
+
+$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py
+$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@
+$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h
+	$$(transform-generated-source)
+
+  LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN)
+
+  LOCAL_CFLAGS := $$(LIBART_COMPILER_CFLAGS)
+  ifeq ($$(art_target_or_host),target)
+    LOCAL_CLANG := $(ART_TARGET_CLANG)
+    $(call set-target-local-cflags-vars,$(2))
+  else # host
+    LOCAL_CLANG := $(ART_HOST_CLANG)
+    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+    LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
+    ifeq ($$(art_static_or_shared),static)
+      LOCAL_LDFLAGS += -static
+    endif
+    ifeq ($$(art_ndebug_or_debug),debug)
+      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $(ART_HOST_DEBUG_ASFLAGS)
+    else
+      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $(ART_HOST_NON_DEBUG_ASFLAGS)
+    endif
+  endif
+
+  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/disassembler
+
+  ifeq ($$(art_target_or_host),host)
+    # For compiler driver TLS.
+    LOCAL_LDLIBS += -lpthread
+  endif
+  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+  # VIXL assembly support for ARM64 targets.
+  ifeq ($$(art_ndebug_or_debug),debug)
+    ifeq ($$(art_static_or_shared), static)
+      LOCAL_WHOLESTATIC_LIBRARIES += libvixld-arm64
+    else
+      LOCAL_SHARED_LIBRARIES += libvixld-arm64
+    endif
+  else
+    ifeq ($$(art_static_or_shared), static)
+      LOCAL_WHOLE_STATIC_LIBRARIES += libvixl-arm64
+    else
+      LOCAL_SHARED_LIBRARIES += libvixl-arm64
+    endif
+  endif
+
+  LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
+
+  ifeq ($$(art_target_or_host),target)
+    # For atrace.
+    LOCAL_SHARED_LIBRARIES += libcutils
+    include $(BUILD_SHARED_LIBRARY)
+  else # host
+    LOCAL_MULTILIB := both
+    ifeq ($$(art_static_or_shared), static)
+      include $(BUILD_HOST_STATIC_LIBRARY)
+    else
+      include $(BUILD_HOST_SHARED_LIBRARY)
+    endif
+  endif
+
+  # Clear locally defined variables.
+  art_target_or_host :=
+  art_ndebug_or_debug :=
+  art_static_or_shared :=
+  art_codegen_targets :=
+endef
+
+# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
+ifeq ($(ART_BUILD_HOST_NDEBUG),true)
+  $(eval $(call build-libart-compiler,host,ndebug))
+  ifeq ($(ART_BUILD_HOST_STATIC),true)
+    $(eval $(call build-libart-compiler,host,ndebug,static))
+  endif
+endif
+ifeq ($(ART_BUILD_HOST_DEBUG),true)
+  $(eval $(call build-libart-compiler,host,debug))
+  ifeq ($(ART_BUILD_HOST_STATIC),true)
+    $(eval $(call build-libart-compiler,host,debug,static))
+  endif
+endif
+ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
+  $(eval $(call build-libart-compiler,target,ndebug))
+endif
+ifeq ($(ART_BUILD_TARGET_DEBUG),true)
+  $(eval $(call build-libart-compiler,target,debug))
+endif
diff --git a/runtime/Android.bp b/runtime/Android.bp
deleted file mode 100644
index 938a1d6..0000000
--- a/runtime/Android.bp
+++ /dev/null
@@ -1,452 +0,0 @@
-//
-// Copyright (C) 2011 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.
-//
-
-// Keep the __jit_debug_register_code symbol as a unique symbol during ICF for architectures where
-// we use gold as the linker (arm, x86, x86_64). The symbol is used by the debuggers to detect when
-// new jit code is generated. We don't want it to be called when a different function with the same
-// (empty) body is called.
-JIT_DEBUG_REGISTER_CODE_LDFLAGS = ["-Wl,--keep-unique,__jit_debug_register_code"]
-
-cc_defaults {
-    name: "libart_defaults",
-    defaults: ["art_defaults"],
-    host_supported: true,
-    srcs: [
-        "art_field.cc",
-        "art_method.cc",
-        "atomic.cc",
-        "barrier.cc",
-        "base/allocator.cc",
-        "base/arena_allocator.cc",
-        "base/arena_bit_vector.cc",
-        "base/bit_vector.cc",
-        "base/file_magic.cc",
-        "base/hex_dump.cc",
-        "base/logging.cc",
-        "base/mutex.cc",
-        "base/scoped_arena_allocator.cc",
-        "base/scoped_flock.cc",
-        "base/stringpiece.cc",
-        "base/stringprintf.cc",
-        "base/time_utils.cc",
-        "base/timing_logger.cc",
-        "base/unix_file/fd_file.cc",
-        "base/unix_file/random_access_file_utils.cc",
-        "check_jni.cc",
-        "class_linker.cc",
-        "class_table.cc",
-        "code_simulator_container.cc",
-        "common_throws.cc",
-        "compiler_filter.cc",
-        "debugger.cc",
-        "dex_file.cc",
-        "dex_file_verifier.cc",
-        "dex_instruction.cc",
-        "elf_file.cc",
-        "fault_handler.cc",
-        "gc/allocation_record.cc",
-        "gc/allocator/dlmalloc.cc",
-        "gc/allocator/rosalloc.cc",
-        "gc/accounting/bitmap.cc",
-        "gc/accounting/card_table.cc",
-        "gc/accounting/heap_bitmap.cc",
-        "gc/accounting/mod_union_table.cc",
-        "gc/accounting/remembered_set.cc",
-        "gc/accounting/space_bitmap.cc",
-        "gc/collector/concurrent_copying.cc",
-        "gc/collector/garbage_collector.cc",
-        "gc/collector/immune_region.cc",
-        "gc/collector/immune_spaces.cc",
-        "gc/collector/mark_compact.cc",
-        "gc/collector/mark_sweep.cc",
-        "gc/collector/partial_mark_sweep.cc",
-        "gc/collector/semi_space.cc",
-        "gc/collector/sticky_mark_sweep.cc",
-        "gc/gc_cause.cc",
-        "gc/heap.cc",
-        "gc/reference_processor.cc",
-        "gc/reference_queue.cc",
-        "gc/scoped_gc_critical_section.cc",
-        "gc/space/bump_pointer_space.cc",
-        "gc/space/dlmalloc_space.cc",
-        "gc/space/image_space.cc",
-        "gc/space/large_object_space.cc",
-        "gc/space/malloc_space.cc",
-        "gc/space/region_space.cc",
-        "gc/space/rosalloc_space.cc",
-        "gc/space/space.cc",
-        "gc/space/zygote_space.cc",
-        "gc/task_processor.cc",
-        "hprof/hprof.cc",
-        "image.cc",
-        "indirect_reference_table.cc",
-        "instrumentation.cc",
-        "intern_table.cc",
-        "interpreter/interpreter.cc",
-        "interpreter/interpreter_common.cc",
-        "interpreter/interpreter_goto_table_impl.cc",
-        "interpreter/interpreter_switch_impl.cc",
-        "interpreter/unstarted_runtime.cc",
-        "java_vm_ext.cc",
-        "jdwp/jdwp_event.cc",
-        "jdwp/jdwp_expand_buf.cc",
-        "jdwp/jdwp_handler.cc",
-        "jdwp/jdwp_main.cc",
-        "jdwp/jdwp_request.cc",
-        "jdwp/jdwp_socket.cc",
-        "jdwp/object_registry.cc",
-        "jni_env_ext.cc",
-        "jit/debugger_interface.cc",
-        "jit/jit.cc",
-        "jit/jit_code_cache.cc",
-        "jit/offline_profiling_info.cc",
-        "jit/profiling_info.cc",
-        "jit/profile_saver.cc",
-        "jni_internal.cc",
-        "jobject_comparator.cc",
-        "linear_alloc.cc",
-        "mem_map.cc",
-        "memory_region.cc",
-        "mirror/abstract_method.cc",
-        "mirror/array.cc",
-        "mirror/class.cc",
-        "mirror/dex_cache.cc",
-        "mirror/field.cc",
-        "mirror/method.cc",
-        "mirror/object.cc",
-        "mirror/reference.cc",
-        "mirror/stack_trace_element.cc",
-        "mirror/string.cc",
-        "mirror/throwable.cc",
-        "monitor.cc",
-        "native_bridge_art_interface.cc",
-        "native_stack_dump.cc",
-        "native/dalvik_system_DexFile.cc",
-        "native/dalvik_system_VMDebug.cc",
-        "native/dalvik_system_VMRuntime.cc",
-        "native/dalvik_system_VMStack.cc",
-        "native/dalvik_system_ZygoteHooks.cc",
-        "native/java_lang_Class.cc",
-        "native/java_lang_DexCache.cc",
-        "native/java_lang_Object.cc",
-        "native/java_lang_String.cc",
-        "native/java_lang_StringFactory.cc",
-        "native/java_lang_System.cc",
-        "native/java_lang_Thread.cc",
-        "native/java_lang_Throwable.cc",
-        "native/java_lang_VMClassLoader.cc",
-        "native/java_lang_ref_FinalizerReference.cc",
-        "native/java_lang_ref_Reference.cc",
-        "native/java_lang_reflect_AbstractMethod.cc",
-        "native/java_lang_reflect_Array.cc",
-        "native/java_lang_reflect_Constructor.cc",
-        "native/java_lang_reflect_Field.cc",
-        "native/java_lang_reflect_Method.cc",
-        "native/java_lang_reflect_Proxy.cc",
-        "native/java_util_concurrent_atomic_AtomicLong.cc",
-        "native/libcore_util_CharsetUtils.cc",
-        "native/org_apache_harmony_dalvik_ddmc_DdmServer.cc",
-        "native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc",
-        "native/sun_misc_Unsafe.cc",
-        "oat.cc",
-        "oat_file.cc",
-        "oat_file_assistant.cc",
-        "oat_file_manager.cc",
-        "oat_quick_method_header.cc",
-        "object_lock.cc",
-        "offsets.cc",
-        "os_linux.cc",
-        "parsed_options.cc",
-        "plugin.cc",
-        "primitive.cc",
-        "quick_exception_handler.cc",
-        "quick/inline_method_analyser.cc",
-        "reference_table.cc",
-        "reflection.cc",
-        "runtime.cc",
-        "runtime_options.cc",
-        "signal_catcher.cc",
-        "stack.cc",
-        "stack_map.cc",
-        "thread.cc",
-        "thread_list.cc",
-        "thread_pool.cc",
-        "ti/agent.cc",
-        "trace.cc",
-        "transaction.cc",
-        "type_lookup_table.cc",
-        "utf.cc",
-        "utils.cc",
-        "verifier/instruction_flags.cc",
-        "verifier/method_verifier.cc",
-        "verifier/reg_type.cc",
-        "verifier/reg_type_cache.cc",
-        "verifier/register_line.cc",
-        "well_known_classes.cc",
-        "zip_archive.cc",
-
-        "arch/context.cc",
-        "arch/instruction_set.cc",
-        "arch/instruction_set_features.cc",
-        "arch/memcmp16.cc",
-        "arch/arm/instruction_set_features_arm.cc",
-        "arch/arm/registers_arm.cc",
-        "arch/arm64/instruction_set_features_arm64.cc",
-        "arch/arm64/registers_arm64.cc",
-        "arch/mips/instruction_set_features_mips.cc",
-        "arch/mips/registers_mips.cc",
-        "arch/mips64/instruction_set_features_mips64.cc",
-        "arch/mips64/registers_mips64.cc",
-        "arch/x86/instruction_set_features_x86.cc",
-        "arch/x86/registers_x86.cc",
-        "arch/x86_64/registers_x86_64.cc",
-        "entrypoints/entrypoint_utils.cc",
-        "entrypoints/jni/jni_entrypoints.cc",
-        "entrypoints/math_entrypoints.cc",
-        "entrypoints/quick/quick_alloc_entrypoints.cc",
-        "entrypoints/quick/quick_cast_entrypoints.cc",
-        "entrypoints/quick/quick_deoptimization_entrypoints.cc",
-        "entrypoints/quick/quick_dexcache_entrypoints.cc",
-        "entrypoints/quick/quick_field_entrypoints.cc",
-        "entrypoints/quick/quick_fillarray_entrypoints.cc",
-        "entrypoints/quick/quick_instrumentation_entrypoints.cc",
-        "entrypoints/quick/quick_jni_entrypoints.cc",
-        "entrypoints/quick/quick_lock_entrypoints.cc",
-        "entrypoints/quick/quick_math_entrypoints.cc",
-        "entrypoints/quick/quick_thread_entrypoints.cc",
-        "entrypoints/quick/quick_throw_entrypoints.cc",
-        "entrypoints/quick/quick_trampoline_entrypoints.cc",
-    ],
-
-    arch: {
-        arm: {
-            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
-            clang_asflags: ["-no-integrated-as"],
-            srcs: [
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_arm.S",
-                "arch/arm/context_arm.cc",
-                "arch/arm/entrypoints_init_arm.cc",
-                "arch/arm/instruction_set_features_assembly_tests.S",
-                "arch/arm/jni_entrypoints_arm.S",
-                "arch/arm/memcmp16_arm.S",
-                "arch/arm/quick_entrypoints_arm.S",
-                "arch/arm/quick_entrypoints_cc_arm.cc",
-                "arch/arm/thread_arm.cc",
-                "arch/arm/fault_handler_arm.cc",
-            ],
-        },
-        arm64: {
-            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
-            srcs: [
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_arm64.S",
-                "arch/arm64/context_arm64.cc",
-                "arch/arm64/entrypoints_init_arm64.cc",
-                "arch/arm64/jni_entrypoints_arm64.S",
-                "arch/arm64/memcmp16_arm64.S",
-                "arch/arm64/quick_entrypoints_arm64.S",
-                "arch/arm64/thread_arm64.cc",
-                "monitor_pool.cc",
-                "arch/arm64/fault_handler_arm64.cc",
-            ],
-        },
-        x86: {
-            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
-            srcs: [
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_x86.S",
-                "arch/x86/context_x86.cc",
-                "arch/x86/entrypoints_init_x86.cc",
-                "arch/x86/jni_entrypoints_x86.S",
-                "arch/x86/memcmp16_x86.S",
-                "arch/x86/quick_entrypoints_x86.S",
-                "arch/x86/thread_x86.cc",
-                "arch/x86/fault_handler_x86.cc",
-            ],
-        },
-        x86_64: {
-            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
-            srcs: [
-                // Note that the fault_handler_x86.cc is not a mistake.  This file is
-                // shared between the x86 and x86_64 architectures.
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_x86_64.S",
-                "arch/x86_64/context_x86_64.cc",
-                "arch/x86_64/entrypoints_init_x86_64.cc",
-                "arch/x86_64/jni_entrypoints_x86_64.S",
-                "arch/x86_64/memcmp16_x86_64.S",
-                "arch/x86_64/quick_entrypoints_x86_64.S",
-                "arch/x86_64/thread_x86_64.cc",
-                "monitor_pool.cc",
-                "arch/x86/fault_handler_x86.cc",
-            ],
-        },
-        mips: {
-            srcs: [
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_mips.S",
-                "arch/mips/context_mips.cc",
-                "arch/mips/entrypoints_init_mips.cc",
-                "arch/mips/jni_entrypoints_mips.S",
-                "arch/mips/memcmp16_mips.S",
-                "arch/mips/quick_entrypoints_mips.S",
-                "arch/mips/thread_mips.cc",
-                "arch/mips/fault_handler_mips.cc",
-            ],
-        },
-        mips64: {
-            srcs: [
-                "interpreter/mterp/mterp.cc",
-                "interpreter/mterp/out/mterp_mips64.S",
-                "arch/mips64/context_mips64.cc",
-                "arch/mips64/entrypoints_init_mips64.cc",
-                "arch/mips64/jni_entrypoints_mips64.S",
-                "arch/mips64/memcmp16_mips64.S",
-                "arch/mips64/quick_entrypoints_mips64.S",
-                "arch/mips64/thread_mips64.cc",
-                "monitor_pool.cc",
-                "arch/mips64/fault_handler_mips64.cc",
-            ],
-        },
-    },
-    target: {
-        android: {
-            srcs: [
-                "jdwp/jdwp_adb.cc",
-                "monitor_android.cc",
-                "runtime_android.cc",
-                "thread_android.cc",
-            ],
-            shared_libs: [
-                "libdl",
-                // For android::FileMap used by libziparchive.
-                "libutils",
-            ],
-            static_libs: [
-                // ZipArchive support, the order matters here to get all symbols.
-                "libziparchive",
-                "libz",
-                "libbase",
-            ],
-        },
-        host: {
-            srcs: [
-                "monitor_linux.cc",
-                "runtime_linux.cc",
-                "thread_linux.cc",
-            ],
-            shared_libs: [
-                "libziparchive",
-            ],
-        },
-    },
-    cflags: ["-DBUILDING_LIBART=1"],
-    generated_sources: ["art_operator_srcs"],
-    clang: true,
-    include_dirs: [
-        "art/cmdline",
-        "art/sigchainlib",
-        "art",
-    ],
-    shared_libs: [
-        "libnativehelper",
-        "libnativebridge",
-        "libnativeloader",
-        "libbacktrace",
-        "liblz4",
-        // For liblog, atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted.
-        "libcutils",
-    ],
-    static: {
-        static_libs: ["libsigchain_dummy"],
-    },
-    shared: {
-        shared_libs: ["libsigchain"],
-    },
-    export_include_dirs: ["."],
-}
-
-gensrcs {
-    name: "art_operator_srcs",
-    cmd: "art/tools/generate-operator-out.py art/runtime $in > $out",
-    srcs: [
-        "arch/instruction_set.h",
-        "base/allocator.h",
-        "base/enums.h",
-        "base/mutex.h",
-        "debugger.h",
-        "base/unix_file/fd_file.h",
-        "dex_file.h",
-        "dex_instruction.h",
-        "dex_instruction_utils.h",
-        "gc_root.h",
-        "gc/allocator_type.h",
-        "gc/allocator/rosalloc.h",
-        "gc/collector_type.h",
-        "gc/collector/gc_type.h",
-        "gc/heap.h",
-        "gc/space/region_space.h",
-        "gc/space/space.h",
-        "gc/weak_root_state.h",
-        "image.h",
-        "instrumentation.h",
-        "indirect_reference_table.h",
-        "invoke_type.h",
-        "jdwp/jdwp.h",
-        "jdwp/jdwp_constants.h",
-        "lock_word.h",
-        "mirror/class.h",
-        "oat.h",
-        "object_callbacks.h",
-        "process_state.h",
-        "quick/inline_method_analyser.h",
-        "runtime.h",
-        "stack.h",
-        "thread.h",
-        "thread_state.h",
-        "ti/agent.h",
-        "verifier/method_verifier.h",
-    ],
-    output_extension: "operator_out.cc",
-}
-
-// We always build dex2oat and dependencies, even if the host build is otherwise disabled, since
-// they are used to cross compile for the target.
-
-art_cc_library {
-    name: "libart",
-    defaults: ["libart_defaults"],
-}
-
-art_cc_library {
-    name: "libartd",
-    defaults: [
-        "libart_defaults",
-        "art_debug_defaults",
-    ],
-    // Leave the symbols in the shared library so that stack unwinders can
-    // produce meaningful name resolution.
-    strip: {
-        keep_symbols: true,
-    },
-}
-
-subdirs = [
-    "openjdkjvm",
-    "openjdkjvmti",
-    "simulator",
-]
diff --git a/runtime/Android.mk b/runtime/Android.mk
new file mode 100644
index 0000000..0e50eeb
--- /dev/null
+++ b/runtime/Android.mk
@@ -0,0 +1,657 @@
+#
+# Copyright (C) 2011 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)
+
+include art/build/Android.common_build.mk
+
+LIBART_COMMON_SRC_FILES := \
+  art_field.cc \
+  art_method.cc \
+  atomic.cc.arm \
+  barrier.cc \
+  base/allocator.cc \
+  base/arena_allocator.cc \
+  base/arena_bit_vector.cc \
+  base/bit_vector.cc \
+  base/file_magic.cc \
+  base/hex_dump.cc \
+  base/logging.cc \
+  base/mutex.cc \
+  base/scoped_arena_allocator.cc \
+  base/scoped_flock.cc \
+  base/stringpiece.cc \
+  base/stringprintf.cc \
+  base/time_utils.cc \
+  base/timing_logger.cc \
+  base/unix_file/fd_file.cc \
+  base/unix_file/random_access_file_utils.cc \
+  check_jni.cc \
+  class_linker.cc \
+  class_table.cc \
+  code_simulator_container.cc \
+  common_throws.cc \
+  compiler_filter.cc \
+  debugger.cc \
+  dex_file.cc \
+  dex_file_verifier.cc \
+  dex_instruction.cc \
+  elf_file.cc \
+  fault_handler.cc \
+  gc/allocation_record.cc \
+  gc/allocator/dlmalloc.cc \
+  gc/allocator/rosalloc.cc \
+  gc/accounting/bitmap.cc \
+  gc/accounting/card_table.cc \
+  gc/accounting/heap_bitmap.cc \
+  gc/accounting/mod_union_table.cc \
+  gc/accounting/remembered_set.cc \
+  gc/accounting/space_bitmap.cc \
+  gc/collector/concurrent_copying.cc \
+  gc/collector/garbage_collector.cc \
+  gc/collector/immune_region.cc \
+  gc/collector/immune_spaces.cc \
+  gc/collector/mark_compact.cc \
+  gc/collector/mark_sweep.cc \
+  gc/collector/partial_mark_sweep.cc \
+  gc/collector/semi_space.cc \
+  gc/collector/sticky_mark_sweep.cc \
+  gc/gc_cause.cc \
+  gc/heap.cc \
+  gc/reference_processor.cc \
+  gc/reference_queue.cc \
+  gc/scoped_gc_critical_section.cc \
+  gc/space/bump_pointer_space.cc \
+  gc/space/dlmalloc_space.cc \
+  gc/space/image_space.cc \
+  gc/space/large_object_space.cc \
+  gc/space/malloc_space.cc \
+  gc/space/region_space.cc \
+  gc/space/rosalloc_space.cc \
+  gc/space/space.cc \
+  gc/space/zygote_space.cc \
+  gc/task_processor.cc \
+  hprof/hprof.cc \
+  image.cc \
+  indirect_reference_table.cc \
+  instrumentation.cc \
+  intern_table.cc \
+  interpreter/interpreter.cc \
+  interpreter/interpreter_common.cc \
+  interpreter/interpreter_goto_table_impl.cc \
+  interpreter/interpreter_switch_impl.cc \
+  interpreter/unstarted_runtime.cc \
+  java_vm_ext.cc \
+  jdwp/jdwp_event.cc \
+  jdwp/jdwp_expand_buf.cc \
+  jdwp/jdwp_handler.cc \
+  jdwp/jdwp_main.cc \
+  jdwp/jdwp_request.cc \
+  jdwp/jdwp_socket.cc \
+  jdwp/object_registry.cc \
+  jni_env_ext.cc \
+  jit/debugger_interface.cc \
+  jit/jit.cc \
+  jit/jit_code_cache.cc \
+  jit/offline_profiling_info.cc \
+  jit/profiling_info.cc \
+  jit/profile_saver.cc  \
+  jni_internal.cc \
+  jobject_comparator.cc \
+  linear_alloc.cc \
+  mem_map.cc \
+  memory_region.cc \
+  mirror/abstract_method.cc \
+  mirror/array.cc \
+  mirror/class.cc \
+  mirror/dex_cache.cc \
+  mirror/field.cc \
+  mirror/method.cc \
+  mirror/object.cc \
+  mirror/reference.cc \
+  mirror/stack_trace_element.cc \
+  mirror/string.cc \
+  mirror/throwable.cc \
+  monitor.cc \
+  native_bridge_art_interface.cc \
+  native_stack_dump.cc \
+  native/dalvik_system_DexFile.cc \
+  native/dalvik_system_VMDebug.cc \
+  native/dalvik_system_VMRuntime.cc \
+  native/dalvik_system_VMStack.cc \
+  native/dalvik_system_ZygoteHooks.cc \
+  native/java_lang_Class.cc \
+  native/java_lang_DexCache.cc \
+  native/java_lang_Object.cc \
+  native/java_lang_String.cc \
+  native/java_lang_StringFactory.cc \
+  native/java_lang_System.cc \
+  native/java_lang_Thread.cc \
+  native/java_lang_Throwable.cc \
+  native/java_lang_VMClassLoader.cc \
+  native/java_lang_ref_FinalizerReference.cc \
+  native/java_lang_ref_Reference.cc \
+  native/java_lang_reflect_AbstractMethod.cc \
+  native/java_lang_reflect_Array.cc \
+  native/java_lang_reflect_Constructor.cc \
+  native/java_lang_reflect_Field.cc \
+  native/java_lang_reflect_Method.cc \
+  native/java_lang_reflect_Proxy.cc \
+  native/java_util_concurrent_atomic_AtomicLong.cc \
+  native/libcore_util_CharsetUtils.cc \
+  native/org_apache_harmony_dalvik_ddmc_DdmServer.cc \
+  native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc \
+  native/sun_misc_Unsafe.cc \
+  oat.cc \
+  oat_file.cc \
+  oat_file_assistant.cc \
+  oat_file_manager.cc \
+  oat_quick_method_header.cc \
+  object_lock.cc \
+  offsets.cc \
+  os_linux.cc \
+  parsed_options.cc \
+  plugin.cc \
+  primitive.cc \
+  quick_exception_handler.cc \
+  quick/inline_method_analyser.cc \
+  reference_table.cc \
+  reflection.cc \
+  runtime.cc \
+  runtime_options.cc \
+  signal_catcher.cc \
+  stack.cc \
+  stack_map.cc \
+  thread.cc \
+  thread_list.cc \
+  thread_pool.cc \
+  ti/agent.cc \
+  trace.cc \
+  transaction.cc \
+  type_lookup_table.cc \
+  utf.cc \
+  utils.cc \
+  verifier/instruction_flags.cc \
+  verifier/method_verifier.cc \
+  verifier/reg_type.cc \
+  verifier/reg_type_cache.cc \
+  verifier/register_line.cc \
+  well_known_classes.cc \
+  zip_archive.cc
+
+LIBART_COMMON_SRC_FILES += \
+  arch/context.cc \
+  arch/instruction_set.cc \
+  arch/instruction_set_features.cc \
+  arch/memcmp16.cc \
+  arch/arm/instruction_set_features_arm.cc \
+  arch/arm/registers_arm.cc \
+  arch/arm64/instruction_set_features_arm64.cc \
+  arch/arm64/registers_arm64.cc \
+  arch/mips/instruction_set_features_mips.cc \
+  arch/mips/registers_mips.cc \
+  arch/mips64/instruction_set_features_mips64.cc \
+  arch/mips64/registers_mips64.cc \
+  arch/x86/instruction_set_features_x86.cc \
+  arch/x86/registers_x86.cc \
+  arch/x86_64/registers_x86_64.cc \
+  entrypoints/entrypoint_utils.cc \
+  entrypoints/jni/jni_entrypoints.cc \
+  entrypoints/math_entrypoints.cc \
+  entrypoints/quick/quick_alloc_entrypoints.cc \
+  entrypoints/quick/quick_cast_entrypoints.cc \
+  entrypoints/quick/quick_deoptimization_entrypoints.cc \
+  entrypoints/quick/quick_dexcache_entrypoints.cc \
+  entrypoints/quick/quick_field_entrypoints.cc \
+  entrypoints/quick/quick_fillarray_entrypoints.cc \
+  entrypoints/quick/quick_instrumentation_entrypoints.cc \
+  entrypoints/quick/quick_jni_entrypoints.cc \
+  entrypoints/quick/quick_lock_entrypoints.cc \
+  entrypoints/quick/quick_math_entrypoints.cc \
+  entrypoints/quick/quick_thread_entrypoints.cc \
+  entrypoints/quick/quick_throw_entrypoints.cc \
+  entrypoints/quick/quick_trampoline_entrypoints.cc
+
+LIBART_TARGET_LDFLAGS :=
+LIBART_HOST_LDFLAGS :=
+
+# Keep the __jit_debug_register_code symbol as a unique symbol during ICF for architectures where
+# we use gold as the linker (arm, x86, x86_64). The symbol is used by the debuggers to detect when
+# new jit code is generated. We don't want it to be called when a different function with the same
+# (empty) body is called.
+JIT_DEBUG_REGISTER_CODE_LDFLAGS := -Wl,--keep-unique,__jit_debug_register_code
+LIBART_TARGET_LDFLAGS_arm    := $(JIT_DEBUG_REGISTER_CODE_LDFLAGS)
+LIBART_TARGET_LDFLAGS_arm64  := $(JIT_DEBUG_REGISTER_CODE_LDFLAGS)
+LIBART_TARGET_LDFLAGS_x86    := $(JIT_DEBUG_REGISTER_CODE_LDFLAGS)
+LIBART_TARGET_LDFLAGS_x86_64 := $(JIT_DEBUG_REGISTER_CODE_LDFLAGS)
+JIT_DEBUG_REGISTER_CODE_LDFLAGS :=
+
+LIBART_TARGET_SRC_FILES := \
+  $(LIBART_COMMON_SRC_FILES) \
+  jdwp/jdwp_adb.cc \
+  monitor_android.cc \
+  runtime_android.cc \
+  thread_android.cc
+
+LIBART_TARGET_SRC_FILES_arm := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_arm.S \
+  arch/arm/context_arm.cc.arm \
+  arch/arm/entrypoints_init_arm.cc \
+  arch/arm/instruction_set_features_assembly_tests.S \
+  arch/arm/jni_entrypoints_arm.S \
+  arch/arm/memcmp16_arm.S \
+  arch/arm/quick_entrypoints_arm.S \
+  arch/arm/quick_entrypoints_cc_arm.cc \
+  arch/arm/thread_arm.cc \
+  arch/arm/fault_handler_arm.cc
+
+LIBART_TARGET_SRC_FILES_arm64 := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_arm64.S \
+  arch/arm64/context_arm64.cc \
+  arch/arm64/entrypoints_init_arm64.cc \
+  arch/arm64/jni_entrypoints_arm64.S \
+  arch/arm64/memcmp16_arm64.S \
+  arch/arm64/quick_entrypoints_arm64.S \
+  arch/arm64/thread_arm64.cc \
+  monitor_pool.cc \
+  arch/arm64/fault_handler_arm64.cc
+
+LIBART_SRC_FILES_x86 := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_x86.S \
+  arch/x86/context_x86.cc \
+  arch/x86/entrypoints_init_x86.cc \
+  arch/x86/jni_entrypoints_x86.S \
+  arch/x86/memcmp16_x86.S \
+  arch/x86/quick_entrypoints_x86.S \
+  arch/x86/thread_x86.cc \
+  arch/x86/fault_handler_x86.cc
+
+LIBART_TARGET_SRC_FILES_x86 := \
+  $(LIBART_SRC_FILES_x86)
+
+# Note that the fault_handler_x86.cc is not a mistake.  This file is
+# shared between the x86 and x86_64 architectures.
+LIBART_SRC_FILES_x86_64 := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_x86_64.S \
+  arch/x86_64/context_x86_64.cc \
+  arch/x86_64/entrypoints_init_x86_64.cc \
+  arch/x86_64/jni_entrypoints_x86_64.S \
+  arch/x86_64/memcmp16_x86_64.S \
+  arch/x86_64/quick_entrypoints_x86_64.S \
+  arch/x86_64/thread_x86_64.cc \
+  monitor_pool.cc \
+  arch/x86/fault_handler_x86.cc
+
+LIBART_TARGET_SRC_FILES_x86_64 := \
+  $(LIBART_SRC_FILES_x86_64) \
+
+LIBART_TARGET_SRC_FILES_mips := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_mips.S \
+  arch/mips/context_mips.cc \
+  arch/mips/entrypoints_init_mips.cc \
+  arch/mips/jni_entrypoints_mips.S \
+  arch/mips/memcmp16_mips.S \
+  arch/mips/quick_entrypoints_mips.S \
+  arch/mips/thread_mips.cc \
+  arch/mips/fault_handler_mips.cc
+
+LIBART_TARGET_SRC_FILES_mips64 := \
+  interpreter/mterp/mterp.cc \
+  interpreter/mterp/out/mterp_mips64.S \
+  arch/mips64/context_mips64.cc \
+  arch/mips64/entrypoints_init_mips64.cc \
+  arch/mips64/jni_entrypoints_mips64.S \
+  arch/mips64/memcmp16_mips64.S \
+  arch/mips64/quick_entrypoints_mips64.S \
+  arch/mips64/thread_mips64.cc \
+  monitor_pool.cc \
+  arch/mips64/fault_handler_mips64.cc
+
+LIBART_HOST_SRC_FILES := \
+  $(LIBART_COMMON_SRC_FILES) \
+  monitor_linux.cc \
+  runtime_linux.cc \
+  thread_linux.cc
+
+LIBART_HOST_SRC_FILES_32 := \
+  $(LIBART_SRC_FILES_x86)
+
+LIBART_HOST_SRC_FILES_64 := \
+  $(LIBART_SRC_FILES_x86_64)
+
+LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := \
+  arch/instruction_set.h \
+  base/allocator.h \
+  base/enums.h \
+  base/mutex.h \
+  debugger.h \
+  base/unix_file/fd_file.h \
+  dex_file.h \
+  dex_instruction.h \
+  dex_instruction_utils.h \
+  gc_root.h \
+  gc/allocator_type.h \
+  gc/allocator/rosalloc.h \
+  gc/collector_type.h \
+  gc/collector/gc_type.h \
+  gc/heap.h \
+  gc/space/region_space.h \
+  gc/space/space.h \
+  gc/weak_root_state.h \
+  image.h \
+  instrumentation.h \
+  indirect_reference_table.h \
+  invoke_type.h \
+  jdwp/jdwp.h \
+  jdwp/jdwp_constants.h \
+  lock_word.h \
+  mirror/class.h \
+  oat.h \
+  object_callbacks.h \
+  process_state.h \
+  quick/inline_method_analyser.h \
+  runtime.h \
+  stack.h \
+  thread.h \
+  thread_state.h \
+  ti/agent.h \
+  verifier/method_verifier.h
+
+LIBOPENJDKJVM_SRC_FILES := openjdkjvm/OpenjdkJvm.cc
+LIBOPENJDKJVMTI_SRC_FILES := openjdkjvmti/OpenjdkJvmTi.cc
+
+LIBART_CFLAGS := -DBUILDING_LIBART=1
+
+LIBART_TARGET_CFLAGS :=
+LIBART_HOST_CFLAGS :=
+
+# $(1): target or host
+# $(2): ndebug or debug
+# $(3): static or shared (note that static only applies for host)
+# $(4): module name : either libart, libopenjdkjvm, or libopenjdkjvmti
+define build-runtime-library
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+  ifneq ($(2),ndebug)
+    ifneq ($(2),debug)
+      $$(error expected ndebug or debug for argument 2, received $(2))
+    endif
+  endif
+  ifneq ($(4),libart)
+    ifneq ($(4),libopenjdkjvm)
+      ifneq ($(4),libopenjdkjvmti)
+        $$(error expected libart, libopenjdkjvmti, or libopenjdkjvm for argument 4, received $(4))
+      endif
+    endif
+  endif
+
+  art_target_or_host := $(1)
+  art_ndebug_or_debug := $(2)
+  art_static_or_shared := $(3)
+
+  include $$(CLEAR_VARS)
+  LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION)
+  ifeq ($$(art_ndebug_or_debug),ndebug)
+    LOCAL_MODULE := $(4)
+    ifeq ($$(art_target_or_host),target)
+      LOCAL_FDO_SUPPORT := true
+    endif
+  else # debug
+    LOCAL_MODULE := $(4)d
+  endif
+
+  LOCAL_MODULE_TAGS := optional
+
+  ifeq ($$(art_static_or_shared),static)
+    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+  else
+    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+  endif
+
+  ifeq ($(4),libart)
+    ifeq ($$(art_target_or_host),target)
+      LOCAL_SRC_FILES := $$(LIBART_TARGET_SRC_FILES)
+      $$(foreach arch,$$(ART_TARGET_SUPPORTED_ARCH), \
+        $$(eval LOCAL_SRC_FILES_$$(arch) := $$$$(LIBART_TARGET_SRC_FILES_$$(arch))))
+    else # host
+      LOCAL_SRC_FILES := $$(LIBART_HOST_SRC_FILES)
+      LOCAL_SRC_FILES_32 := $$(LIBART_HOST_SRC_FILES_32)
+      LOCAL_SRC_FILES_64 := $$(LIBART_HOST_SRC_FILES_64)
+      LOCAL_IS_HOST_MODULE := true
+    endif
+  else
+    ifeq ($(4),libopenjdkjvmti)
+      LOCAL_SRC_FILES := $$(LIBOPENJDKJVMTI_SRC_FILES)
+    else # libopenjdkjvm
+      LOCAL_SRC_FILES := $$(LIBOPENJDKJVM_SRC_FILES)
+    endif
+    ifeq ($$(art_target_or_host),host)
+      LOCAL_IS_HOST_MODULE := true
+    endif
+  endif
+
+ifeq ($(4),libart)
+  GENERATED_SRC_DIR := $$(call local-generated-sources-dir)
+  ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,$$(LIBART_ENUM_OPERATOR_OUT_HEADER_FILES))
+  ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES))
+
+$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py
+$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@
+$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h
+	$$(transform-generated-source)
+
+  LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN)
+endif
+
+  LOCAL_CFLAGS := $$(LIBART_CFLAGS)
+  LOCAL_LDFLAGS := $$(LIBART_LDFLAGS)
+  ifeq ($$(art_target_or_host),target)
+    LOCAL_CFLAGS += $$(LIBART_TARGET_CFLAGS)
+    LOCAL_LDFLAGS += $$(LIBART_TARGET_LDFLAGS)
+    $$(foreach arch,$$(ART_TARGET_SUPPORTED_ARCH), \
+      $$(eval LOCAL_LDFLAGS_$$(arch) := $$(LIBART_TARGET_LDFLAGS_$$(arch))))
+  else #host
+    LOCAL_CFLAGS += $$(LIBART_HOST_CFLAGS)
+    LOCAL_LDFLAGS += $$(LIBART_HOST_LDFLAGS)
+    ifeq ($$(art_static_or_shared),static)
+      LOCAL_LDFLAGS += -static
+    endif
+  endif
+
+  # Clang usage
+  ifeq ($$(art_target_or_host),target)
+    $$(eval LOCAL_CLANG := $$(ART_TARGET_CLANG))
+    $$(eval $$(call set-target-local-cflags-vars,$(2)))
+    LOCAL_ASFLAGS_arm += -no-integrated-as
+  else # host
+    LOCAL_CLANG := $$(ART_HOST_CLANG)
+    LOCAL_LDLIBS += -ldl -lpthread
+    ifeq ($$(HOST_OS),linux)
+      LOCAL_LDLIBS += -lrt
+    endif
+    LOCAL_CFLAGS += $$(ART_HOST_CFLAGS)
+    LOCAL_ASFLAGS += $$(ART_HOST_ASFLAGS)
+
+    ifeq ($$(art_ndebug_or_debug),debug)
+      LOCAL_CFLAGS += $$(ART_HOST_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $$(ART_HOST_DEBUG_ASFLAGS)
+    else
+      LOCAL_CFLAGS += $$(ART_HOST_NON_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $$(ART_HOST_NON_DEBUG_ASFLAGS)
+    endif
+    LOCAL_MULTILIB := both
+  endif
+
+  LOCAL_C_INCLUDES += $$(ART_C_INCLUDES)
+  LOCAL_C_INCLUDES += art/cmdline
+  LOCAL_C_INCLUDES += art/sigchainlib
+  LOCAL_C_INCLUDES += art
+
+  ifeq ($$(art_static_or_shared),static)
+    LOCAL_STATIC_LIBRARIES := libnativehelper
+    LOCAL_STATIC_LIBRARIES += libnativebridge
+    LOCAL_STATIC_LIBRARIES += libnativeloader
+    LOCAL_STATIC_LIBRARIES += libsigchain_dummy
+    LOCAL_STATIC_LIBRARIES += libbacktrace
+    LOCAL_STATIC_LIBRARIES += liblz4
+  else
+    LOCAL_SHARED_LIBRARIES := libnativehelper
+    LOCAL_SHARED_LIBRARIES += libnativebridge
+    LOCAL_SHARED_LIBRARIES += libnativeloader
+    LOCAL_SHARED_LIBRARIES += libsigchain
+    LOCAL_SHARED_LIBRARIES += libbacktrace
+    LOCAL_SHARED_LIBRARIES += liblz4
+  endif
+
+  ifeq ($$(art_target_or_host),target)
+    LOCAL_SHARED_LIBRARIES += libdl
+    # ZipArchive support, the order matters here to get all symbols.
+    LOCAL_STATIC_LIBRARIES := libziparchive libz libbase
+    # For android::FileMap used by libziparchive.
+    LOCAL_SHARED_LIBRARIES += libutils
+    # For liblog, atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted.
+    LOCAL_SHARED_LIBRARIES += libcutils
+  else # host
+    ifeq ($$(art_static_or_shared),static)
+      LOCAL_STATIC_LIBRARIES += libziparchive-host libz
+      # For ashmem_create_region.
+      LOCAL_STATIC_LIBRARIES += libcutils
+    else
+      LOCAL_SHARED_LIBRARIES += libziparchive-host libz-host
+      # For ashmem_create_region.
+      LOCAL_SHARED_LIBRARIES += libcutils
+    endif
+  endif
+
+  ifeq ($(4),libopenjdkjvm)
+    ifeq ($$(art_ndebug_or_debug),ndebug)
+      LOCAL_SHARED_LIBRARIES += libart
+    else
+      LOCAL_SHARED_LIBRARIES += libartd
+    endif
+    LOCAL_NOTICE_FILE := $(LOCAL_PATH)/openjdkjvm/NOTICE
+  else
+    ifeq ($(4),libopenjdkjvmti)
+      ifeq ($$(art_ndebug_or_debug),ndebug)
+        LOCAL_SHARED_LIBRARIES += libart
+      else
+        LOCAL_SHARED_LIBRARIES += libartd
+      endif
+      LOCAL_NOTICE_FILE := $(LOCAL_PATH)/openjdkjvmti/NOTICE
+    endif
+  endif
+  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
+  LOCAL_ADDITIONAL_DEPENDENCIES += $$(LOCAL_PATH)/Android.mk
+
+  ifeq ($$(art_target_or_host),target)
+    LOCAL_MODULE_TARGET_ARCH := $$(ART_TARGET_SUPPORTED_ARCH)
+  endif
+
+  LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
+
+  ifeq ($$(art_target_or_host),target)
+    ifneq ($$(art_ndebug_or_debug),debug)
+      # Leave the symbols in the shared library so that stack unwinders can
+      # produce meaningful name resolution.
+      LOCAL_STRIP_MODULE := keep_symbols
+    endif
+    include $$(BUILD_SHARED_LIBRARY)
+  else # host
+    ifeq ($$(art_static_or_shared),static)
+      include $$(BUILD_HOST_STATIC_LIBRARY)
+    else
+      include $$(BUILD_HOST_SHARED_LIBRARY)
+    endif
+  endif
+
+  # Clear locally defined variables.
+  GENERATED_SRC_DIR :=
+  ENUM_OPERATOR_OUT_CC_FILES :=
+  ENUM_OPERATOR_OUT_GEN :=
+  art_target_or_host :=
+  art_ndebug_or_debug :=
+  art_static_or_shared :=
+endef
+
+# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since
+# they are used to cross compile for the target.
+ifeq ($(ART_BUILD_HOST_NDEBUG),true)
+  $(eval $(call build-runtime-library,host,ndebug,shared,libart))
+  $(eval $(call build-runtime-library,host,ndebug,shared,libopenjdkjvm))
+  $(eval $(call build-runtime-library,host,ndebug,shared,libopenjdkjvmti))
+  ifeq ($(ART_BUILD_HOST_STATIC),true)
+    $(eval $(call build-runtime-library,host,ndebug,static,libart))
+    $(eval $(call build-runtime-library,host,ndebug,static,libopenjdkjvm))
+    $(eval $(call build-runtime-library,host,ndebug,static,libopenjdkjvmti))
+  endif
+endif
+ifeq ($(ART_BUILD_HOST_DEBUG),true)
+  $(eval $(call build-runtime-library,host,debug,shared,libart))
+  $(eval $(call build-runtime-library,host,debug,shared,libopenjdkjvm))
+  $(eval $(call build-runtime-library,host,debug,shared,libopenjdkjvmti))
+  ifeq ($(ART_BUILD_HOST_STATIC),true)
+    $(eval $(call build-runtime-library,host,debug,static,libart))
+    $(eval $(call build-runtime-library,host,debug,static,libopenjdkjvm))
+    $(eval $(call build-runtime-library,host,debug,static,libopenjdkjvmti))
+  endif
+endif
+
+ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
+#  $(error $(call build-runtime-library,target,ndebug))
+  $(eval $(call build-runtime-library,target,ndebug,shared,libart))
+  $(eval $(call build-runtime-library,target,ndebug,shared,libopenjdkjvm))
+  $(eval $(call build-runtime-library,target,ndebug,shared,libopenjdkjvmti))
+endif
+ifeq ($(ART_BUILD_TARGET_DEBUG),true)
+  $(eval $(call build-runtime-library,target,debug,shared,libart))
+  $(eval $(call build-runtime-library,target,debug,shared,libopenjdkjvm))
+  $(eval $(call build-runtime-library,target,debug,shared,libopenjdkjvmti))
+endif
+
+# Clear locally defined variables.
+LOCAL_PATH :=
+LIBART_COMMON_SRC_FILES :=
+LIBART_HOST_LDFLAGS :=
+LIBART_TARGET_LDFLAGS :=
+LIBART_TARGET_LDFLAGS_arm :=
+LIBART_TARGET_LDFLAGS_arm64 :=
+LIBART_TARGET_LDFLAGS_x86 :=
+LIBART_TARGET_LDFLAGS_x86_64 :=
+LIBART_TARGET_LDFLAGS_mips :=
+LIBART_TARGET_LDFLAGS_mips64 :=
+LIBART_TARGET_SRC_FILES :=
+LIBART_TARGET_SRC_FILES_arm :=
+LIBART_TARGET_SRC_FILES_arm64 :=
+LIBART_TARGET_SRC_FILES_x86 :=
+LIBART_TARGET_SRC_FILES_x86_64 :=
+LIBART_TARGET_SRC_FILES_mips :=
+LIBART_TARGET_SRC_FILES_mips64 :=
+LIBART_HOST_SRC_FILES :=
+LIBART_HOST_SRC_FILES_32 :=
+LIBART_HOST_SRC_FILES_64 :=
+LIBART_ENUM_OPERATOR_OUT_HEADER_FILES :=
+LIBART_CFLAGS :=
+LIBART_TARGET_CFLAGS :=
+LIBART_HOST_CFLAGS :=
+build-runtime-library :=
diff --git a/runtime/openjdkjvm/Android.bp b/runtime/openjdkjvm/Android.bp
deleted file mode 100644
index 3e8dc8c..0000000
--- a/runtime/openjdkjvm/Android.bp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (C) 2016 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.
-
-cc_defaults {
-    name: "libopenjdkjvm_defaults",
-    defaults: ["art_defaults"],
-    host_supported: true,
-    srcs: ["OpenjdkJvm.cc"],
-    include_dirs: ["art/runtime"],
-    shared_libs: ["libnativehelper"],
-}
-
-art_cc_library {
-    name: "libopenjdkjvm",
-    defaults: ["libopenjdkjvm_defaults"],
-    shared_libs: ["libart"],
-}
-
-art_cc_library {
-    name: "libopenjdkjvmd",
-    defaults: [
-        "libopenjdkjvm_defaults",
-        "art_debug_defaults",
-    ],
-    shared_libs: ["libartd"],
-}
diff --git a/runtime/openjdkjvm/Android.mk b/runtime/openjdkjvm/Android.mk
new file mode 100644
index 0000000..9b7404e
--- /dev/null
+++ b/runtime/openjdkjvm/Android.mk
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2016 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)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := openjdkjvm-phony
+include $(BUILD_PHONY_PACKAGE)
diff --git a/runtime/openjdkjvmti/Android.bp b/runtime/openjdkjvmti/Android.bp
deleted file mode 100644
index 4430248..0000000
--- a/runtime/openjdkjvmti/Android.bp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (C) 2016 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.
-
-cc_defaults {
-    name: "libopenjdkjvmti_defaults",
-    defaults: ["art_defaults"],
-    host_supported: true,
-    srcs: ["OpenjdkJvmTi.cc"],
-    include_dirs: ["art/runtime"],
-    shared_libs: ["libnativehelper"],
-}
-
-art_cc_library {
-    name: "libopenjdkjvmti",
-    defaults: ["libopenjdkjvmti_defaults"],
-    shared_libs: ["libart"],
-}
-
-art_cc_library {
-    name: "libopenjdkjvmtid",
-    defaults: [
-        "libopenjdkjvmti_defaults",
-        "art_debug_defaults",
-    ],
-    shared_libs: ["libartd"],
-}
diff --git a/runtime/openjdkjvmti/Android.mk b/runtime/openjdkjvmti/Android.mk
new file mode 100644
index 0000000..1de20e8
--- /dev/null
+++ b/runtime/openjdkjvmti/Android.mk
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2016 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)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := openjdkjvmti-phony
+include $(BUILD_PHONY_PACKAGE)
diff --git a/runtime/simulator/Android.bp b/runtime/simulator/Android.bp
deleted file mode 100644
index 05f44e3..0000000
--- a/runtime/simulator/Android.bp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Copyright (C) 2015 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.
-//
-
-cc_defaults {
-    name: "libart_simulator_defaults",
-    defaults: ["art_defaults"],
-    srcs: [
-        "code_simulator.cc",
-        "code_simulator_arm64.cc",
-    ],
-    shared_libs: [
-        "liblog",
-    ],
-    cflags: ["-DVIXL_INCLUDE_SIMULATOR_AARCH64"],
-    export_include_dirs: ["."],
-    include_dirs: ["art/runtime"],
-}
-
-cc_library_host_shared {
-    name: "libart-simulator",
-    defaults: ["libart_simulator_defaults"],
-    shared_libs: [
-        "libart",
-        "libvixl-arm64",
-    ],
-}
-
-cc_library_host_shared {
-    name: "libart-simulatord",
-    defaults: [
-        "libart_simulator_defaults",
-        "art_debug_defaults",
-    ],
-    shared_libs: [
-        "libartd",
-        "libvixld-arm64",
-    ],
-}
diff --git a/runtime/simulator/Android.mk b/runtime/simulator/Android.mk
new file mode 100644
index 0000000..e39af2d
--- /dev/null
+++ b/runtime/simulator/Android.mk
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2015 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)
+
+include art/build/Android.common_build.mk
+
+LIBART_SIMULATOR_SRC_FILES := \
+  code_simulator.cc \
+  code_simulator_arm64.cc
+
+LIBART_SIMULATOR_CFLAGS := \
+  -DVIXL_INCLUDE_SIMULATOR_AARCH64
+
+# $(1): target or host
+# $(2): ndebug or debug
+define build-libart-simulator
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+  ifneq ($(2),ndebug)
+    ifneq ($(2),debug)
+      $$(error expected ndebug or debug for argument 2, received $(2))
+    endif
+  endif
+
+  art_target_or_host := $(1)
+  art_ndebug_or_debug := $(2)
+
+  include $(CLEAR_VARS)
+  ifeq ($$(art_target_or_host),host)
+     LOCAL_IS_HOST_MODULE := true
+  endif
+  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+  ifeq ($$(art_ndebug_or_debug),ndebug)
+    LOCAL_MODULE := libart-simulator
+  else # debug
+    LOCAL_MODULE := libartd-simulator
+  endif
+
+  LOCAL_MODULE_TAGS := optional
+  LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+  LOCAL_SRC_FILES := $$(LIBART_SIMULATOR_SRC_FILES)
+  LOCAL_CFLAGS := $$(LIBART_SIMULATOR_CFLAGS)
+
+  ifeq ($$(art_target_or_host),target)
+    $(call set-target-local-clang-vars)
+    $(call set-target-local-cflags-vars,$(2))
+  else # host
+    LOCAL_CLANG := $(ART_HOST_CLANG)
+    LOCAL_LDLIBS := $(ART_HOST_LDLIBS)
+    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+    LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
+    ifeq ($$(art_ndebug_or_debug),debug)
+      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $(ART_HOST_DEBUG_ASFLAGS)
+    else
+      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
+      LOCAL_ASFLAGS += $(ART_HOST_NON_DEBUG_ASFLAGS)
+    endif
+  endif
+
+  LOCAL_SHARED_LIBRARIES += liblog
+  ifeq ($$(art_ndebug_or_debug),debug)
+    LOCAL_SHARED_LIBRARIES += libartd
+  else
+    LOCAL_SHARED_LIBRARIES += libart
+  endif
+
+  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime
+  LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+  LOCAL_MULTILIB := both
+
+  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+  LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
+  # For simulator_arm64.
+  ifeq ($$(art_ndebug_or_debug),debug)
+    LOCAL_SHARED_LIBRARIES += libvixld-arm64
+  else
+    LOCAL_SHARED_LIBRARIES += libvixl-arm64
+  endif
+  ifeq ($$(art_target_or_host),target)
+    include $(BUILD_SHARED_LIBRARY)
+  else # host
+    include $(BUILD_HOST_SHARED_LIBRARY)
+  endif
+endef
+
+ifeq ($(ART_BUILD_HOST_NDEBUG),true)
+  $(eval $(call build-libart-simulator,host,ndebug))
+endif
+ifeq ($(ART_BUILD_HOST_DEBUG),true)
+  $(eval $(call build-libart-simulator,host,debug))
+endif
diff --git a/sigchainlib/Android.bp b/sigchainlib/Android.bp
deleted file mode 100644
index 08af254..0000000
--- a/sigchainlib/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (C) 2014 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.
-//
-
-cc_library {
-    name: "libsigchain",
-    host_supported: true,
-    defaults: ["art_defaults"],
-    shared: {
-        srcs: ["sigchain_dummy.cc"],
-    },
-    static: {
-        srcs: ["sigchain.cc"],
-    },
-    target: {
-        host: {
-            host_ldlibs: ["-ldl"],
-        },
-        android: {
-            shared_libs: ["liblog"],
-        },
-    },
-}
-
-// Create a dummy version of libsigchain which expose the necessary symbols
-// but throws when called. This can be used to get static binaries which don't
-// need the real functionality of the sig chain but need to please the linker.
-cc_library_static {
-    name: "libsigchain_dummy",
-    host_supported: true,
-    defaults: ["art_defaults"],
-    srcs: ["sigchain_dummy.cc"],
-    target: {
-        host: {
-            host_ldlibs: ["-ldl"],
-        },
-        android: {
-            shared_libs: ["liblog"],
-        },
-    },
-}
diff --git a/sigchainlib/Android.mk b/sigchainlib/Android.mk
new file mode 100644
index 0000000..e1120e4
--- /dev/null
+++ b/sigchainlib/Android.mk
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2014 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)
+
+include art/build/Android.common_build.mk
+
+include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
+LOCAL_SRC_FILES := sigchain_dummy.cc
+LOCAL_CLANG := $(ART_TARGET_CLANG)
+LOCAL_MODULE:= libsigchain
+LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_build.mk
+LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
+$(eval $(call set-target-local-clang-vars))
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
+LOCAL_SRC_FILES := sigchain.cc
+LOCAL_CLANG := $(ART_TARGET_CLANG)
+LOCAL_MODULE:= libsigchain
+LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_build.mk
+$(eval $(call set-target-local-clang-vars))
+include $(BUILD_STATIC_LIBRARY)
+
+# Build host library.
+include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+LOCAL_MODULE_TAGS := optional
+LOCAL_IS_HOST_MODULE := true
+LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
+LOCAL_CLANG := $(ART_HOST_CLANG)
+LOCAL_SRC_FILES := sigchain_dummy.cc
+LOCAL_MODULE:= libsigchain
+LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+LOCAL_LDLIBS := -ldl
+LOCAL_MULTILIB := both
+LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+LOCAL_MODULE_TAGS := optional
+LOCAL_IS_HOST_MODULE := true
+LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
+LOCAL_CLANG := $(ART_HOST_CLANG)
+LOCAL_SRC_FILES := sigchain.cc
+LOCAL_MODULE:= libsigchain
+LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+LOCAL_LDLIBS := -ldl
+LOCAL_MULTILIB := both
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# Create a dummy version of libsigchain which expose the necessary symbols
+# but throws when called. This can be used to get static binaries which don't
+# need the real functionality of the sig chain but need to please the linker.
+include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+LOCAL_MODULE_TAGS := optional
+LOCAL_IS_HOST_MODULE := true
+LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+LOCAL_CLANG := $(ART_HOST_CLANG)
+LOCAL_SRC_FILES := sigchain_dummy.cc
+LOCAL_MODULE:= libsigchain_dummy
+LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+LOCAL_LDLIBS := -ldl
+LOCAL_MULTILIB := both
+include $(BUILD_HOST_STATIC_LIBRARY)