3460 |
miho |
1 |
PROGRAM = timer_demo2 |
|
|
2 |
|
|
|
3 |
MCU = atmega88 |
|
|
4 |
|
|
|
5 |
CC = avr-gcc |
|
|
6 |
OBJCOPY = avr-objcopy |
|
|
7 |
CFLAGS += -Wall -g -Os -mmcu=$(MCU) |
|
|
8 |
LDFLAGS += |
|
|
9 |
|
|
|
10 |
OBJS = $(PROGRAM).o |
|
|
11 |
|
|
|
12 |
all: $(PROGRAM)_$(MCU).hex |
|
|
13 |
|
|
|
14 |
$(PROGRAM)_$(MCU).elf: $(PROGRAM).o |
|
|
15 |
@printf " LD $(subst $(shell pwd)/,,$(@))\n" |
|
|
16 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ |
|
|
17 |
|
|
|
18 |
$(PROGRAM)_$(MCU).hex: $(PROGRAM)_$(MCU).elf |
|
|
19 |
@printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n" |
|
|
20 |
$(OBJCOPY) -O ihex $< $@ |
|
|
21 |
|
|
|
22 |
%.o: %.c |
|
|
23 |
@printf " CC $(subst $(shell pwd)/,,$(@))\n" |
|
|
24 |
$(CC) $(CFLAGS) -o $@ -c $< |
|
|
25 |
|
|
|
26 |
flash: $(PROGRAM)_$(MCU).hex |
|
|
27 |
@printf " FLASH $(PROGRAM)_$(MCU).hex\n" |
|
|
28 |
avrdude -c stk500v1 -P usb -p m88 -U flash:w:$(PROGRAM)_$(MCU).hex |
|
|
29 |
|
|
|
30 |
clean: |
|
|
31 |
@printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n" |
|
|
32 |
rm -f *.o |
|
|
33 |
@printf " CLEAN $(PROGRAM).elf\n" |
|
|
34 |
rm -f *.elf |
|
|
35 |
@printf " CLEAN $(PROGRAM).hex\n" |
|
|
36 |
rm -f *.hex |