Servus,
ich hab mir ein eigenes Makefile geschrieben, dass automatisch alle *.c Dateien im Ordner kompiliert, linkt und via AVR-Dude an meinen uC überträgt. Es funktioniert auch einwandfrei, bis auf dass es nach erfolgreichem Senden alle *.o Dateien löscht.
Ich unterdrücke alle ausgaben in der BASH durch ein @ und meine "clear" Regel löscht nicht nur die *.o Dateien, sondern auch die *.elf und *.hex Dateien.
Trotzdemg gibt das Makefile zum Schluss z.B. folgendes aus:
Und ich weiß nicht wo dieses rm herkommt und warum es nur die *.o Dateien löscht?Code:rm portexpander.o main.o multiplex.o
Hier noch mein Makefile:
Code:### GCC SETTINGS # MCU name MCU = atmega8 # Processor speed F_CPU = 1000000 # Target TARGET = AVR # Sourcefiles SCR = $(wildcard *.c) # Objectfiles OBJ = $(patsubst %.c, %.o, $(SCR)) # Optimization level, OPT = s # Compiler Flags CFLAGS = -g CFLAGS += -c CFLAGS += -O$(OPT) CFLAGS += -DF_CPU=$(F_CPU) CFLAGS += -mmcu=$(MCU) # Linker Flags LFLAGS = LFLAGS += -mmcu=$(MCU) # Objcopy Flags OBJCOPY_FLAGS = OBJCOPY_FLAGS += -j .text -j .data OBJCOPY_FLAGS += -O ihex ### AVRDUDE SETTINGS # programming hardware AVRDUDE_PROGRAMMER = ponyser # MCU name AVRDUDE_MCU = m8 # Port AVRDUDE_PORT = /dev/ttyS0 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex # Flags AVRDUDE_FLAGS = AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) AVRDUDE_FLAGS += -p $(AVRDUDE_MCU) AVRDUDE_FLAGS += -q -q ### DEFINE PROGRAMS AND COMMANDS SUPRESS = @ COMPILER = $(SUPRESS)avr-gcc OBJCOPY = $(SUPRESS)avr-objcopy AVRDUDE = $(SUPRESS)avrdude REMOVE = $(SUPRESS)rm -f ECHO = $(SUPRESS)echo CLEAR = $(SUPRESS)clear ### DEFINE MESSAGES MSG_BEGIN = "Simple AVR Makefile\n\nwritten by Icon\nuses avr-gcc and avrdude.\n" MSG_END = "Makefle Completed! Thank you for using and have a nice day!\n" MSG_SEND = "Sending $(TARGET).hex to the device ($(MCU))" MSG_COMPILE = "Compiling:" MSG_LINK = "Linking:" MSG_OBJCOPY = "Creating .hex-File:" MSG_DELETE = "Deleting $(OBJ), $(TARGET).elf and $(TARGET).hex" MSG_DONE = "Done!\n" ### RULES .PHONY: all all: begin gcc_version build send end .PHONY: fall fall: force_all .PHONY: force_all force_all: begin gcc_version clear build send end .PHONY: fbuild fbuild: force_build .PHONY: force_build force_build: begin gcc_version clear build end .PHONY: build build: hex elf .PHONY: hex hex: $(TARGET).hex .PHONY: elf elf: $(TARGET).elf .PHONY: begin begin: $(CLEAR) $(ECHO) $(MSG_BEGIN) .PHONY: end end: $(ECHO) $(MSG_END) .PHONY: gcc_version gcc_version: $(COMPILER) --version %.hex : %.elf $(ECHO) $(MSG_OBJCOPY) $@ $(OBJCOPY) $< $@ $(OBJCOPY_FLAGS) $(ECHO) $(MSG_DONE) %.elf : $(OBJ) $(ECHO) $(MSG_LINK) $(OBJ) $(COMPILER) $(OBJ) -o $@ $(LFLAGS) $(ECHO) $(MSG_DONE) %.o : %.c $(ECHO) $(MSG_COMPILE) $< $(COMPILER) $< -o $@ $(CFLAGS) $(ECHO) $(MSG_DONE) .PHONY: send send: $(TARGET).hex $(ECHO) $(MSG_SEND) $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(ECHO) $(MSG_DONE) .PHONY: clear clear: $(ECHO) $(MSG_DELETE) $(REMOVE) $(OBJ) $(TARGET).elf $(TARGET).hex $(ECHO) $(MSG_DONE)







Zitieren

Lesezeichen