-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
62 lines (51 loc) · 1.85 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
59
60
61
62
CC = sdcc
ASM = sdasz80
PLATFORM = -mz80
EMULATOR = /Applications/openMSX.app/Contents/MacOS/openmsx -machine Philips_NMS_8255 -ext msxdos2 -diska emulation/msx-dos2/ -script emulation/boot.tcl -diskb bin/
#EMULATOR = /Applications/openMSX.app/Contents/MacOS/openmsx -machine C-BIOS_MSX2 -carta
HEXBIN = hex2bin
STARTUPDIR = startups
INCLUDEDIR = includes
LIBDIR = libs
SRCDIR = src
# See startup files for the correct ADDR_CODE and ADDR_DATA
CRT0 = crt0msx_msxdos_advanced.s
ADDR_CODE = 0x0107
ADDR_DATA = 0
VERBOSE = -V
CCFLAGS = $(VERBOSE) $(PLATFORM) --code-loc $(ADDR_CODE) --data-loc $(ADDR_DATA) \
--no-std-crt0 --opt-code-size --out-fmt-ihx
OBJECTS = $(CRT0) putchar.s getchar.s dos.s conio.c
SOURCES = main.c
OUTFILE = main.com
.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
@mv main.bin bin/${OUTFILE}
@echo "Done."
clean:
@echo "Cleaning ...."
rm -f *.asm *.bin *.cdb *.ihx *.lk *.lst *.map *.mem *.omf *.rst *.rel *.sym *.noi *.hex *.lnk *.dep
rm -f bin/$(OUTFILE)
emulator: $(OUTFILE)
$(EMULATOR) &
#For ROM use:
#$(EMULATOR) $(OUTFILE) &