]> www.fi.muni.cz Git - tinyboard.git/blob - projects/rgb-led-string/Makefile
Merge branch 'master' of ssh://anxur.fi.muni.cz/~kas/html/git/tinyboard
[tinyboard.git] / projects / rgb-led-string / Makefile
1
2 PROGRAM=rgbstring
3 SRC=version.c main.c logging.c serial.c
4 OBJ=$(SRC:.c=.o)
5
6
7 MCU=attiny45
8 AVRDUDE_MCU=$(MCU)
9 AVRDUDE_PROGRAMMER=usbasp
10
11 CFLAGS=-Wall -Os -mmcu=$(MCU) -DUSE_LOGGING=1 -DF_CPU=8000000UL -std=gnu99
12 LDFLAGS=
13 AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
14
15 FORMAT=ihex
16
17 CC=avr-gcc
18 OBJCOPY=avr-objcopy
19 OBJDUMP=avr-objdump
20 AVRDUDE=avrdude
21
22 all: $(PROGRAM).hex $(PROGRAM).eep
23
24 program: $(PROGRAM).hex $(PROGRAM).eep
25         $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
26
27 program_flash: $(PROGRAM).hex
28         $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i
29
30 program_eeprom: $(PROGRAM).eep
31         $(AVRDUDE) $(AVRDUDE_FLAGS) eeprom:w:$(PROGRAM).eep:i
32
33 dump_eeprom:
34         $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:eeprom.raw:r
35         od -tx1 eeprom.raw
36
37 objdump: $(PROGRAM).elf
38         $(OBJDUMP) --disassemble $<
39
40 .PRECIOUS : $(OBJ) $(PROGRAM).elf
41
42 %.hex: %.elf
43         $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
44
45 %.eep: %.elf
46         $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
47                 --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
48
49 %.elf: $(OBJ)
50         $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
51
52 %.o: %.c rgbstring.h Makefile
53         $(CC) -c $(CFLAGS) $< -o $@
54
55 %.s: %.c rgbstring.h Makefile
56         $(CC) -S -c $(CFLAGS) $< -o $@
57
58 %.o: %.S
59         $(CC) -c $(CFLAGS) $< -o $@
60
61 clean:
62         rm -f $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s eeprom.raw
63
64 version.c:
65         ./version.pl > version.c
66
67 .PHONY: all clean dump_eeprom program program_flash program_eeprom objdump version.c
68