]>
Commit | Line | Data |
---|---|---|
3c3744f1 L |
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 | ||
5c8bb361 L |
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 | |
ce520bff | 9 | MCU = atmega328p |
5c8bb361 L |
10 | #F_CPU = 20000000 |
11 | #DRAM_8BIT = 0 | |
623dd899 | 12 | #BAUD = 57600 |
5c8bb361 | 13 | #BAUD = 115200 |
ce520bff | 14 | #I2C_SUPPORT = 0 |
5c8bb361 L |
15 | #EM_Z80 = 0 |
16 | #FAT16_SUPPORT = 0 | |
ce520bff | 17 | #CPMDSK_SUPPORT = 0 |
5c8bb361 | 18 | #MMCBOOTLOADER = 0 |
9c15f366 | 19 | |
623dd899 | 20 | |
9c15f366 | 21 | TARGET = avrcpm |
4bd49b80 | 22 | ASRC0 = avrcpm.asm |
b2017655 | 23 | |
4bd49b80 | 24 | ASRC0 += config.inc macros.inc init.asm dram-refresh.asm timer.asm utils.asm |
fa9059af | 25 | ASRC0 += mmc.asm mmc-old.asm virt_ports.asm |
4bd49b80 | 26 | ASRC0 += dsk_cpm.asm dsk_fat16.asm dsk_fsys.asm dsk_mgr.asm dsk_ram.asm |
fa9059af | 27 | ASRC0 += 8080int-orig.asm 8080int.asm 8080int-jmp.asm 8080int-t3.asm 8080int-t3-jmp.asm Z80int-jmp.asm |
b2017655 | 28 | |
fc0cd571 L |
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 | ||
b2017655 | 52 | ifneq ($(DRAM_8BIT),0) |
d8fa6a36 | 53 | ASRC0 += dram-8bit.inc dram-8bit.asm sw-uart.asm i2c.asm |
b2017655 | 54 | else |
4bd49b80 | 55 | ASRC0 += dram-4bit.inc dram-4bit.asm hw-uart.asm |
b2017655 | 56 | endif |
3c3744f1 | 57 | |
fc0cd571 | 58 | ASRC = $(ASRC0) |
fa9059af | 59 | |
3c3744f1 | 60 | # Place -D or -U options here |
fc0cd571 | 61 | CDEFS = -D$(MCU) -DVERSION=\"$(VERSION)\" -DVMAJOR=$(VMAJOR) -DVMINOR=$(VMINOR) |
5c8bb361 L |
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 | |
825ecc9d L |
71 | ifdef I2C_SUPPORT |
72 | CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT) | |
73 | endif | |
5c8bb361 L |
74 | ifdef EM_Z80 |
75 | CDEFS += -DEM_Z80=$(EM_Z80) | |
76 | endif | |
623dd899 L |
77 | ifdef FAT16_SUPPORT |
78 | CDEFS += -DFAT16_SUPPORT=$(FAT16_SUPPORT) | |
79 | endif | |
ce520bff L |
80 | ifdef CPMDSK_SUPPORT |
81 | CDEFS += -DCPMDSK_SUPPORT=$(CPMDSK_SUPPORT) | |
82 | endif | |
5c8bb361 L |
83 | ifdef MMCBOOTLOADER |
84 | CDEFS += -DMMCBOOTLOADER=$(MMCBOOTLOADER) | |
623dd899 | 85 | endif |
5c8bb361 L |
86 | ifdef TESTVERSION |
87 | CDEFS += -DTESTVERSION=$(TESTVERSION) | |
623dd899 L |
88 | endif |
89 | ||
fc0cd571 L |
90 | ASPATH := C:/Programme/Atmel/AVR\ Tools/AvrAssembler2 |
91 | DEFS := $(ASPATH)/Appnotes | |
fa9059af L |
92 | |
93 | ifeq "$(OS)" "Windows_NT" | |
94 | PLATFORM=win32 | |
95 | else | |
96 | PLATFORM=Linux | |
97 | endif | |
3c3744f1 | 98 | |
fa9059af L |
99 | WINE = |
100 | ifeq ($(PLATFORM),Linux) | |
101 | WINE = wine | |
102 | endif | |
103 | ||
104 | AS = $(WINE) $(ASPATH)/avrasm2.exe | |
3c3744f1 L |
105 | ASFLAGS = -I $(DEFS) $(CDEFS) |
106 | ||
623dd899 L |
107 | OBJCOPY = avr-objcopy |
108 | CRCGEN = crcgen | |
109 | ||
4bd49b80 | 110 | HEXTOBIN = $(OBJCOPY) -I ihex -O binary --gap-fill 0xff |
623dd899 | 111 | |
3c3744f1 L |
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 | ||
3c3744f1 L |
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 | |
4bd49b80 | 130 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
3c3744f1 L |
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 | ||
623dd899 | 141 | .PHONY: all bin hex eep lst map program flash eeprom tags clean |
b2017655 | 142 | |
3c3744f1 L |
143 | # Default target. |
144 | all: hex lst | |
145 | ||
623dd899 L |
146 | hex: $(TARGET).hex |
147 | eep: $(TARGET).eep | |
148 | lst: $(TARGET).lst | |
149 | map: $(TARGET).map | |
150 | bin: $(TARGET)-$(VMAJOR).$(VMINOR).bin | |
3c3744f1 L |
151 | |
152 | ||
4bd49b80 | 153 | # Program the device. |
3c3744f1 L |
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 | ||
b2017655 FZ |
164 | $(TARGET).hex: $(ASRC) |
165 | $(TARGET).eep: $(ASRC) | |
166 | $(TARGET).lst: $(ASRC) | |
167 | $(TARGET).map: $(ASRC) | |
3c3744f1 | 168 | |
623dd899 | 169 | |
b2017655 | 170 | .SUFFIXES: |
3c3744f1 | 171 | |
623dd899 L |
172 | %-$(VMAJOR).$(VMINOR).bin: %.hex |
173 | $(HEXTOBIN) $< $@ | |
174 | $(CRCGEN) $@ | |
175 | ||
3c3744f1 | 176 | %.hex: %.asm |
623dd899 | 177 | $(AS) $(ASFLAGS) -fI -o $@ $< |
3c3744f1 L |
178 | |
179 | %.lst: %.asm | |
623dd899 | 180 | @$(AS) $(ASFLAGS) -v0 -f- -l $@ $< |
3c3744f1 L |
181 | |
182 | %.map: %.asm | |
623dd899 | 183 | $(AS) $(ASFLAGS) -v0 -f- -m $@ $< |
3c3744f1 L |
184 | |
185 | tags: $(SRC) $(ASRC) | |
186 | ctags $(SRC) $(ASRC) | |
187 | ||
3c3744f1 L |
188 | # Target: clean project. |
189 | clean: | |
623dd899 L |
190 | $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst \ |
191 | $(TARGET)-$(VMAJOR).$(VMINOR).bin |