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