build: Add QCOM target-specific config

 * Needed to support global DirectTract config on legacy targets
 * Let's also eliminate some boilerplate

Change-Id: I736c10a5e7e1f3d1e0de9e60f29b60add276f151
diff --git a/core/config.mk b/core/config.mk
index 68d91ce..b13a88d 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -687,6 +687,9 @@
 RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
 RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
 
+# Rules for QCOM targets
+include $(BUILD_SYSTEM)/qcom_target.mk
+
 ifneq ($(CM_BUILD),)
 ## We need to be sure the global selinux policies are included
 ## last, to avoid accidental resetting by device configs
diff --git a/core/qcom_target.mk b/core/qcom_target.mk
new file mode 100644
index 0000000..b993e8f
--- /dev/null
+++ b/core/qcom_target.mk
@@ -0,0 +1,19 @@
+# Target-specific configuration
+
+# Enable DirectTrack on QCOM legacy boards
+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+
+    TARGET_GLOBAL_CFLAGS += -DQCOM_HARDWARE
+
+    ifeq ($(TARGET_USES_QCOM_BSP),true)
+        TARGET_GLOBAL_CFLAGS += -DQCOM_BSP
+    endif
+
+    # Enable DirectTrack for legacy targets
+    ifneq ($(filter caf bfam,$(TARGET_QCOM_AUDIO_VARIANT)),)
+        ifeq ($(BOARD_USES_LEGACY_ALSA_AUDIO),true)
+            TARGET_GLOBAL_CFLAGS += -DQCOM_DIRECTTRACK
+        endif
+    endif
+endif
+