1# -*- makefile -*- 2# 3# This makefile template should be included by makefiles in 4# program directories. 5# 6 7# Set the directory for the local sources 8LOCAL_SRCDIR := $(abspath $(LOCAL_PATH)/$(SRCDIR)) 9LOCAL_INCSRCDIR := $(abspath $(LOCAL_PATH)/$(INCSRCDIR)) 10 11OBJDIR := $(patsubst $(SRC_ROOT)/%,$(BUILD_ROOT)/%,$(abspath $(LOCAL_PATH)/$(OUTPUT_DIR_COMPONENT))) 12 13$(eval $(call set-src-and-obj-names,$(SRCS),$(LOCAL_SRCDIR))) 14 15ifneq ($(strip $(FORCED_OBJS)),) 16 # The point of this dependency is to force object rebuilds when the 17 # corresponding dependency files are missing (even if the object file exists). 18 $(FORCED_OBJS): FORCE 19endif 20 21 22ifneq "$(MAKECMDGOALS)" "clean" 23 ifneq ($(strip $(FOUND_DEPS)),) 24# $(warning Including $(FOUND_DEPS)) 25 -include $(FOUND_DEPS) 26 endif 27endif 28 29ifeq ($(strip $(DEFAULT_LIBMODE)),release) 30 XCXXFLAGS+=$(OPT_CXXFLAG) 31 XCXXFLAGS+=$(RELEASE_CXXFLAGS) 32 XCPPFLAGS+=$(RELEASE_CPPFLAGS) 33else 34 XCPPFLAGS+=$(DEBUG_CPPFLAGS) 35 XCXXFLAGS+=$(DEBUG_CXXFLAGS) 36endif 37 38LOCAL_XINCDIRS := $(abspath $(patsubst ../%,$(LOCAL_PATH)/../%,$(patsubst -I%,%,$(XINCDIRS)))) 39 40LOCAL_TOTAL_INCDIRS := $(LOCAL_SRCDIR) $(LOCAL_INCSRCDIR) $(LOCAL_XINCDIRS) 41 42$(COMPILED_OBJS): XFLAGS := $(XCPPFLAGS) $(patsubst %,-I%,$(LOCAL_TOTAL_INCDIRS)) $(XCXXFLAGS) 43 44# remove any leading / trailing whitespace 45TARGET := $(strip $(TARGET)) 46 47# save compiled objects in a macro 48$(TARGET)_compiled_objs := $(COMPILED_OBJS) 49 50ifneq ($(strip $(REMOTE_DIRS)),) 51# $(info remote dirs = $(REMOTE_DIRS)) 52$(foreach srcdir, $(strip $(REMOTE_DIRS)), $(eval $(call OBJ_TEMPLATE,$(srcdir),$(OBJDIR)))) 53endif 54 55 56$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.cpp 57 $(call make-cpp-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS)) 58 59$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.c 60 $(call make-c-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS)) 61 62 63#ifeq ($(HOST_ARCH), win32) 64# vpath %.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%) 65# vpath %.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%) 66#else 67# vpath lib%.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%) 68# vpath lib%.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%) 69#endif 70 71LOCAL_LIBDIRS := $(abspath $(patsubst ../%,$(LOCAL_PATH)/../%,$(patsubst $(LIBCOMPFLAG)%,%,$(XLIBDIRS)))) 72 73LOCAL_LIBDIRS := $(patsubst %,$(LIBCOMPFLAG)%,$(LOCAL_LIBDIRS)) $(LIB_DIRS) 74 75 76REALTARGET := $(TARGET:%=$(BUILD_ROOT)/bin/$(OUTPUT_DIR_COMPONENT)/%$(TARGET_EXT)) 77 78TMPDEPS := $(patsubst %,$$(%_fullname),$(LIBS)) 79 80$(eval $(TARGET)_LIBDEPS := $(TMPDEPS)) 81 82$(TARGET)_LDFLAGS := $(LOCAL_LIBDIRS) $($(TARGET)_LIBDEPS) $(LDFLAGS) $(XLDFLAGS) 83 84$(REALTARGET): $(COMPILED_OBJS) $($(TARGET)_LIBDEPS) 85 @echo Building $@ 86 $(call create_objdir,$(@D)) 87 $(call generate_prog,$@,$(notdir $@)) 88 @echo DONE building $@. 89 90ALL_BIN_INSTALLED: $(REALTARGET) 91 92# Pseudo-targets for executables. With this, we can use "make $(TARGET)" instead of "make $(BUILD_ROOT)/bin/$(OUTPUT_DIR_COMPONENT)/%$(TARGET_EXT)" 93# # E.g., make pvplayer_engine_test 94$(TARGET): $(REALTARGET) 95 96.PRECIOUS:: $(DEPS) $(COMPILED_OBJS) 97 98TARGET_TYPE := prog 99 100-include $(PLATFORM_EXTRAS) 101 102TARGET_LIST := $(TARGET_LIST) $(TARGET) 103 104run_$(TARGET)_TEST_ARGS := $(TEST_ARGS) 105run_$(TARGET)_SOURCE_ARGS := $(SOURCE_ARGS) 106run_$(TARGET)_SOURCE_DIR := $(LOCAL_PATH) 107 108###incluede targest for test apps########### 109run_$(TARGET): $(REALTARGET) 110 $(call cd_and_run_test,$($@_SOURCE_DIR),$<,$($@_TEST_ARGS),$($@_SOURCE_ARGS)) 111 112run_test: run_$(TARGET) 113build_$(TARGET): $(REALTARGET) 114build_test: build_$(TARGET) 115