TARGET := main.elf FLASHDEV := /dev/ttyUSB0 CXXFLAGS := -g -Os -Wall -mmcu=msp430f1111a CXX := msp430-gcc LIBS := EXT := c BUILDDIR := build override BUILDDIR := $(strip $(BUILDDIR)) SOURCES := $(wildcard *.$(EXT)) OBJECTS := $(patsubst %.$(EXT), $(BUILDDIR)/%.o, $(SOURCES)) DEPS := $(patsubst %.$(EXT), $(BUILDDIR)/%.dep, $(SOURCES)) .PHONY: all all: compile compile: $(TARGET) $(TARGET): $(OBJECTS) $(DEPS) $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) ifneq ($(MAKECMDGOALS), clean) -include $(DEPS) endif $(OBJECTS): $(BUILDDIR)/%.o: %.$(EXT) $(BUILDDIR)/%.dep $(BUILDDIR)/.tag $(CXX) $(CXXFLAGS) -c $< -o $@ $(DEPS): $(BUILDDIR)/%.dep: %.$(EXT) $(BUILDDIR)/.tag mkdir -p $(dir $(@)) $(CXX) $(CXXFLAGS) -MM $< -MT $@ -MT $(<:.$(EXT)=.o) -o $@ %.tag: mkdir -p $(dir $(@)) touch $@ flash: compile hex msp430-bsl.py -e -P -r -p $(FLASHDEV) main.hex --invert-reset --swap-reset-test hex: compile msp430-objcopy -O ihex $(TARGET) main.hex .PHONY: clean clean: $(RM) -r $(BUILDDIR) *.elf *.hex