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) #----------------------------------------------------------------------- -----------------
Die Abhängigkeit %elf: %o finde ich ziemlich lausig formuliert. Überhaupt ist mir nicht so ganz klar, warum die Leute offenbar den GNUismus %foo: %bar anstelle der generischen Variante mittels .SUFFIXES und .foo: .bar bevorzugen. Ansonsten sollte es irgendwelche Debug-Optionen geben, die Dir die Abhängigkeitsbehandlung der einzelnen Targets näher erläutern.
Hallo Joerg, Deine philosophischen Betrachtungen haben mir leider nicht weiter geholfen. Die Debug - Möglichkeiten hatte ich bereits vorher genutzt. Meldungen wie: pruning xxx.c, xxx.c older than xxx.o waren mir allerdings unerklärlich, da die C-Files einen älteren Timestamp aufwiesen als die O-Files. Die Lösung war aber an sich ganz einfach: make muss in diesem Fall nicht mit make sondern mit make all aufgerufen werden und schon werden die Abhängikeiten korrekt bearbeitet. mfg Peter
Verstehe zwar nicht warum (ich hatte versucht herauszufinden, ob "all:" nicht das erste Target ist), aber das ist ein bißchen die Folge dieses ``obfuscated'' Makefiles: man weiß gar nicht so recht, was nun wirklich das default target ist... Offenbar ist es aus irgendwelchen Gründen nicht "all", aber ich finde es auch nicht raus (das Webformular zerschrummst das Makefile hinreichend -- Du hättest es besser als Upload machen sollen).
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.