Gast
#40733
Hi, bei dem folgenden Makefile habe ich das Problem, dass stets alles übersetzt wird. Die Make-Doku kenne ich mittlerweile fast auswendig. Die Ursache für die unnötigen Programmabläufe habe ich leider bis jetzt noch nich entdecken können. Für einen Tip wäre ich sehr dankbar. mfg Peter # AVR-GCC Makefile #************************************************************** .SUFFIXES: .SUFFIXES: .S .c .o .cof .elf .eep .rom #--- define some variables based on the AVR base path in $(AVR) CC = avr-gcc AS = avr-gcc RM = rm -f RN = mv CP = cp BIN = avr-objcopy ELFCOF = objtool INCDIR = . INCLUDES = Standard_Include.h Zentrale_Types.h Zentrale_Common.h OBJECTS = Zentrale_Main.o Zentrale_Lcd.o Zentrale_Common.o Zentrale_Uart.o Zentrale_Rtc.o Zentrale_Can.o #If all other steps compile ok then echo "Errors: none". #Necessary for AVR Studio to understand that everything went ok. DONE = @echo Errors: none #--- default mcu type MCU = atmega16 #--- default compiler flags -ahlmsn CPFLAGS = -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -mmcu=$(MCU) -Wa,-ahlmsnd=$(<:.c=.lst) #--- default assembler flags ASFLAGS = -mmcu=$(MCU) -Wa,-mmcu=$(MCU),-gstabs #--- default linker flags LDFLAGS = -Wl,-Map=$(<:.o=.map),--cref -mmcu=$(MCU) #--- output format can be srec (Motorola), ihex (Intel HEX) ROMFORMAT = ihex #<========== wichtig, Zentrale_Main.rom ist ein Hexfile !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EEPROMFORMAT = ihex # AVR Studio needs Intel HEX format #--- compile: instructions to create assembler and/or object files from C source %o : %c $(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@ %s : %c $(CC) -s $(CPFLAGS) -I$(INCDIR) $< -o $@ #--- assemble: instructions to create object file from assembler source %o : %S $(AS) -x assembler-with-cpp $(ASFLAGS) -I$(INCDIR) -c $< -o $@ #--- link: instructions to create elf output file from object files %elf: %o $(CC) $^ $(LIB) $(LDFLAGS) -o $@ #--- create AVR Studio cof file from elf output file and map file #%cof: %elf # $(ELFCOF) loadelf $^ mapfile $(<:.elf=.map) writecof $@ #--- create flash and eeprom bin file (ihex, srec) from elf output file %rom: %elf $(BIN) -O $(ROMFORMAT) -R .eeprom $< $@ #%eep: %elf # $(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(EEPROMFORMAT) $< $(@:.elf=.eep) #If all other steps compile ok then echo "Errors: none". #Necessary for AVR Studio to understand that everything went ok. #%ok: # $(DONE) # @echo "Errors: none" # .PHONY : begin # begin: all .PHONY : all #.phony: clean #clean: # $(RM) *.rom # $(RM) *.eep # $(RM) *.cof # $(RM) *.elf # $(RM) *.o # $(RM) *.lst # $(RM) *.map #----------------------------------------------------------------------- ----------------- #--- this defines the aims of the make process all: Zentrale_Main.rom $(DONE) Zentrale_Main.rom: Zentrale_Main.elf Zentrale_Main.elf: $(OBJECTS) Zentrale_Main.o: Zentrale_Main.c $(INCLUDES) Zentrale_Lcd.o: Zentrale_Lcd.c Zentrale_Lcd.h $(INCLUDES) Zentrale_Common.o: Zentrale_Common.c Zentrale_Common.h $(INCLUDES) Zentrale_Uart.o: Zentrale_Uart.c Zentrale_Uart.h $(INCLUDES) Zentrale_Rtc.o: Zentrale_Rtc.c Zentrale_Rtc.h $(INCLUDES) Zentrale_Can.o: Zentrale_Can.c Zentrale_Can.h $(INCLUDES) #----------------------------------------------------------------------- -----------------