diff --git a/Makefile b/Makefile index 7b5327e..a368d0c 100644 --- a/Makefile +++ b/Makefile @@ -11,3 +11,7 @@ avr: flash: @make -f avr.Makefile flash + +clean: + @rm -r build + @echo clean all diff --git a/avr.Makefile b/avr.Makefile index 69cfaa4..e88adf6 100644 --- a/avr.Makefile +++ b/avr.Makefile @@ -171,18 +171,16 @@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf .SECONDARY: $(TARGET).elf .PRECIOUS: $(OBJ) -$(OBJDIR)/%.elf: $(OBJ) +$(OBJDIR)/%.elf: $(OBJ) | $(OBJDIR) @echo link $^ @$(CXX) $(CPU) $^ -o $@ $(LDFLAGS) #-lstdc++ -$(OBJDIR)/%.o: $(SRCDIR)/%.c - @$(shell mkdir -p $(OBJDIR) 2>/dev/null) +$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) @echo compile $< @$(CC) -c $(CPU) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: $(SRCDIR)/%.cpp - @$(shell mkdir -p $(OBJDIR) 2>/dev/null) +$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR) @echo compile $< @$(CXX) -c $(CPU) $(CXXFLAGS) $< -o $@ @@ -190,15 +188,12 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.size: $(OBJDIR)/%.elf @$(AVRSIZE) -A $< | tee $@ +$(OBJDIR): + mkdir -p $(OBJDIR) clean: - @$(REMOVE) "size" - @$(REMOVE) "$(TARGET).hex" - @$(REMOVE) "$(TARGET).eep" - @$(REMOVE) "$(TARGET).elf" - @$(REMOVE) "$(TARGET).lss" @$(REMOVEDIR) "$(OBJDIR)" - @echo clean $(TARGET) + @echo clean $(OBJDIR) backup: diff --git a/linux.Makefile b/linux.Makefile index 908d973..cbf6f30 100644 --- a/linux.Makefile +++ b/linux.Makefile @@ -10,6 +10,7 @@ OBJDIR = build/linux SRC_PATH = $(SRC:%=$(SRCDIR)/%) OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o) +REMOVEDIR = rm -rf CFLAGS += -std=gnu99 CXXFLAGS += -std=c++17 @@ -26,6 +27,7 @@ all: $(OBJDIR)/$(TARGET) .SECONDARY: $(TARGET) .PRECIOUS: $(OBJ) $(OBJDIR)/$(TARGET): $(OBJ) | $(OBJDIR) + @echo link $^ @$(CXX) -o $@ $^ $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) @@ -36,6 +38,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR) @echo compile $< @$(CXX) -c $(CXXFLAGS) $< -o $@ - $(OBJDIR): mkdir -p $(OBJDIR) + +clean: + @$(REMOVEDIR) "$(OBJDIR)" + @echo clean $(OBJDIR)