-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (37 loc) · 1.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
DEVICE = attiny85 # it's what we're using
CLOCK = 16500000 # 16.5Mhz, no external crystal needed
FUSES = -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
PROGRAMMER = -c usbasp -P usb # modify for different programmer
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I. -D $(MODULE)
_OBJECTS := libs-device/osccal.o usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
all:
@echo "\nRead the readme!"
snes: OBJECTS = $(_OBJECTS) snes/snes.o
snes: MODULE = SNES
snes: snes/snes.o main.hex
nes: OBJECTS = $(_OBJECTS) nes/nes.o
nes: MODULE = NES
nes: nes/nes.o main.hex
flash:
$(AVRDUDE) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
upload:
micronucleus --run main.hex
clean:
rm -f main.hex main.elf $(_OBJECTS) snes/snes.o nes/nes.o
# file targets:
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
main.elf: $(_OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avr-size --format=avr --mcu=$(DEVICE) main.elf