diff options
| author | Paul Brook <paul@codesourcery.com> | 2012-07-05 04:30:47 +0100 |
|---|---|---|
| committer | Matthijs Kooijman <matthijs@stdin.nl> | 2013-05-30 21:21:54 +0200 |
| commit | 4fdd1765e6db9049b5048dad568954e4c6b6fa21 (patch) | |
| tree | a20b86414cd5a533df2239bbb0b33ec150768015 /arduino-mk | |
| parent | 1f043bb819064d786d106d40ffbff5b92b1a0ced (diff) | |
Rewrite dependency code
Commit originally by: Paul Brook <paul@codesourcery.com>
Port to newer version and commit message by: Matthijs Kooijman <matthijs@stdin.nl>
Instead of generating a big list of dependencies at the start, now
dependency files are generated whenever a .o file is compiled. This
works, since if the .o file does not exist, it should be compiled and
make does not need to know about its dependencies. If the .o (and thus
the .d) file does exist, the .d file contains all the dependencies used
to compile the .o file. If none of those changed, the .o file does not
need a recompile, but also the .d file is still accurate (in particular,
the dependency list cannot change without one of the dependent .h files
or the .cpp file itself changing).
This helps to remove a lot of duplication in the code, since now only a
single commandline is needed for both compilation and dependency
generation. It will probably also run a bit faster now.
Note that this commit breaks the creation of $(OBJDIR) since this
"accidentally" always worked before because $(DEPFILE) was created
before anything else. That will be fixed next.
Diffstat (limited to 'arduino-mk')
| -rw-r--r-- | arduino-mk/Arduino.mk | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8ca4026..30de577 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -710,9 +710,6 @@ TARGET_EEP = $(OBJDIR)/$(TARGET).eep TARGETS = $(OBJDIR)/$(TARGET).* CORE_LIB = $(OBJDIR)/libcore.a -# A list of dependencies -DEP_FILE = $(OBJDIR)/depends.mk - # Names of executables CC = $(AVR_TOOLS_PATH)/avr-gcc CXX = $(AVR_TOOLS_PATH)/avr-g++ @@ -825,54 +822,29 @@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ # normal local sources -# .o rules are for objects, .d for dependency tracking -# there seems to be an awful lot of duplication here!!! COMMON_DEPS := Makefile $(OBJDIR)/%.o: %.c $(COMMON_DEPS) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cc $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.S $(COMMON_DEPS) - $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ $(OBJDIR)/%.o: %.s $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.d: %.c $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.cc $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.cpp $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.S $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.s $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) - # the pde -> o file $(OBJDIR)/%.o: %.pde - $(CXX) -x c++ -include $(PDE_INCLUDE) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ - -# the pde -> d file -$(OBJDIR)/%.d: %.pde - $(CXX) -x c++ -include $(PDE_INCLUDE) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + $(CXX) -x c++ -include $(PDE_INCLUDE) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # the ino -> o file $(OBJDIR)/%.o: %.ino - $(CXX) -x c++ -include Arduino.h -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ - -# the ino -> d file -$(OBJDIR)/%.d: %.ino - $(CXX) -x c++ -include Arduino.h -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + $(CXX) -x c++ -include Arduino.h -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # generated assembly $(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) @@ -966,9 +938,6 @@ $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) -$(DEP_FILE): $(OBJDIR) $(DEPS) - cat $(DEPS) > $(DEP_FILE) - upload: $(TARGET_HEX) verify_size # Use submake so we can guarantee the reset happens # before the upload, even with make -j @@ -1014,10 +983,7 @@ ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size -U lock:w:$(ISP_LOCK_FUSE_POST):m clean: - $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} - -depends: $(DEPS) - $(CAT) $(DEPS) > $(DEP_FILE) + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} size: $(OBJDIR) $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) @@ -1046,6 +1012,4 @@ generated_assembly: $(OBJDIR)/$(TARGET).s .PHONY: all upload raw_upload reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly verify_size # added - in the beginning, so that we don't get an error if the file is not present -ifneq ($(MAKECMDGOALS),clean) --include $(DEP_FILE) -endif +-include $(DEPS) |
