]> cloudbase.mooo.com Git - avrcpm.git/blob - avr/Makefile
30dbfa0c85f4b0c6e9e82160591ca66f834bb585
[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 # Version defined in 'config.inc'.
22 VMAJOR = $(call conf-val, VMAJOR, config.inc)
23 VMINOR = $(call conf-val, VMINOR, config.inc)
24
25
26 TARGET = avrcpm
27 ASRC0 = avrcpm.asm
28
29 ASRC0 += config.inc macros.inc init.asm dram-refresh.asm timer.asm utils.asm
30 ASRC0 += mmc.asm mmc-old.asm virt_ports.asm
31 ASRC0 += dsk_cpm.asm dsk_fat16.asm dsk_fsys.asm dsk_mgr.asm dsk_ram.asm
32 ASRC0 += 8080int-orig.asm 8080int.asm 8080int-jmp.asm 8080int-t3.asm 8080int-t3-jmp.asm Z80int-jmp.asm
33
34 ifneq ($(DRAM_8BIT),0)
35 ASRC0 += dram-8bit.inc dram-8bit.asm sw-uart.asm i2c.asm
36 else
37 ASRC0 += dram-4bit.inc dram-4bit.asm hw-uart.asm
38 endif
39
40 ASRC = $(ASRC0) svnrev.inc
41 #ASRC := $(ASRC0) svnrev.inc
42
43 # Place -D or -U options here
44 CDEFS = -D$(MCU)
45
46 ifdef F_CPU
47 CDEFS += -DF_CPU=$(F_CPU)
48 endif
49 ifdef DRAM_8BIT
50 CDEFS += -DDRAM_8BIT=$(DRAM_8BIT)
51 endif
52 ifdef BAUD
53 CDEFS += -DBAUD=$(BAUD)
54 endif
55 ifdef I2C_SUPPORT
56 CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT)
57 endif
58 ifdef EM_Z80
59 CDEFS += -DEM_Z80=$(EM_Z80)
60 endif
61 ifdef FAT16_SUPPORT
62 CDEFS += -DFAT16_SUPPORT=$(FAT16_SUPPORT)
63 endif
64 ifdef CPMDSK_SUPPORT
65 CDEFS += -DCPMDSK_SUPPORT=$(CPMDSK_SUPPORT)
66 endif
67 ifdef MMCBOOTLOADER
68 CDEFS += -DMMCBOOTLOADER=$(MMCBOOTLOADER)
69 endif
70 ifdef TESTVERSION
71 CDEFS += -DTESTVERSION=$(TESTVERSION)
72 endif
73
74 ASPATH = C:/Programme/Atmel/AVR\ Tools/AvrAssembler2
75 DEFS = $(ASPATH)/Appnotes
76
77 ifeq "$(OS)" "Windows_NT"
78 PLATFORM=win32
79 else
80 PLATFORM=Linux
81 endif
82
83 WINE =
84 ifeq ($(PLATFORM),Linux)
85 WINE = wine
86 endif
87
88 AS = $(WINE) $(ASPATH)/avrasm2.exe
89 ASFLAGS = -I $(DEFS) $(CDEFS)
90
91 AWK = gawk
92 OBJCOPY = avr-objcopy
93 CRCGEN = crcgen
94
95 HEXTOBIN = $(OBJCOPY) -I ihex -O binary --gap-fill 0xff
96
97 #(call conf-val,config-id,config-file)
98 #conf-val = $(shell $(AWK) -vID=$(strip $1) '$$0 ~ "^[ \t]*\#define[ \t]+" ID "[ \t]+" {print $$3}' $2 )
99 conf-val = $(shell $(AWK) -vID=$(strip $1) '$$1$$2 ~ "\#define"ID {print $$3}' $2)
100
101
102 # Programming support using avrdude. Settings and variables.
103
104 AVRDUDE_PROGRAMMER = dragon_isp
105 AVRDUDE_PORT = usb
106
107 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
108 AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
109
110
111 # Uncomment the following if you want avrdude's erase cycle counter.
112 # Note that this counter needs to be initialized first using -Yn,
113 # see avrdude manual.
114 #AVRDUDE_ERASE_COUNTER = -y
115
116 # Uncomment the following if you do /not/ wish a verification to be
117 # performed after programming the device.
118 #AVRDUDE_NO_VERIFY = -V
119
120 # Increase verbosity level. Please use this when submitting bug
121 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
122 # to submit bug reports.
123 #AVRDUDE_VERBOSE = -v -v
124
125 AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
126 AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
127
128 AVRDUDE = avrdude
129 REMOVE = rm -f
130 MV = mv -f
131
132 .PHONY: all bin hex eep lst map program flash eeprom tags clean
133
134 # Default target.
135 all: hex lst
136
137 hex: $(TARGET).hex
138 eep: $(TARGET).eep
139 lst: $(TARGET).lst
140 map: $(TARGET).map
141 bin: $(TARGET)-$(VMAJOR).$(VMINOR).bin
142
143
144 # Program the device.
145 program: $(TARGET).hex $(TARGET).eep
146 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
147
148 flash: $(TARGET).hex
149 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
150
151 eeprom: $(TARGET).hex $(TARGET).eep
152 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM)
153
154
155 $(TARGET).hex: $(ASRC)
156 $(TARGET).eep: $(ASRC)
157 $(TARGET).lst: $(ASRC)
158 $(TARGET).map: $(ASRC)
159
160
161 .SUFFIXES:
162
163 %-$(VMAJOR).$(VMINOR).bin: %.hex
164 $(HEXTOBIN) $< $@
165 $(CRCGEN) $@
166
167 %.hex: %.asm
168 $(AS) $(ASFLAGS) -fI -o $@ $<
169
170 %.lst: %.asm
171 @$(AS) $(ASFLAGS) -v0 -f- -l $@ $<
172
173 %.map: %.asm
174 $(AS) $(ASFLAGS) -v0 -f- -m $@ $<
175
176 tags: $(SRC) $(ASRC)
177 ctags $(SRC) $(ASRC)
178
179 svnrev.inc: $(ASRC0)
180 svnrev -osvnrev.inc $^
181 touch svnrev.inc
182
183 # Target: clean project.
184 clean:
185 $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst \
186 $(TARGET)-$(VMAJOR).$(VMINOR).bin