clean Makefiles

This commit is contained in:
j3d1 2018-10-25 16:21:57 +02:00
parent a0cb1c1395
commit 4218c4102e
3 changed files with 16 additions and 12 deletions

View file

@ -11,3 +11,7 @@ avr:
flash: flash:
@make -f avr.Makefile flash @make -f avr.Makefile flash
clean:
@rm -r build
@echo clean all

View file

@ -171,18 +171,16 @@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf
.SECONDARY: $(TARGET).elf .SECONDARY: $(TARGET).elf
.PRECIOUS: $(OBJ) .PRECIOUS: $(OBJ)
$(OBJDIR)/%.elf: $(OBJ) $(OBJDIR)/%.elf: $(OBJ) | $(OBJDIR)
@echo link $^ @echo link $^
@$(CXX) $(CPU) $^ -o $@ $(LDFLAGS) #-lstdc++ @$(CXX) $(CPU) $^ -o $@ $(LDFLAGS) #-lstdc++
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
@$(shell mkdir -p $(OBJDIR) 2>/dev/null)
@echo compile $< @echo compile $<
@$(CC) -c $(CPU) $(CFLAGS) $< -o $@ @$(CC) -c $(CPU) $(CFLAGS) $< -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
@$(shell mkdir -p $(OBJDIR) 2>/dev/null)
@echo compile $< @echo compile $<
@$(CXX) -c $(CPU) $(CXXFLAGS) $< -o $@ @$(CXX) -c $(CPU) $(CXXFLAGS) $< -o $@
@ -190,15 +188,12 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(OBJDIR)/%.size: $(OBJDIR)/%.elf $(OBJDIR)/%.size: $(OBJDIR)/%.elf
@$(AVRSIZE) -A $< | tee $@ @$(AVRSIZE) -A $< | tee $@
$(OBJDIR):
mkdir -p $(OBJDIR)
clean: clean:
@$(REMOVE) "size"
@$(REMOVE) "$(TARGET).hex"
@$(REMOVE) "$(TARGET).eep"
@$(REMOVE) "$(TARGET).elf"
@$(REMOVE) "$(TARGET).lss"
@$(REMOVEDIR) "$(OBJDIR)" @$(REMOVEDIR) "$(OBJDIR)"
@echo clean $(TARGET) @echo clean $(OBJDIR)
backup: backup:

View file

@ -10,6 +10,7 @@ OBJDIR = build/linux
SRC_PATH = $(SRC:%=$(SRCDIR)/%) SRC_PATH = $(SRC:%=$(SRCDIR)/%)
OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o) OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
REMOVEDIR = rm -rf
CFLAGS += -std=gnu99 CFLAGS += -std=gnu99
CXXFLAGS += -std=c++17 CXXFLAGS += -std=c++17
@ -26,6 +27,7 @@ all: $(OBJDIR)/$(TARGET)
.SECONDARY: $(TARGET) .SECONDARY: $(TARGET)
.PRECIOUS: $(OBJ) .PRECIOUS: $(OBJ)
$(OBJDIR)/$(TARGET): $(OBJ) | $(OBJDIR) $(OBJDIR)/$(TARGET): $(OBJ) | $(OBJDIR)
@echo link $^
@$(CXX) -o $@ $^ @$(CXX) -o $@ $^
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
@ -36,6 +38,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
@echo compile $< @echo compile $<
@$(CXX) -c $(CXXFLAGS) $< -o $@ @$(CXX) -c $(CXXFLAGS) $< -o $@
$(OBJDIR): $(OBJDIR):
mkdir -p $(OBJDIR) mkdir -p $(OBJDIR)
clean:
@$(REMOVEDIR) "$(OBJDIR)"
@echo clean $(OBJDIR)