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