]> cloudbase.mooo.com Git - avrcpm.git/blame - avr/Makefile
SVN --> GIT
[avrcpm.git] / avr / Makefile
CommitLineData
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 9MCU = 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 21TARGET = avrcpm
4bd49b80 22ASRC0 = avrcpm.asm
b2017655 23
4bd49b80 24ASRC0 += config.inc macros.inc init.asm dram-refresh.asm timer.asm utils.asm
fa9059af 25ASRC0 += mmc.asm mmc-old.asm virt_ports.asm
4bd49b80 26ASRC0 += dsk_cpm.asm dsk_fat16.asm dsk_fsys.asm dsk_mgr.asm dsk_ram.asm
fa9059af 27ASRC0 += 8080int-orig.asm 8080int.asm 8080int-jmp.asm 8080int-t3.asm 8080int-t3-jmp.asm Z80int-jmp.asm
b2017655 28
fc0cd571
L
29EXTRA_DIST := autorevision.cache
30
31PREFIX = $(PROG)_$(VERSION)
32DIST_NAME = $(PREFIX).zip
33
34$(foreach X,$(subst =,:=,$(subst ",,$(filter VCS_%,\
35 $(shell autorevision -q -t sh -o ./autorevision.cache)))),$(eval $X))
36
37VERSION := $(shell echo "$(VCS_TAG)" | sed -e 's/^v//g')
38VMAJOR := $(shell echo "$(VCS_TAG)" | sed -E 's/([^0-9]*)([0-9]+)([.])([0-9]+)([^0-9]*)/\2/')
39VMINOR := $(shell echo "$(VCS_TAG)" | sed -E 's/([^0-9]*)([0-9]+)([.])([0-9]+)([^0-9]*)/\4/')
40
41
42ifneq ($(VCS_TICK),0)
43 VERSION := $(VERSION)-$(VCS_TICK)
44endif
45ifneq ($(VCS_BRANCH),master)
46 VERSION := $(VERSION)-$(VCS_BRANCH)
47endif
48ifeq ($(VCS_WC_MODIFIED),1)
49 VERSION := $(VERSION)-dirty
50endif
51
b2017655 52ifneq ($(DRAM_8BIT),0)
d8fa6a36 53 ASRC0 += dram-8bit.inc dram-8bit.asm sw-uart.asm i2c.asm
b2017655 54else
4bd49b80 55 ASRC0 += dram-4bit.inc dram-4bit.asm hw-uart.asm
b2017655 56endif
3c3744f1 57
fc0cd571 58ASRC = $(ASRC0)
fa9059af 59
3c3744f1 60# Place -D or -U options here
fc0cd571 61CDEFS = -D$(MCU) -DVERSION=\"$(VERSION)\" -DVMAJOR=$(VMAJOR) -DVMINOR=$(VMINOR)
5c8bb361
L
62ifdef F_CPU
63 CDEFS += -DF_CPU=$(F_CPU)
64endif
65ifdef DRAM_8BIT
66 CDEFS += -DDRAM_8BIT=$(DRAM_8BIT)
67endif
68ifdef BAUD
69 CDEFS += -DBAUD=$(BAUD)
70endif
825ecc9d
L
71ifdef I2C_SUPPORT
72 CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT)
73endif
5c8bb361
L
74ifdef EM_Z80
75 CDEFS += -DEM_Z80=$(EM_Z80)
76endif
623dd899
L
77ifdef FAT16_SUPPORT
78 CDEFS += -DFAT16_SUPPORT=$(FAT16_SUPPORT)
79endif
ce520bff
L
80ifdef CPMDSK_SUPPORT
81 CDEFS += -DCPMDSK_SUPPORT=$(CPMDSK_SUPPORT)
82endif
5c8bb361
L
83ifdef MMCBOOTLOADER
84 CDEFS += -DMMCBOOTLOADER=$(MMCBOOTLOADER)
623dd899 85endif
5c8bb361
L
86ifdef TESTVERSION
87 CDEFS += -DTESTVERSION=$(TESTVERSION)
623dd899
L
88endif
89
fc0cd571
L
90ASPATH := C:/Programme/Atmel/AVR\ Tools/AvrAssembler2
91DEFS := $(ASPATH)/Appnotes
fa9059af
L
92
93ifeq "$(OS)" "Windows_NT"
94 PLATFORM=win32
95else
96 PLATFORM=Linux
97endif
3c3744f1 98
fa9059af
L
99WINE =
100ifeq ($(PLATFORM),Linux)
101 WINE = wine
102endif
103
104AS = $(WINE) $(ASPATH)/avrasm2.exe
3c3744f1
L
105ASFLAGS = -I $(DEFS) $(CDEFS)
106
623dd899
L
107OBJCOPY = avr-objcopy
108CRCGEN = crcgen
109
4bd49b80 110HEXTOBIN = $(OBJCOPY) -I ihex -O binary --gap-fill 0xff
623dd899 111
3c3744f1
L
112# Programming support using avrdude. Settings and variables.
113
114AVRDUDE_PROGRAMMER = dragon_isp
115AVRDUDE_PORT = usb
116
117AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
118AVRDUDE_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
134AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
135AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
136
137AVRDUDE = avrdude
138REMOVE = rm -f
139MV = mv -f
140
623dd899 141.PHONY: all bin hex eep lst map program flash eeprom tags clean
b2017655 142
3c3744f1
L
143# Default target.
144all: hex lst
145
623dd899
L
146hex: $(TARGET).hex
147eep: $(TARGET).eep
148lst: $(TARGET).lst
149map: $(TARGET).map
150bin: $(TARGET)-$(VMAJOR).$(VMINOR).bin
3c3744f1
L
151
152
4bd49b80 153# Program the device.
3c3744f1
L
154program: $(TARGET).hex $(TARGET).eep
155 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
156
157flash: $(TARGET).hex
158 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
159
160eeprom: $(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
185tags: $(SRC) $(ASRC)
186 ctags $(SRC) $(ASRC)
187
3c3744f1
L
188# Target: clean project.
189clean:
623dd899
L
190 $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst \
191 $(TARGET)-$(VMAJOR).$(VMINOR).bin