1 EXEC = inv_self_test$(SHARED_APP_SUFFIX) 2 3 MK_NAME = $(notdir $(CURDIR)/$(firstword $(MAKEFILE_LIST))) 4 5 # ANDROID version check 6 BUILD_ANDROID_LOLLIPOP = $(shell test -d $(ANDROID_ROOT)/bionic/libc/kernel/uapi && echo 1) 7 $(info YD>>BUILD_ANDROID_LOLLIPOP = $(BUILD_ANDROID_LOLLIPOP)) 8 #ANDROID version check END 9 10 ifeq ($(BUILD_ANDROID_LOLLIPOP),1) 11 CFLAGS += -DANDROID_LOLLIPOP 12 else 13 CFLAGS += -DANDROID_KITKAT 14 endif 15 16 #--yd CROSS ?= $(ANDROID_ROOT)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- 17 COMP ?= $(CROSS)gcc 18 LINK ?= $(CROSS)gcc 19 20 OBJFOLDER = $(CURDIR)/obj 21 22 INV_ROOT = ../../../../.. 23 APP_DIR = $(CURDIR)/../.. 24 MLLITE_DIR = $(INV_ROOT)/software/core/mllite 25 COMMON_DIR = $(INV_ROOT)/software/simple_apps/common 26 MPL_DIR = $(INV_ROOT)/software/core/mpl 27 HAL_DIR = $(INV_ROOT)/software/core/HAL 28 29 include $(INV_ROOT)/software/build/android/common.mk 30 31 CFLAGS += $(CMDLINE_CFLAGS) 32 CFLAGS += $(ANDROID_COMPILE) 33 CFLAGS += -Wall 34 ifeq ($(BUILD_ANDROID_LOLLIPOP),1) 35 else 36 CFLAGS += -fpic 37 endif 38 CFLAGS += -nostdlib 39 CFLAGS += -DNDEBUG 40 CFLAGS += -D_REENTRANT 41 CFLAGS += -DLINUX 42 CFLAGS += -DANDROID 43 ifeq ($(ARCH),arm) 44 CFLAGS += -mthumb-interwork 45 endif 46 CFLAGS += -fno-exceptions 47 CFLAGS += -ffunction-sections 48 CFLAGS += -funwind-tables 49 CFLAGS += -fstack-protector 50 CFLAGS += -fno-short-enums 51 CFLAGS += -fmessage-length=0 52 CFLAGS += -I$(MLLITE_DIR) 53 CFLAGS += -I$(MPL_DIR) 54 CFLAGS += -I$(COMMON_DIR) 55 CFLAGS += -I$(HAL_DIR)/include 56 CFLAGS += $(INV_INCLUDES) 57 CFLAGS += $(INV_DEFINES) 58 59 LLINK = -lc 60 LLINK += -lm 61 LLINK += -lutils 62 LLINK += -lcutils 63 LLINK += -lgcc 64 LLINK += -ldl 65 LLINK += -lstdc++ 66 LLINK += -llog 67 LLINK += -lz 68 69 LFLAGS += $(CMDLINE_LFLAGS) 70 LFLAGS += $(ANDROID_LINK_EXECUTABLE) 71 ifeq ($(ARCH),arm64) 72 LRPATH = -Wl,-rpath,$(ANDROID_ROOT)/out/target/product/$(PRODUCT)/obj/lib 73 else 74 LRPATH = -Wl,-rpath,$(ANDROID_ROOT)/out/target/product/$(PRODUCT)/obj/lib:$(ANDROID_ROOT)/out/target/product/$(PRODUCT)/system/lib 75 endif 76 77 #################################################################################################### 78 ## sources 79 80 INV_LIBS = $(MPL_DIR)/build/$(TARGET)/$(LIB_PREFIX)$(MPL_LIB_NAME).$(SHARED_LIB_EXT) 81 INV_LIBS += $(MLLITE_DIR)/build/$(TARGET)/$(LIB_PREFIX)$(MLLITE_LIB_NAME).$(SHARED_LIB_EXT) 82 83 #INV_SOURCES and VPATH provided by Makefile.filelist 84 include ../filelist.mk 85 86 INV_OBJS := $(addsuffix .o,$(INV_SOURCES)) 87 INV_OBJS_DST = $(addprefix $(OBJFOLDER)/,$(addsuffix .o, $(notdir $(INV_SOURCES)))) 88 89 #################################################################################################### 90 ## rules 91 92 .PHONY: all clean cleanall install 93 94 all: $(EXEC) $(MK_NAME) 95 96 $(EXEC) : $(OBJFOLDER) $(INV_OBJS_DST) $(INV_LIBS) $(MK_NAME) 97 @$(call echo_in_colors, "\n<linking $(EXEC) with objects $(INV_OBJS_DST) $(PREBUILT_OBJS) and libraries $(INV_LIBS)\n") 98 $(LINK) $(INV_OBJS_DST) -o $(EXEC) $(LFLAGS) $(LLINK) $(INV_LIBS) $(LLINK) $(LRPATH) 99 100 $(OBJFOLDER) : 101 @$(call echo_in_colors, "\n<creating object's folder 'obj/'>\n") 102 mkdir obj 103 104 $(INV_OBJS_DST) : $(OBJFOLDER)/%.c.o : %.c $(MK_NAME) 105 @$(call echo_in_colors, "\n<compile $< to $(OBJFOLDER)/$(notdir $@)>\n") 106 $(COMP) $(ANDROID_INCLUDES) $(KERNEL_INCLUDES) $(INV_INCLUDES) $(CFLAGS) -o $@ -c $< 107 108 clean : 109 rm -fR $(OBJFOLDER) 110 111 cleanall : 112 rm -fR $(EXEC) $(OBJFOLDER) 113 114 install : $(EXEC) 115 cp -f $(EXEC) $(INSTALL_DIR) 116 117 118