1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
   |  ifeq ($(IN_TARGET), ) $(error not define compile target) endif
  ifeq ($(IN_TARGET_SRC_PATH), ) $(error not define compile target src dir) endif
  ifeq ($(IN_TARGET_OBJ_PATH), ) $(error not define compile target obj dir) endif
 
 
 
 
 
 
  TARGET_SRC_DIR := $(abspath $(IN_TARGET_SRC_PATH))
 
  TARGET_OBJ_DIR := $(abspath $(IN_TARGET_OBJ_PATH))
 
  TARGET_SRC_DIRS := $(shell find $(TARGET_SRC_DIR) -maxdepth 6 -type d)
 
 
 
 
 
  FILTER_FILES := $(foreach dir, $(TARGET_SRC_DIRS), $(dir)/filter.mk) sinclude $(FILTER_FILES)
 
  FILTER_OUT_OBJ := $(foreach dir_name, $(filter-y), $(shell find $(TARGET_SRC_DIR) -name $(dir_name))) FILTER_OUT_DIRS := $(foreach dir, $(FILTER_OUT_OBJ), $(shell find $(dir) -type d))
 
  COMPILE_DIRS := $(abspath $(filter-out $(FILTER_OUT_DIRS), $(TARGET_SRC_DIRS)))
 
  COMPILE_INC_DIRS := $(foreach dir,$(COMPILE_DIRS), -I$(dir)) export IN_COMP_INC_DIR := $(COMPILE_INC_DIRS)
 
  COMPILE_CSRCS := $(foreach dir, $(COMPILE_DIRS), $(wildcard $(dir)/*.c)) COMPILE_CPPSRCS := $(foreach dir, $(COMPILE_DIRS), $(wildcard $(dir)/*.cpp))
 
  COMPILE_CSRC_DIRS := $(filter $(abspath $(dir $(COMPILE_CSRCS))), $(COMPILE_DIRS))
  COMPILE_CPPSRC_DIRS := $(filter $(abspath $(dir $(COMPILE_CPPSRCS))), $(COMPILE_DIRS)) COMPILE_TARGET_DIRS += $(filter-out $(COMPILE_CPPSRC_DIRS), $(COMPILE_CSRC_DIRS)) COMPILE_TARGET_DIRS += $(COMPILE_CPPSRC_DIRS)
 
  COMPILE_RELATIVE_PATHS  := $(foreach path, $(foreach dir,$(COMPILE_TARGET_DIRS), $(subst $(abspath $(TARGET_SRC_DIR)/../),, $(dir))), \ 								$(subst /$(notdir $(TARGET_SRC_DIR))/,/./, $(path)/))
 
  BUILD_TARGET_DIRS := $(subst $(TARGET_SRC_DIR)/,$(TARGET_OBJ_DIR)/, $(COMPILE_TARGET_DIRS))
 
  COMPILE_CSRC_FILES := $(notdir $(COMPILE_CSRCS)) COMPILE_CPPSRC_FILES := $(notdir $(COMPILE_CPPSRCS))
  BUILD_OBJ_FILES += 	$(foreach src, $(COMPILE_CSRC_FILES), \ 						$(foreach dir, $(COMPILE_DIRS), $(subst $(TARGET_SRC_DIR)/,$(TARGET_OBJ_DIR)/, \ 							$(firstword $(subst .c,.o,$(wildcard $(dir)/$(src))))))) 							 BUILD_OBJ_FILES += 	$(foreach src, $(COMPILE_CPPSRC_FILES), \ 						$(foreach dir, $(COMPILE_DIRS), $(subst $(TARGET_SRC_DIR)/,$(TARGET_OBJ_DIR)/, \ 							$(firstword $(subst .cpp,.o,$(wildcard $(dir)/$(src)))))))
  target_build: target_check_dir target_build_objs $(IN_TARGET)
  target_check_dir: 	@if [ ! -d $(IN_TARGET_OBJ_PATH) ]; then \ 		mkdir -p $(IN_TARGET_OBJ_PATH) -m 777; \ 	fi 	@for dir in $(BUILD_TARGET_DIRS); do \ 		if [ ! -d $$dir ]; then \ 			mkdir -p $$dir -m 777; \ 		fi; \ 	done
  target_build_objs: 	@printf "*******************************************\n" 	@printf "* Compiles   [%-12s/*] source file *\n" $(notdir $(TARGET_SRC_DIR)) 	@printf "*******************************************\n" 	$(QUIET)for rpath in $(COMPILE_RELATIVE_PATHS); do $(MAKE) $(MAKEFLAG) -f $(COMPILE_FILE) \ 		IN_COMP_SRC_DIR=$(TARGET_SRC_DIR)$${rpath} \ 		IN_COMP_OBJ_DIR=$(TARGET_OBJ_DIR)$${rpath} \ 		|| exit $$? ; done 	@printf "*******************************************\n" 	@printf "* Completion [%-12s/*] object file *\n" $(notdir $(TARGET_OBJ_DIR)) 	@printf "*******************************************\n" 	 $(IN_TARGET):$(BUILD_OBJ_FILES)
 
  |