Subversion Repositories pentevo

Rev

Rev 625 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 lvd 1
###############################################################################
189 lvd 2
# Makefile for the project pentevo
6 lvd 3
###############################################################################
4
 
5
## General Flags
6
PROJECT = core
7
MCU = atmega128
8
TARGET = core.elf
189 lvd 9
CC = avr-gcc
6 lvd 10
 
11
## Options common to compile, link and assembly rules
12
COMMON = -mmcu=$(MCU)
13
 
14
## Compile options common for all C compilation units.
15
CFLAGS = $(COMMON)
658 lvd 16
CFLAGS += -Wall -Wextra -gdwarf-2 -std=gnu99 -Os -DF_CPU=11059200UL -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
6 lvd 17
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
18
 
19
## Assembly specific flags
20
ASMFLAGS = $(COMMON)
21
ASMFLAGS += $(CFLAGS)
22
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
23
 
24
## Linker flags
25
LDFLAGS = $(COMMON)
26
LDFLAGS +=  -Wl,-Map=core.map
27
 
28
 
29
## Intel Hex file production flags
30
HEX_FLASH_FLAGS = -R .eeprom
31
 
32
HEX_EEPROM_FLAGS = -j .eeprom
33
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
34
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
35
 
36
 
37
## Objects that must be built in order to link
219 chrv 38
OBJECTS = zx.o interrupts.o main.o ps2.o spi.o depacker_dirty.o rs232.o rtc.o atx.o joystick.o version.o tape.o kbmap.o
6 lvd 39
 
40
## Objects explicitly added by the user
41
#LINKONLYOBJECTS = fpga.o
42
FPGACORE = top.o
43
 
44
## Build
253 ddp 45
all: $(TARGET) core.hex core.eep core.lss size zxevo_beta.bin
46
	mv zxevo_beta.bin zxevo_fw.bin
6 lvd 47
 
236 lvd 48
release: $(TARGET) core.hex core.eep core.lss size zxevo_release.bin
253 ddp 49
	mv zxevo_release.bin zxevo_fw.bin
236 lvd 50
 
6 lvd 51
## Compile
52
zx.o: ../zx.c ../zx.h
53
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
54
 
55
interrupts.o: ../interrupts.c
56
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
57
 
58
main.o: ../main.c
59
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
60
 
61
ps2.o: ../ps2.c ../ps2.h
62
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
63
 
64
spi.o: ../spi.c ../spi.h
65
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
66
 
67
depacker_dirty.o: ../depacker_dirty.c ../depacker_dirty.h
68
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
69
 
61 chrv 70
rs232.o: ../rs232.c ../rs232.h
71
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
72
 
73 chrv 73
rtc.o: ../rtc.c ../rtc.h
74
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
61 chrv 75
 
76 chrv 76
atx.o: ../atx.c ../atx.h
77
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
73 chrv 78
 
112 chrv 79
joystick.o: ../joystick.c ../joystick.h
80
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
81
 
179 chrv 82
version.o: ../version.c ../version.h
83
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
84
 
219 chrv 85
tape.o: ../tape.c ../tape.h
86
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
87
 
88
kbmap.o: ../kbmap.c ../kbmap.h
89
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
90
 
6 lvd 91
##Link
92
$(TARGET): $(OBJECTS) $(FPGACORE)
93
	 $(CC) $(LDFLAGS) $(OBJECTS) $(FPGACORE) $(LIBDIRS) $(LIBS) -o $(TARGET)
94
 
424 lvd 95
top.rbf: ../../../fpga/current/quartus/top.rbf
96
	cp ../../../fpga/current/quartus/top.rbf top.rbf
38 lvd 97
 
6 lvd 98
$(FPGACORE): top.rbf
189 lvd 99
	../../../tools/mhmt/mhmt -maxwin2048 top.rbf top.mlz
578 lvd 100
	avr-objcopy -I binary -O elf32-avr -B avr:51 --rename-section .data=.progmem.data,contents,alloc,load,readonly,data --redefine-sym _binary_top_mlz_start=fpga --redefine-sym _binary_top_mlz_end=fpga_end top.mlz top.o
6 lvd 101
 
102
%.hex: $(TARGET)
103
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
104
 
105
%.eep: $(TARGET)
106
	avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
107
 
108
%.lss: $(TARGET)
109
	avr-objdump -h -S $< > $@
110
 
111
size: ${TARGET}
625 ddp 112
	@echo .
6 lvd 113
	@avr-size -C --mcu=${MCU} ${TARGET}
114
 
253 ddp 115
zxevo_beta.bin: core.hex core.eep
116
	../../../tools/make_fw/make_fw core.hex core.eep zxevo_beta.bin version.txt
236 lvd 117
 
118
zxevo_release.bin: core.hex core.eep
253 ddp 119
	../../../tools/make_fw/make_fw core.hex core.eep zxevo_release.bin version.txt o
236 lvd 120
 
6 lvd 121
## Clean target
122
.PHONY: clean
123
clean:
253 ddp 124
	-rm -rf $(OBJECTS) $(FPGACORE) core.* dep/* top.* zxevo_*.bin
6 lvd 125
 
126
## program chip
127
pgm: core.hex
128
	pgm.bat core.hex
129
 
130
 
131
 
132
## Other dependencies
133
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)