aboutsummaryrefslogtreecommitdiff
path: root/tools/build_system
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2018-09-18 15:36:27 +0100
committerronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com>2018-11-14 14:33:49 +0100
commite5ea5d102ab619081e803fb8dc96546fc97f8f45 (patch)
tree3f9dfbb24cbee2fc7cf4b25107830a868dc11ce3 /tools/build_system
parent246f1e75cd3061cf31146bbb7b7f71926a80c45b (diff)
build: Use wildcard-based directory creation rules
The current rule for creating directories does not allow creation of directories through dependencies on demand. This patch moves away from the predefined build directories approach to a more flexible wildcard- based approach. Change-Id: Idfb40a1405a5812973b14a05da3cab183740c1e3 Signed-off-by: Chris Kay <chris.kay@arm.com>
Diffstat (limited to 'tools/build_system')
-rw-r--r--tools/build_system/defs.mk3
-rw-r--r--tools/build_system/firmware.mk8
-rw-r--r--tools/build_system/rules.mk25
3 files changed, 14 insertions, 22 deletions
diff --git a/tools/build_system/defs.mk b/tools/build_system/defs.mk
index 23f2619c..e2442561 100644
--- a/tools/build_system/defs.mk
+++ b/tools/build_system/defs.mk
@@ -82,6 +82,3 @@ endef
define to_upper
$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
endef
-
-.SECONDEXPANSION:
-targetdir := $$(dir $$@)
diff --git a/tools/build_system/firmware.mk b/tools/build_system/firmware.mk
index 88bfb906..40366f5d 100644
--- a/tools/build_system/firmware.mk
+++ b/tools/build_system/firmware.mk
@@ -238,15 +238,17 @@ LDFLAGS_ARM += \
$(LIBS_y) \
$(OBJECTS)
-$(TARGET_ELF): $(LIB_TARGETS_y) $(SCATTER_PP) $(OBJECTS) | $(targetdir)
+.SECONDEXPANSION:
+
+$(TARGET_ELF): $(LIB_TARGETS_y) $(SCATTER_PP) $(OBJECTS) | $$(@D)/
$(call show-action,LD,$@)
$(LD) $(LDFLAGS) -o $@
$(SIZE) $@
-$(SCATTER_PP): $(SCATTER_SRC) | $(targetdir)
+$(SCATTER_PP): $(SCATTER_SRC) | $$(@D)/
$(call show-action,GEN,$@)
$(CC) $(CFLAGS) -E -P -C $< -o $@
-$(TARGET_BIN): $(TARGET_ELF)
+$(TARGET_BIN): $(TARGET_ELF) | $$(@D)/
$(call show-action,BIN,$@)
$(OBJCOPY) $< $(OCFLAGS) $@
diff --git a/tools/build_system/rules.mk b/tools/build_system/rules.mk
index b21eca12..1e39b29b 100644
--- a/tools/build_system/rules.mk
+++ b/tools/build_system/rules.mk
@@ -179,20 +179,11 @@ OBJECTS := $(addprefix $(OBJ_DIR)/, \
$(patsubst %.c,%.o, \
$(SOURCES)))))
-GENERATED_DIRS := $(sort $(BUILD_DIR) \
- $(BUILD_DOC_DIR) \
- $(BUILD_FIRMWARE_DIR) \
- $(dir $(LIB) \
- $(OBJECTS) \
- $(SCATTER_PP) \
- $(SCATTER_SRC) \
- $(TARGET_BIN)))
-
#
# Module code generation
#
.PHONY: gen_module
-gen_module: $(TOOLS_DIR)/gen_module_code.py $(BUILD_FIRMWARE_DIR)
+gen_module: $(TOOLS_DIR)/gen_module_code.py | $(BUILD_FIRMWARE_DIR)/
$(TOOLS_DIR)/gen_module_code.py --path $(BUILD_FIRMWARE_DIR) \
$(FIRMWARE_MODULES_LIST)
@@ -203,32 +194,34 @@ export INCLUDES += $(BUILD_FIRMWARE_DIR)
# Targets
#
+.SECONDEXPANSION:
+
.PHONY: $(LIB_TARGETS_y)
$(LIB_TARGETS_y):
$(MAKE) -C $@
-$(LIB): $(OBJECTS) | $(targetdir)
+$(LIB): $(OBJECTS) | $$(@D)/
$(call show-action,AR,$@)
$(AR) $(ARFLAGS) $@ $(OBJECTS)
-$(OBJ_DIR)/%.o: %.c $(EXTRA_DEP) | $(targetdir)
+$(OBJ_DIR)/%.o: %.c $(EXTRA_DEP) | $$(@D)/
$(call show-action,CC,$<)
$(CC) -c $(CFLAGS) $(DEP_CFLAGS) $< -o $@
-$(OBJ_DIR)/%.o: %.s | $(targetdir)
+$(OBJ_DIR)/%.o: %.s | $$(@D)/
$(call show-action,AS,$<)
$(AS) -c $(ASFLAGS) $(DEP_CFLAGS) $< -o $@
-$(OBJ_DIR)/%.o: %.S | $(targetdir)
+$(OBJ_DIR)/%.o: %.S | $$(@D)/
$(call show-action,AS,$<)
$(AS) -c $(CFLAGS) $(DEP_CFLAGS) $< -o $@
-$(GENERATED_DIRS):
+$(BUILD_PATH)/%/:
$(call show-action,MD,$@)
$(MD) $@
.PHONY: doc
-doc: | $(BUILD_DOC_DIR)
+doc: | $(BUILD_DOC_DIR)/
$(call show-action,DOC,)
$(DOC) $(DOC_DIR)/config.dxy