1PRG            = largedemo
2OBJ            = largedemo.o
3MCU_TARGET     = atmega16
4#MCU_TARGET     = atmega8
5#MCU_TARGET     = atmega48
6#MCU_TARGET     = atmega88
7#MCU_TARGET     = atmega168
8#MCU_TARGET     = attiny2313
9OPTIMIZE       = -Os
10
11DEFS           =
12LIBS           =
13
14# You should not have to change anything below here.
15
16CC             = avr-gcc
17
18# Override is only needed by avr-lib build system.
19
20override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
21override LDFLAGS       = -Wl,-Map,$(PRG).map
22
23OBJCOPY        = avr-objcopy
24OBJDUMP        = avr-objdump
25
26all: $(PRG).elf lst text eeprom
27
28$(PRG).elf: $(OBJ)
29	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
30
31clean:
32	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
33	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
34
35lst:  $(PRG).lst
36
37%.lst: %.elf
38	$(OBJDUMP) -h -S $< > $@
39
40# Rules for building the .text rom images
41
42text: hex bin srec
43
44hex:  $(PRG).hex
45bin:  $(PRG).bin
46srec: $(PRG).srec
47
48%.hex: %.elf
49	$(OBJCOPY) -j .text -j .data -O ihex $< $@
50
51%.srec: %.elf
52	$(OBJCOPY) -j .text -j .data -O srec $< $@
53
54%.bin: %.elf
55	$(OBJCOPY) -j .text -j .data -O binary $< $@
56
57# Rules for building the .eeprom rom images
58
59eeprom: ehex ebin esrec
60
61ehex:  $(PRG)_eeprom.hex
62ebin:  $(PRG)_eeprom.bin
63esrec: $(PRG)_eeprom.srec
64
65%_eeprom.hex: %.elf
66	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
67
68%_eeprom.srec: %.elf
69	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
70
71%_eeprom.bin: %.elf
72	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
73
74# Every thing below here is used by avr-libc's build system and can be ignored
75# by the casual user.
76
77JPEGFILES               = largedemo-setup.jpg largedemo-wiring.jpg \
78                          largedemo-wiring2.jpg
79
80JPEG2PNM                = jpegtopnm
81PNM2EPS                 = pnmtops
82JPEGRESOLUTION          = 180
83EXTRA_CLEAN_FILES       = *.hex *.bin *.srec *.eps
84
85dox: ${JPEGFILES:.jpg=.eps}
86
87%.eps: %.jpg
88	$(JPEG2PNM) $< |\
89	$(PNM2EPS) -noturn -dpi $(JPEGRESOLUTION) -equalpixels \
90	> $@
91