Skript file: /~heha/ewa/Reluktanzmotor/firmware.zip/makefile

# Makefile für ATmega32U4-Firmware auf eHaJo ATmega32U4-Display-Adapter
# für Reluktanzmotor → Durchflussmesser → Frequenzzähler
# Henrik Haftmenn, 180713
P = FZ
D = atmega32u4
F = 16000000

# Diese Zeile schaltet auf avr-gcc-4.9.2 um (je nach Installation),
# beim Auskommentieren gilt der normale Suchpfad (hier WinAVR-2010)
PATH := c:\programs\WinAVR\gcc492\bin;$(PATH)

# Compiler und Linker:
C = avr-gcc -Wall -Wno-parentheses -Wno-array-bounds -Wno-char-subscripts -Os -mmcu=$D -fshort-enums -Wno-strict-aliasing -D F_CPU=$F
# -D DEBUG
#no-parentheses: Ich weiß selbst wo Klammern nötig sind
#no-array-bounds: Flash-Stringadressen nicht im Flash (0..7FFF)
#no-char-subscripts: Bytes als Array-Indizes sind okay für kleine Arrays

all: $P.hex $P.lst

.c.o .S.o: makefile
	$C -c -o $@ $<

# Alle C++-Dateien sind (der Einfachheit halber) von allen Kopfdateien abhängig
%.o: %.cpp *.h makefile
	$C -std=c++11 -c -o $@ $<

$P.elf: main.o usb.o
	$C -o $@ $^
# Das alte avr-size aufheben! Das neue kann kein -C
	avr-size -C --mcu=$D $@

$P.hex: $P.elf
	avr-objcopy -j .text -j .data -O ihex $< $@

$P.lst: $P.elf
	avr-objdump -d -t $< > $@

# via 4K-Atmel-Urlader (beim eHaJo-Board vorhanden)
flash: $P.hex
	dfu-programmer $D erase --force --suppress-validation
	dfu-programmer $D flash --force --suppress-validation $<
	dfu-programmer $D launch

clean:
	rm *.o

# via 2K-Arduino-Urlader (bei allen Arduinos) — viel langsamer
flash-arduino: $P.hex
	avrdude -p m32u4 -P lpt1 -c arduino -U f:w:$<

#	sc start giveio
#	avrdude -p m32u4 -P lpt1 -c pony-stk200 -U f:w:ATMega32U4-usbdevice_dfu-1_0_0.hex -U lfuse:w:0x5E:m -U hfuse:w:0x99:m -U efuse:w:0xC3:m -U lock:w:0xEC:m -E noreset
#	sc stop giveio
Detected encoding: UTF-80