1 |
PRG = glg |
1 |
PRG = glg |
2 |
OBJ = main.o tff.o mmc.o |
2 |
OBJ = main.o tff.o mmc.o |
3 |
MCU_TARGET = atmega168 |
3 |
MCU_TARGET = atmega168 |
4 |
OPTIMIZE = -Os -mcall-prologues |
4 |
OPTIMIZE = -Os -mcall-prologues |
5 |
DEFS = |
5 |
DEFS = |
6 |
LIBS = |
6 |
LIBS = |
7 |
DEBUG = dwarf-2 |
7 |
DEBUG = dwarf-2 |
8 |
|
8 |
|
9 |
CC = avr-gcc |
9 |
CC = avr-gcc |
10 |
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
10 |
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
11 |
ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS) |
11 |
ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS) |
12 |
CFLAGS = -g$(DEBUG) -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
12 |
CFLAGS = -g$(DEBUG) -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
13 |
LDFLAGS = -Wl,-Map,$(PRG).map |
13 |
LDFLAGS = -Wl,-Map,$(PRG).map |
14 |
|
14 |
|
15 |
OBJCOPY = avr-objcopy |
15 |
OBJCOPY = avr-objcopy |
16 |
OBJDUMP = avr-objdump |
16 |
OBJDUMP = avr-objdump |
17 |
SIZE = avr-size |
17 |
SIZE = avr-size |
18 |
|
18 |
|
19 |
|
19 |
|
20 |
|
20 |
|
21 |
all: $(PRG).elf lst text size |
21 |
all: $(PRG).elf lst text size |
22 |
|
22 |
|
23 |
$(PRG).elf: $(OBJ) |
23 |
$(PRG).elf: $(OBJ) |
24 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
24 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
25 |
|
25 |
|
26 |
|
26 |
|
27 |
clean: |
27 |
clean: |
28 |
rm -rf *.o $(PRG).elf *.eps *.bak *.a |
28 |
rm -rf *.o $(PRG).elf *.eps *.bak *.a |
29 |
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
29 |
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
30 |
rm -rf $(PRG).hex |
30 |
rm -rf $(PRG).hex |
31 |
|
31 |
|
32 |
|
32 |
|
33 |
|
33 |
|
34 |
size: $(PRG).elf |
34 |
size: $(PRG).elf |
35 |
$(SIZE) $(PRG).elf |
35 |
$(SIZE) $(PRG).elf |
36 |
|
36 |
|
37 |
lst: $(PRG).lst |
37 |
lst: $(PRG).lst |
38 |
%.lst: %.elf |
38 |
%.lst: %.elf |
39 |
$(OBJDUMP) -h -S $< > $@ |
39 |
$(OBJDUMP) -h -S $< > $@ |
40 |
|
40 |
|
41 |
%.o : %.S |
41 |
%.o : %.S |
42 |
$(CC) -c $(ALL_ASFLAGS) $< -o $@ |
42 |
$(CC) -c $(ALL_ASFLAGS) $< -o $@ |
43 |
|
43 |
|
44 |
|
44 |
|
45 |
|
45 |
|
46 |
text: hex |
46 |
text: hex |
47 |
hex: $(PRG).hex |
47 |
hex: $(PRG).hex |
48 |
|
48 |
|
49 |
%.hex: %.elf |
49 |
%.hex: %.elf |
50 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
50 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
51 |
|
51 |
|
52 |
|
52 |
|