1# Use bash for additional echo fancyness
2SHELL = /bin/bash
3
4####################################################################################################
5## defines
6
7# Build for Jellybean
8#--yd BUILD_ANDROID_JELLYBEAN = $(shell test -d $(ANDROID_ROOT)/frameworks/native && echo 1)
9
10# Build for Lollipop
11# ANDROID version check
12BUILD_ANDROID_LOLLIPOP = $(shell test -d $(ANDROID_ROOT)/bionic/libc/kernel/uapi && echo 1)
13#ANDROID version check END
14
15#--yd PRODUCT = generic_arm64
16#--yd TARGET = android
17
18## libraries ##
19LIB_PREFIX = lib
20
21STATIC_LIB_EXT = a
22SHARED_LIB_EXT = so
23
24# normally, overridden from outside
25# ?= assignment sets it only if not already defined
26TARGET ?= android
27
28MLLITE_LIB_NAME     ?= mllite
29#--yd MLLITE_LIB_NAME     ?= mllite_64
30MPL_LIB_NAME        ?= mplmpu
31
32## applications ##
33SHARED_APP_SUFFIX = -shared
34STATIC_APP_SUFFIX = -static
35
36####################################################################################################
37## compile, includes, and linker
38
39ifeq ($(BUILD_ANDROID_JELLYBEAN),1)
40ANDROID_COMPILE = -DANDROID_JELLYBEAN=1
41endif
42
43ANDROID_LINK  = -nostdlib
44ANDROID_LINK += -fpic
45ANDROID_LINK += -Wl,--gc-sections
46ANDROID_LINK += -Wl,--no-whole-archive
47ANDROID_LINK += -L$(ANDROID_ROOT)/out/target/product/$(PRODUCT)/obj/lib
48ifeq ($(ARCH),arm)
49ANDROID_LINK += -L$(ANDROID_ROOT)/out/target/product/$(PRODUCT)/system/lib
50endif
51
52ANDROID_LINK_EXECUTABLE  = $(ANDROID_LINK)
53ifeq ($(ARCH),arm64)
54ANDROID_LINK_EXECUTABLE += -Wl,-dynamic-linker,/system/bin/linker64
55else
56ANDROID_LINK_EXECUTABLE += -Wl,-dynamic-linker,/system/bin/linker
57endif
58ifneq ($(BUILD_ANDROID_JELLYBEAN),1)
59#--yd ANDROID_LINK_EXECUTABLE += -Wl,-T,$(ANDROID_ROOT)/build/core/armelf.x
60#--yd ANDROID_LINK_EXECUTABLE += -Wl,-T,$(ANDROID_ROOT)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/lib/ldscripts/armelf.x
61ifeq ($(ARCH),arm64)
62ANDROID_LINK_EXECUTABLE += -Wl,-T,$(ANDROID_ROOT)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/lib/ldscripts/aarch64linux.x
63endif
64endif
65ANDROID_LINK_EXECUTABLE += $(ANDROID_ROOT)/out/target/product/$(PRODUCT)/obj/lib/crtbegin_dynamic.o
66ANDROID_LINK_EXECUTABLE += $(ANDROID_ROOT)/out/target/product/$(PRODUCT)/obj/lib/crtend_android.o
67
68ANDROID_INCLUDES  = -I$(ANDROID_ROOT)/system/core/include
69ANDROID_INCLUDES += -I$(ANDROID_ROOT)/hardware/libhardware/include
70ANDROID_INCLUDES += -I$(ANDROID_ROOT)/hardware/ril/include
71ANDROID_INCLUDES += -I$(ANDROID_ROOT)/dalvik/libnativehelper/include
72ANDROID_INCLUDES += -I$(ANDROID_ROOT)/frameworks/base/include   # ICS
73ANDROID_INCLUDES += -I$(ANDROID_ROOT)/frameworks/native/include # Jellybean
74ANDROID_INCLUDES += -I$(ANDROID_ROOT)/external/skia/include
75ANDROID_INCLUDES += -I$(ANDROID_ROOT)/out/target/product/generic/obj/include
76#--yd ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/arch-arm/include
77
78ifeq ($(BUILD_ANDROID_LOLLIPOP),1)
79#for Android L--yd
80ANDROID_INCLUDES += -DHAVE_SYS_UIO_H
81ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/uapi #LP
82ifeq ($(ARCH),arm64)
83ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/uapi/asm-arm64 #LP
84else
85ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/uapi/asm-arm #LP
86endif
87endif
88$(info YD>>>TARGET_ARCH=$(TARGET_ARCH), ARCH=$(ARCH))
89#--yd ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/arch-arm64/include
90ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/arch-$(ARCH)/include
91ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/include
92ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libstdc++/include
93ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/common
94#--yd ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/arch-arm64
95ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libc/kernel/arch-$(ARCH)
96ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm/include
97#--yd ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm/include/arch/arm64
98ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm/include/arch/$(ARCH)
99ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libthread_db/include
100#--yd ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm/arm64
101ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm/$(ARCH)
102ANDROID_INCLUDES += -I$(ANDROID_ROOT)/bionic/libm
103
104ANDROID_INCLUDES += -I$(ANDROID_ROOT)/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates
105#--yd #for Android L--yd
106#--yd ANDROID_INCLUDES += -DHAVE_SYS_UIO_H
107
108
109KERNEL_INCLUDES  = -I$(KERNEL_ROOT)/include
110
111ifeq ($(ARCH),arm)
112KERNEL_INCLUDES  += -I$(KERNEL_ROOT)/arch/arm/include -I$(KERNEL_ROOT)/arch/arm/include/generated
113endif
114
115#--yd KERNEL_INCLUDES  = -I$(KERNEL_ROOT)/include -I$(KERNEL_ROOT)/include/uapi -I$(KERNEL_ROOT)/arch/arm64/include -I$(KERNEL_ROOT)/arch/arm64/include/generated -I$(KERNEL_ROOT)/arch/arm64/include/uapi
116
117INV_INCLUDES  = -I$(INV_ROOT)/software/core/driver/include
118INV_INCLUDES += -I$(MLLITE_DIR)
119INV_INCLUDES += -I$(MLLITE_DIR)/linux
120
121INV_DEFINES += -DINV_CACHE_DMP=1
122
123####################################################################################################
124## macros
125
126ifndef echo_in_colors
127define echo_in_colors
128	echo -ne "\e[1;32m"$(1)"\e[0m"
129endef
130endif
131
132
133
134