From 4e6c776425fbaf7e653935ceddd956b45eb0b7e2 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 13 Jun 2013 23:05:57 +0200 Subject: [PATCH] Fix directory creation for library source files In commit 3bce1d88 (Allow adding extra common dependencies), the way $(OBJDIR) was created changed. Instead of having some ad-hoc mkdir calls around, all relevant rules were made to depend on the directory instead. However, this change didn't take into account that the object files for libraries live instead a subdirectory of $(OBJDIR), which was no longer automatically created. This made compilation of all libraries fail, on a clean build directory. Fixing the rules to depend on $(dir $@) or $(dir %) doesn't work, since those function calls are expanded by making upon reading the file, not later when the rule is actually matched. Therefore, this commit restores the previous explicit mkdir calls for library object files. The non-library objects files, which do not live in a subdirectory, still use the dependency approach as before. Fixes: #58 --- arduino-mk/Arduino.mk | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index efa3bd6..7b281b7 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -706,16 +706,20 @@ $(call show_separator) # easy to change the build options in future # library sources -$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c | $(OBJDIR) +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c + mkdir -p $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp | $(OBJDIR) +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp + mkdir -p $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp | $(OBJDIR) +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp + mkdir -p $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c | $(OBJDIR) +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c + mkdir -p $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ ifdef COMMON_DEPS