-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (47 loc) · 1.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
CC = sdcc
ASM = sdasz80
PLATFORM = -mz80
EMULATOR = openmsx -machine msx1 -carta
HEXBIN = makebin -s 65536
STARTUPDIR = startups
INCLUDEDIR = includes
LIBDIR = libs
SRCDIR = src
CRT0 = crt0msx.32k.4000.s
ADDR_CODE = 0x4020
ADDR_DATA = 0xC000
#VERBOSE = -V
CCFLAGS = $(VERBOSE) $(PLATFORM) --code-loc $(ADDR_CODE) --data-loc $(ADDR_DATA) \
--no-std-crt0 --out-fmt-ihx --opt-code-size
OBJECTS = $(CRT0)
SOURCES = main.c
OUTFILE = test.rom
.PHONY: all compile build clean emulator
all: clean compile build
compile: $(OBJECTS) $(SOURCES)
$(CRT0):
@echo "Compiling $(CRT0)"
@$(ASM) -o $(notdir $(@:.s=.rel)) $(STARTUPDIR)/$(CRT0)
%.s:
@echo "Compiling $@"
@[ -f $(LIBDIR)/$@ ] && $(ASM) -o $(notdir $(@:.s=.rel)) $(LIBDIR)/$@ || true
@[ -f $(SRCDIR)/$@ ] && $(ASM) -o $(notdir $(@:.s=.rel)) $(SRCDIR)/$@ || true
%.c:
@echo "Compiling $@"
@[ -f $(LIBDIR)/$@ ] && $(CC) $(VERBOSE) $(PLATFORM) -I$(INCLUDEDIR) -c -o $(notdir $(@:.c=.rel)) $(LIBDIR)/$@ || true
@[ -f $(SRCDIR)/$@ ] && $(CC) $(VERBOSE) $(PLATFORM) -I$(INCLUDEDIR) -c -o $(notdir $(@:.c=.rel)) $(SRCDIR)/$@ || true
$(SOURCES):
$(CC) -I$(INCLUDEDIR) $(CCFLAGS) \
$(addsuffix .rel, $(basename $(notdir $(OBJECTS)))) \
$(SRCDIR)/$(SOURCES)
build: main.ihx
@echo "Building $(OUTFILE)..."
@$(HEXBIN) main.ihx $(OUTFILE).tmp
@dd skip=16384 count=32768 if=$(OUTFILE).tmp of=$(OUTFILE) bs=1 status=none
@rm $(OUTFILE).tmp
@echo "Done."
clean:
@echo "Cleaning..."
@rm -f $(OUTFILE) *.asm *.bin *.cdb *.ihx *.lk *.lst *.map *.mem *.omf *.rst *.rel *.sym *.noi *.hex *.lnk *.dep
emulator: $(OUTFILE)
$(EMULATOR) $(OUTFILE) &