]>
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 |
e8384f88 | 15 | ADC_SUPPORT = 0 |
5c8bb361 L |
16 | #EM_Z80 = 0 |
17 | #FAT16_SUPPORT = 0 | |
ce520bff | 18 | #CPMDSK_SUPPORT = 0 |
5c8bb361 | 19 | #MMCBOOTLOADER = 0 |
9c15f366 | 20 | |
623dd899 L |
21 | |
22 | # Version defined in 'config.inc'. | |
23 | VMAJOR = $(call conf-val, VMAJOR, config.inc) | |
24 | VMINOR = $(call conf-val, VMINOR, config.inc) | |
25 | ||
623dd899 | 26 | |
9c15f366 | 27 | TARGET = avrcpm |
fa9059af | 28 | ASRC0 = avrcpm.asm |
b2017655 | 29 | |
fa9059af L |
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 | |
b2017655 FZ |
34 | |
35 | ifneq ($(DRAM_8BIT),0) | |
d8fa6a36 | 36 | ASRC0 += dram-8bit.inc dram-8bit.asm sw-uart.asm i2c.asm |
b2017655 | 37 | else |
fa9059af | 38 | ASRC0 += dram-4bit.inc dram-4bit.asm hw-uart.asm |
b2017655 | 39 | endif |
3c3744f1 | 40 | |
623dd899 | 41 | ASRC = $(ASRC0) svnrev.inc |
fa9059af | 42 | #ASRC := $(ASRC0) svnrev.inc |
fa9059af | 43 | |
3c3744f1 | 44 | # Place -D or -U options here |
5c8bb361 | 45 | CDEFS = -D$(MCU) |
623dd899 | 46 | |
5c8bb361 L |
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 | |
825ecc9d L |
56 | ifdef I2C_SUPPORT |
57 | CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT) | |
58 | endif | |
59 | ifdef ADC_SUPPORT | |
60 | CDEFS += -DADC_SUPPORT=$(ADC_SUPPORT) | |
d8fa6a36 | 61 | endif |
5c8bb361 L |
62 | ifdef EM_Z80 |
63 | CDEFS += -DEM_Z80=$(EM_Z80) | |
64 | endif | |
623dd899 L |
65 | ifdef FAT16_SUPPORT |
66 | CDEFS += -DFAT16_SUPPORT=$(FAT16_SUPPORT) | |
67 | endif | |
ce520bff L |
68 | ifdef CPMDSK_SUPPORT |
69 | CDEFS += -DCPMDSK_SUPPORT=$(CPMDSK_SUPPORT) | |
70 | endif | |
5c8bb361 L |
71 | ifdef MMCBOOTLOADER |
72 | CDEFS += -DMMCBOOTLOADER=$(MMCBOOTLOADER) | |
623dd899 | 73 | endif |
5c8bb361 L |
74 | ifdef TESTVERSION |
75 | CDEFS += -DTESTVERSION=$(TESTVERSION) | |
623dd899 L |
76 | endif |
77 | ||
fa9059af L |
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 | |
3c3744f1 | 86 | |
fa9059af L |
87 | WINE = |
88 | ifeq ($(PLATFORM),Linux) | |
89 | WINE = wine | |
90 | endif | |
91 | ||
92 | AS = $(WINE) $(ASPATH)/avrasm2.exe | |
3c3744f1 L |
93 | ASFLAGS = -I $(DEFS) $(CDEFS) |
94 | ||
623dd899 L |
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 | ||
3c3744f1 L |
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 | ||
623dd899 | 136 | .PHONY: all bin hex eep lst map program flash eeprom tags clean |
b2017655 | 137 | |
3c3744f1 L |
138 | # Default target. |
139 | all: hex lst | |
140 | ||
623dd899 L |
141 | hex: $(TARGET).hex |
142 | eep: $(TARGET).eep | |
143 | lst: $(TARGET).lst | |
144 | map: $(TARGET).map | |
145 | bin: $(TARGET)-$(VMAJOR).$(VMINOR).bin | |
3c3744f1 L |
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 | ||
b2017655 FZ |
159 | $(TARGET).hex: $(ASRC) |
160 | $(TARGET).eep: $(ASRC) | |
161 | $(TARGET).lst: $(ASRC) | |
162 | $(TARGET).map: $(ASRC) | |
3c3744f1 | 163 | |
623dd899 | 164 | |
b2017655 | 165 | .SUFFIXES: |
3c3744f1 | 166 | |
623dd899 L |
167 | %-$(VMAJOR).$(VMINOR).bin: %.hex |
168 | $(HEXTOBIN) $< $@ | |
169 | $(CRCGEN) $@ | |
170 | ||
3c3744f1 | 171 | %.hex: %.asm |
623dd899 | 172 | $(AS) $(ASFLAGS) -fI -o $@ $< |
3c3744f1 L |
173 | |
174 | %.lst: %.asm | |
623dd899 | 175 | @$(AS) $(ASFLAGS) -v0 -f- -l $@ $< |
3c3744f1 L |
176 | |
177 | %.map: %.asm | |
623dd899 | 178 | $(AS) $(ASFLAGS) -v0 -f- -m $@ $< |
3c3744f1 L |
179 | |
180 | tags: $(SRC) $(ASRC) | |
181 | ctags $(SRC) $(ASRC) | |
182 | ||
fa9059af | 183 | svnrev.inc: $(ASRC0) |
623dd899 L |
184 | svnrev -osvnrev.inc $^ |
185 | touch svnrev.inc | |
3c3744f1 L |
186 | |
187 | # Target: clean project. | |
188 | clean: | |
623dd899 L |
189 | $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst \ |
190 | $(TARGET)-$(VMAJOR).$(VMINOR).bin | |
3c3744f1 | 191 |