On 12/05/2017 18:39, Alex Bennée wrote: > This is slightly clumsy way to ensure the directory structure for the > out-of-tree build is made first. The PHONY target is depended on by > make all first which runs mkdir for all OBJDIRS. > > If an architecture target needs deeper nesting it needs to add > directories to OBJDIRS so it can be picked up by the directories rule. > > Signed-off-by: Alex Bennée <alex.bennee@xxxxxxxxxx> > > --- > v2 > - use explicit PHONY directories target > - use @mkdir > --- > Makefile | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index a8e15b6..881bc78 100644 > --- a/Makefile > +++ b/Makefile > @@ -12,6 +12,7 @@ VPATH = $(SRCDIR) > > libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm") > ARCH_LIBDIRS := $(call libdirs-get,$(ARCH)) $(call libdirs-get,$(TEST_DIR)) > +OBJDIRS := $(ARCH_LIBDIRS) > > DESTDIR := $(PREFIX)/share/kvm-unit-tests/ > > @@ -38,6 +39,8 @@ LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a > LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) > LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION)) > > +OBJDIRS += $(LIBFDT_objdir) > + > #include architecture specific make rules > include $(SRCDIR)/$(TEST_DIR)/Makefile > > @@ -78,12 +81,18 @@ $(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compa > $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) > $(AR) rcs $@ $^ > > + > +# Build directory target > +.PHONY: directories > +directories: > + @mkdir -p $(OBJDIRS) > + > %.o: %.S > $(CC) $(CFLAGS) -c -nostdlib -o $@ $< Could you add a $(shell $(mkdir -p $(@D)) here instead, and a $(shell $(mkdir $(LIBFDT_objdir)) to cater for the nested libfdt makefile? Sorry if I have asked this already. Paolo > > -include */.*.d */*/.*.d > > -all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null) > +all: directories $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null) > > standalone: all > @scripts/mkstandalone.sh >