From db741bdfbbbfee10bce6353b5d6ab70baf1cc62d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 8 Aug 2019 17:26:46 -0400 Subject: [PATCH] Makefile: Rename targets for make recursion We make a few sub-directories recursively, in particular $(TARGET_DIRS). For goal "all", we do it the nice way: "all" has a prerequisite subdir-T for each T in $(TARGET_DIRS), and T's recipe runs make recursively. Behaves nicely with -j and -k. For other goals such as "clean" and "install", the recipe runs make recursively in a for loop. Ignores -j and -k. The next commit will fix that for "clean" and "install". This commit prepares the ground by renaming the targets we use for "all" to include the goal for the sub-make. This will permit reusing them for goals other than "all". Targets subdir-T for T in $(TARGET_DIRS) run "make all" in T. Rename to T/all, and declare phony. Targets romsubdir-R for R in $(ROMS) run "make" in pc-bios/R. Default goal is "all" for all R. Rename to pc-bios/R/all, and declare phony. The remainder are renamed just for consistency. Target subdir-dtc runs "make libbft/libfdt.a" in dtc. Rename to dtc/all, and declare phony. Target subdir-capstone runs make $(BUILD_DIR)/capstone/$(LIBCAPSTONE) in $(SRC_PATH)/capstone. Rename to capstone/all, and declare phony. Target subdir-slirp runs "make" in $(SRC_PATH)/slirp. Default goal is all, which builds $(BUILD_DIR)/libslirp.a. Rename to slirp/all, and declare phony. Backports commit 3b8593eeaa5778ae118f0cc2837e615acd13baeb from qemu --- qemu/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qemu/Makefile b/qemu/Makefile index 93566af2..0984a035 100644 --- a/qemu/Makefile +++ b/qemu/Makefile @@ -120,15 +120,16 @@ all: $(TOOLS) $(HELPERS-y) recurse-all modules config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak -SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS)) -SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES)) +SUBDIR_RULES=$(addsuffix /all, $(TARGET_DIRS)) +SOFTMMU_SUBDIR_RULES=$(filter %-softmmu/all,$(SUBDIR_RULES)) $(SOFTMMU_SUBDIR_RULES): $(block-obj-y) $(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y) $(SOFTMMU_SUBDIR_RULES): config-all-devices.mak -subdir-%: - $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,) +.PHONY: $(SUBDIR_RULES) +$(SUBDIR_RULES): + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" all,) $(SUBDIR_RULES): qapi/qapi-types.c qapi/qapi-types.h qapi/qapi-visit.c qapi/qapi-visit.h $(common-obj-y) $(util-obj-y)