1 |
# ====================================================================== |
1 |
# ====================================================================== |
2 |
# Common Makefile for USBtiny applications |
2 |
# Common Makefile for USBtiny applications |
3 |
# |
3 |
# |
4 |
# Macros to be defined before including this file: |
4 |
# Macros to be defined before including this file: |
5 |
# |
5 |
# |
6 |
# USBTINY - the location of this directory |
6 |
# USBTINY - the location of this directory |
7 |
# TARGET_ARCH - gcc -mmcu= option with AVR device type |
7 |
# TARGET_ARCH - gcc -mmcu= option with AVR device type |
8 |
# OBJECTS - the objects in addition to the USBtiny objects |
8 |
# OBJECTS - the objects in addition to the USBtiny objects |
9 |
# FLASH_CMD - command to upload main.hex to flash |
9 |
# FLASH_CMD - command to upload main.hex to flash |
10 |
# STACK - maximum stack size (optional) |
10 |
# STACK - maximum stack size (optional) |
11 |
# FLASH - flash size (optional) |
11 |
# FLASH - flash size (optional) |
12 |
# SRAM - SRAM size (optional) |
12 |
# SRAM - SRAM size (optional) |
13 |
# SCHEM - Postscript version of the schematic to be generated |
13 |
# SCHEM - Postscript version of the schematic to be generated |
14 |
# |
14 |
# |
15 |
# Copyright (C) 2006 Dick Streefland |
15 |
# Copyright (C) 2006 Dick Streefland |
16 |
# |
16 |
# |
17 |
# This is free software, licensed under the terms of the GNU General |
17 |
# This is free software, licensed under the terms of the GNU General |
18 |
# Public License as published by the Free Software Foundation. |
18 |
# Public License as published by the Free Software Foundation. |
19 |
# ====================================================================== |
19 |
# ====================================================================== |
20 |
|
20 |
|
21 |
CC = avr-gcc |
21 |
CC = avr-gcc |
22 |
CFLAGS = -Os -g -Wall -I. -I$(USBTINY) |
22 |
CFLAGS = -Os -g -Wall -I. -I$(USBTINY) |
23 |
ASFLAGS = -Os -g -Wall -I. |
23 |
ASFLAGS = -Os -g -Wall -I. |
24 |
LDFLAGS = -g |
24 |
LDFLAGS = -g |
25 |
MODULES = crc.o int.o usb.o $(OBJECTS) |
25 |
MODULES = crc.o int.o usb.o $(OBJECTS) |
26 |
UTIL = $(USBTINY)/../util |
26 |
UTIL = $(USBTINY)/../util |
27 |
|
27 |
|
28 |
main.hex: |
28 |
main.hex: |
29 |
|
29 |
|
30 |
all: main.hex $(SCHEM) |
30 |
all: main.hex $(SCHEM) |
31 |
|
31 |
|
32 |
clean: |
32 |
clean: |
33 |
rm -f main.elf *.o tags *.sch~ gschem.log |
33 |
rm -f main.elf *.o tags *.sch~ gschem.log |
34 |
|
34 |
|
35 |
clobber: clean |
35 |
clobber: clean |
36 |
rm -f main.hex $(SCHEM) |
36 |
rm -f main.hex $(SCHEM) |
37 |
|
37 |
|
38 |
main.elf: $(MODULES) |
38 |
main.elf: $(MODULES) |
39 |
$(LINK.o) -o $@ $(MODULES) |
39 |
$(LINK.o) -o $@ $(MODULES) |
40 |
|
40 |
|
41 |
main.hex: main.elf $(UTIL)/check.py |
41 |
main.hex: main.elf $(UTIL)/check.py |
42 |
@python $(UTIL)/check.py main.elf $(STACK) $(FLASH) $(SRAM) |
42 |
@python $(UTIL)/check.py main.elf $(STACK) $(FLASH) $(SRAM) |
43 |
avr-objcopy -j .text -j .data -O ihex main.elf main.hex |
43 |
avr-objcopy -j .text -j .data -O ihex main.elf main.hex |
44 |
|
44 |
|
45 |
disasm: main.elf |
45 |
disasm: main.elf |
46 |
avr-objdump -S main.elf |
46 |
avr-objdump -S main.elf |
47 |
|
47 |
|
48 |
flash: main.hex |
48 |
flash: main.hex |
49 |
$(FLASH_CMD) |
49 |
$(FLASH_CMD) |
50 |
|
50 |
|
51 |
crc.o: $(USBTINY)/crc.S $(USBTINY)/def.h usbtiny.h |
51 |
crc.o: $(USBTINY)/crc.S $(USBTINY)/def.h usbtiny.h |
52 |
$(COMPILE.c) $(USBTINY)/crc.S |
52 |
$(COMPILE.c) $(USBTINY)/crc.S |
53 |
int.o: $(USBTINY)/int.S $(USBTINY)/def.h usbtiny.h |
53 |
int.o: $(USBTINY)/int.S $(USBTINY)/def.h usbtiny.h |
54 |
$(COMPILE.c) $(USBTINY)/int.S |
54 |
$(COMPILE.c) $(USBTINY)/int.S |
55 |
usb.o: $(USBTINY)/usb.c $(USBTINY)/def.h $(USBTINY)/usb.h usbtiny.h |
55 |
usb.o: $(USBTINY)/usb.c $(USBTINY)/def.h $(USBTINY)/usb.h usbtiny.h |
56 |
$(COMPILE.c) $(USBTINY)/usb.c |
56 |
$(COMPILE.c) $(USBTINY)/usb.c |
57 |
|
57 |
|
58 |
main.o: $(USBTINY)/usb.h |
58 |
main.o: $(USBTINY)/usb.h |
59 |
|
59 |
|
60 |
%.ps: %.sch $(UTIL)/sch2ps |
60 |
%.ps: %.sch $(UTIL)/sch2ps |
61 |
$(UTIL)/sch2ps $< |
61 |
$(UTIL)/sch2ps $< |