From 0c2d5e70f9fc533395811687350f67bf0adca6bb Mon Sep 17 00:00:00 2001 From: Thomas Dickerson Date: Thu, 4 Feb 2016 18:09:20 -0500 Subject: [PATCH] Increase subdirectory portability This allows us to, for example, portably include files from subdirectories: SOURCES = $(wildcard *.c) $(subst /,\,$(wildcard */*.c)) (note: if your shell supports "globstar" you can use `**/*.c` to recursively include from subdirectories) --- CEdev/examples/template/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CEdev/examples/template/Makefile b/CEdev/examples/template/Makefile index b55055cd2..dbcc3c9a0 100644 --- a/CEdev/examples/template/Makefile +++ b/CEdev/examples/template/Makefile @@ -1,4 +1,6 @@ +REALWINPATH = $(subst /,\,$(realpath $(1))) CEDEV ?= .. +CEDEV := $(call REALWINPATH,$(CEDEV)) BIN = $(CEDEV)\bin INCLUDE = $(CEDEV)\include WORKDIR ?= src @@ -43,7 +45,8 @@ $(TARGET).hex : $(OBJECTS) $(STARTUPMODULE) $(LIBRARIES) $(CV) $(@:%.8xp=%) %.obj : %.c - $(CC) $(CFLAGS) $< + cd $(dir $@) && \ + $(CC) $(CFLAGS) $(notdir $<) %.obj : %.asm $(CC) $(CFLAGS) $< @@ -51,4 +54,4 @@ $(TARGET).hex : $(OBJECTS) $(STARTUPMODULE) $(LIBRARIES) clean : $(RM) $(wildcard *.src *.obj $(TARGET).*) -.PHONY : all clean \ No newline at end of file +.PHONY : all clean