]> cloudbase.mooo.com Git - avrcpm.git/blob - avr/Makefile
SVN --> GIT
[avrcpm.git] / avr / Makefile
1 # AVR-ASM Makefile, derived from the WinAVR template (which
2 # is public domain), believed to be neutral to any flavor of "make"
3 # (GNU make, BSD make, SysV make)
4
5 #For a description of of the following built options see 'config.inc'
6 #Defining options here will override the defaults from the config file.
7
8 #MCU = atmega88
9 MCU = atmega328p
10 #F_CPU = 20000000
11 #DRAM_8BIT = 0
12 #BAUD = 57600
13 #BAUD = 115200
14 #I2C_SUPPORT = 0
15 #EM_Z80 = 0
16 #FAT16_SUPPORT = 0
17 #CPMDSK_SUPPORT = 0
18 #MMCBOOTLOADER = 0
19
20
21 TARGET = avrcpm
22 ASRC0 = avrcpm.asm
23
24 ASRC0 += config.inc macros.inc init.asm dram-refresh.asm timer.asm utils.asm
25 ASRC0 += mmc.asm mmc-old.asm virt_ports.asm
26 ASRC0 += dsk_cpm.asm dsk_fat16.asm dsk_fsys.asm dsk_mgr.asm dsk_ram.asm
27 ASRC0 += 8080int-orig.asm 8080int.asm 8080int-jmp.asm 8080int-t3.asm 8080int-t3-jmp.asm Z80int-jmp.asm
28
29 EXTRA_DIST := autorevision.cache
30
31 PREFIX = $(PROG)_$(VERSION)
32 DIST_NAME = $(PREFIX).zip
33
34 $(foreach X,$(subst =,:=,$(subst ",,$(filter VCS_%,\
35 $(shell autorevision -q -t sh -o ./autorevision.cache)))),$(eval $X))
36
37 VERSION := $(shell echo "$(VCS_TAG)" | sed -e 's/^v//g')
38 VMAJOR := $(shell echo "$(VCS_TAG)" | sed -E 's/([^0-9]*)([0-9]+)([.])([0-9]+)([^0-9]*)/\2/')
39 VMINOR := $(shell echo "$(VCS_TAG)" | sed -E 's/([^0-9]*)([0-9]+)([.])([0-9]+)([^0-9]*)/\4/')
40
41
42 ifneq ($(VCS_TICK),0)
43 VERSION := $(VERSION)-$(VCS_TICK)
44 endif
45 ifneq ($(VCS_BRANCH),master)
46 VERSION := $(VERSION)-$(VCS_BRANCH)
47 endif
48 ifeq ($(VCS_WC_MODIFIED),1)
49 VERSION := $(VERSION)-dirty
50 endif
51
52 ifneq ($(DRAM_8BIT),0)
53 ASRC0 += dram-8bit.inc dram-8bit.asm sw-uart.asm i2c.asm
54 else
55 ASRC0 += dram-4bit.inc dram-4bit.asm hw-uart.asm
56 endif
57
58 ASRC = $(ASRC0)
59
60 # Place -D or -U options here
61 CDEFS = -D$(MCU) -DVERSION=\"$(VERSION)\" -DVMAJOR=$(VMAJOR) -DVMINOR=$(VMINOR)
62 ifdef F_CPU
63 CDEFS += -DF_CPU=$(F_CPU)
64 endif
65 ifdef DRAM_8BIT
66 CDEFS += -DDRAM_8BIT=$(DRAM_8BIT)
67 endif
68 ifdef BAUD
69 CDEFS += -DBAUD=$(BAUD)
70 endif
71 ifdef I2C_SUPPORT
72 CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT)
73 endif
74 ifdef EM_Z80
75 CDEFS += -DEM_Z80=$(EM_Z80)
76 endif
77 ifdef FAT16_SUPPORT
78 CDEFS += -DFAT16_SUPPORT=$(FAT16_SUPPORT)
79 endif
80 ifdef CPMDSK_SUPPORT
81 CDEFS += -DCPMDSK_SUPPORT=$(CPMDSK_SUPPORT)
82 endif
83 ifdef MMCBOOTLOADER
84 CDEFS += -DMMCBOOTLOADER=$(MMCBOOTLOADER)
85 endif
86 ifdef TESTVERSION
87 CDEFS += -DTESTVERSION=$(TESTVERSION)
88 endif
89
90 ASPATH := C:/Programme/Atmel/AVR\ Tools/AvrAssembler2
91 DEFS := $(ASPATH)/Appnotes
92
93 ifeq "$(OS)" "Windows_NT"
94 PLATFORM=win32
95 else
96 PLATFORM=Linux
97 endif
98
99 WINE =
100 ifeq ($(PLATFORM),Linux)
101 WINE = wine
102 endif
103
104 AS = $(WINE) $(ASPATH)/avrasm2.exe
105 ASFLAGS = -I $(DEFS) $(CDEFS)
106
107 OBJCOPY = avr-objcopy
108 CRCGEN = crcgen
109
110 HEXTOBIN = $(OBJCOPY) -I ihex -O binary --gap-fill 0xff
111
112 # Programming support using avrdude. Settings and variables.
113
114 AVRDUDE_PROGRAMMER = dragon_isp
115 AVRDUDE_PORT = usb
116
117 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
118 AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
119
120 # Uncomment the following if you want avrdude's erase cycle counter.
121 # Note that this counter needs to be initialized first using -Yn,
122 # see avrdude manual.
123 #AVRDUDE_ERASE_COUNTER = -y
124
125 # Uncomment the following if you do /not/ wish a verification to be
126 # performed after programming the device.
127 #AVRDUDE_NO_VERIFY = -V
128
129 # Increase verbosity level. Please use this when submitting bug
130 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
131 # to submit bug reports.
132 #AVRDUDE_VERBOSE = -v -v
133
134 AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
135 AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
136
137 AVRDUDE = avrdude
138 REMOVE = rm -f
139 MV = mv -f
140
141 .PHONY: all bin hex eep lst map program flash eeprom tags clean
142
143 # Default target.
144 all: hex lst
145
146 hex: $(TARGET).hex
147 eep: $(TARGET).eep
148 lst: $(TARGET).lst
149 map: $(TARGET).map
150 bin: $(TARGET)-$(VMAJOR).$(VMINOR).bin
151
152
153 # Program the device.
154 program: $(TARGET).hex $(TARGET).eep
155 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
156
157 flash: $(TARGET).hex
158 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
159
160 eeprom: $(TARGET).hex $(TARGET).eep
161 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM)
162
163
164 $(TARGET).hex: $(ASRC)
165 $(TARGET).eep: $(ASRC)
166 $(TARGET).lst: $(ASRC)
167 $(TARGET).map: $(ASRC)
168
169
170 .SUFFIXES:
171
172 %-$(VMAJOR).$(VMINOR).bin: %.hex
173 $(HEXTOBIN) $< $@
174 $(CRCGEN) $@
175
176 %.hex: %.asm
177 $(AS) $(ASFLAGS) -fI -o $@ $<
178
179 %.lst: %.asm
180 @$(AS) $(ASFLAGS) -v0 -f- -l $@ $<
181
182 %.map: %.asm
183 $(AS) $(ASFLAGS) -v0 -f- -m $@ $<
184
185 tags: $(SRC) $(ASRC)
186 ctags $(SRC) $(ASRC)
187
188 # Target: clean project.
189 clean:
190 $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst \
191 $(TARGET)-$(VMAJOR).$(VMINOR).bin