Skript file: /~heha/mb-iwp/Bergwerk/Bergwerk.zip/Makefile

P = us2
D = atmega328p
F = 16000000

C = c:/programs/WinAVR/gcc530/bin/avr-gcc -Wall -Wno-parentheses -Os -mmcu=$D -D F_CPU=$F -std=c++11
X = avrdude -c arduino -P com8 -p $D
Y = avrdude -c avrisp2 -P usb -p $D


all: $P.lst
zip: $P.zip


$P.elf: *.cpp Makefile
	$C -o $@ $(filter %.cpp,$^) -nostartfiles
	avr-size -C --mcu=$D $@
#-Wl,-u,vfprintf -lprintf_min 

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

%.lst: %.elf
	avr-objdump -d $< > $@
	avr-strip $<
	
flash: $P.hex
	$X -e -U flash:w:$<
#Geht nicht: Verify-Fehler

bl: optiboot_atmega328p.hex
	$Y -e -U flash:w:$<

readfuse:
	$Y -v -U lock:r:-:i
#Die Option -v spuckt u.a. die Fuses aus

flash2: $P.hex
	$Y -e -U flash:w:$<
#Geht! Das lässt das Arduino-Geraffel weg

fuse2:
	$Y -U hfuse:w:0xD9:m
Detected encoding: UTF-80