Refactor FDO support code to ensure arm64 can also be built with FDO.
Change-Id: I752c9f411b0a046a15c72b4837efc1fb0503b470
diff --git a/core/combo/fdo.mk b/core/combo/fdo.mk
new file mode 100644
index 0000000..26e842f
--- /dev/null
+++ b/core/combo/fdo.mk
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Setup FDO related flags.
+
+$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=
+$(combo_2nd_arch_prefix)TARGET_FDO_LIB:=
+
+ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
+ # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
+ # The profile will be generated on /data/local/tmp/profile on the device.
+ $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/fdo_profile -DANDROID_FDO
+ $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov)
+else
+ ifneq ($(strip $(BUILD_FDO_OPTIMIZE)),)
+ # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
+ ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
+ $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := fdo_profiles
+ endif
+
+ ifneq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH))),)
+ $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
+ $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov)
+ else
+ $(warning Profile directory $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) does not exist. Turn off FDO.)
+ endif
+ endif
+endif