Skript file: /~heha/enas/Convac-Ätzer/uba.zip/firmware-210407/Makefile

# Copyright 2017 by Robert Evans (rrevans@gmail.com)
#
# Tested with GNU Make 4.1

#PATH := c:\programs\winavr\gcc492\bin\;$(PATH)

P = ubaboot
D = atmega32u4
F = 16000000
# only 8 MHz and 16 MHz are supported
A = avr-

AVRDUDE = crundll InpOut32,CatchIo avrdude -c pony-stk200 -p $D -P lpt1 -E noreset
# On some Win64 systems, giveio64.sys faults with nasty bluescreen.
# crundll.exe is a command-line replacement for rundll32.exe
# bundled with h#s inpout32.dll / inpoutx64.dll which, using CatchIo,
# redirects I/O over safe inpout32.dll Inp() / Out() API calls.
# Change this line according to your environment and programmer.

CFLAGS += -DF_CPU=$F
CFLAGS += -Os -g
CFLAGS += -mmcu=$D
CFLAGS += -Wall
CFLAGS += -ffreestanding -nostdlib

ifneq (,$(findstring u4,$D))	# atmega16u4, atmega32u4 (Arduino Leonardo, Pro Micro)
EFUSE = 0xC3
LOCK  = 0x2F
UNLOCK= 0x3F
else	# atmega8u2, atmega16u2, atmega32u2, at90usb82, at90usb162
EFUSE = 0xF4
LOCK  = 0xDF
UNLOCK= 0xFF
endif

all: $P.elf $P.lst

verify: $P.hex
	$(AVRDUDE) -U flash:v:$< -U lfuse:v:0xDE:m -U hfuse:v:0xDF:m -U efuse:v:$(EFUSE):m -U lock:v:$(LOCK):m
flash: $P.hex
	$(AVRDUDE) -U flash:w:$<
fuse:
	$(AVRDUDE) -U lfuse:w:0xDE:m -U hfuse:w:0xDF:m -U efuse:w:$(EFUSE):m -U lock:w:$(LOCK):m
erase:
	$(AVRDUDE) -U lock:w:$(UNLOCK):m -e

program: erase flash fuse

.SUFFIXES: .elf .hex .lst

%.hex: %.elf
	$Aobjcopy -O ihex -R .eeprom $< $@
%.lst: %.elf
	$Aobjdump -d $< > $@
	$Astrip $<

%.elf: *.S *.x Makefile
	$Agcc $(CFLAGS) $< -o $@ -Wl,-T $(filter %.x,$^)
	$Asize $@

clean:
	rm -f $P.hex $P.elf

.PHONY: all clean
Detected encoding: ASCII (7 bit)2