blob: 44ae3978f6e3a91fc4f9ec533d7775f778b56734 (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# these files are written as .s
ASM_FILES=alu.s flags.s ports.s main.s
# these files are written as .s.m4 and then preprocessed to .s
M4_ASM_OUTPUT=opcodes.s interrupts.s
M4_ASM_INCLUDES=opcodes.inc.m4
# this is the set of file(s) which is fed to the assembler, and uses
# INCLUDE directives to include the rest of assembly source.
ASM=main.s
C_HEADERS=global.h asm_vars.h
C_FILES=loader.c bankswap.c video.c misc.c debug.c
S_FILES=loader.s bankswap.s video.s misc.s debug.s
O_FILES=loader.o bankswap.o video.o misc.o debug.o main.o
# temporary, for including z80 code in the final binary
MADE_FILES=testbenches/mine.testbench.h testbenches/zexdoc.testbench.h
MADE_BINS=testbenches/mine.testbench.bin testbenches/zexdoc.testbench.bin
# final output files
LISTING_DEBUG=z680d.listing
BINS_DEBUG=z680d.dbg
OBJ_DEBUG=z680d.89z
OBJ=z680k.89z
# executables to build for the host platform
NATIVE_OBJ=packager
# this is the Sierra linker from the TI Flash Studio SDK. It works
# quite well under Wine, and is a purely command-line tool.
LINKER=wine ~/.wine/drive_c/SIERRA/BIN/link68.exe
ASFLAGS=--register-prefix-optional
# flags for the tigcc cross-compiler
TIGCCFLAGS_DEBUG=--debug -WA,-l$(LISTING_DEBUG)
TIGCCFLAGS=-falign-functions=4 -ffunction-sections -fdata-sections -Wall -Wextra -Wwrite-strings -Wa,$(ASFLAGS)
#-Wa,-ahls # -- for listings
# flags for the native C compiler
CFLAGS=-Wall -ltifiles
.PHONY: clean debug
all: $(OBJ) $(NATIVE_OBJ)
clean:
rm -f $(S_FILES) $(O_FILES) $(M4_ASM_OUTPUT) $(MADE_FILES) $(MADE_BINS) $(BINS_DEBUG) $(OBJ) $(OBJ_DEBUG) $(NATIVE_OBJ) $(LISTING_DEBUG) $(OBJ)
debug: $(OBJ_DEBUG)
$(OBJ): $(O_FILES)
$(LINKER) $(O_FILES) -o $(OBJ)
# tigcc $(TIGCCFLAGS) $(ASM) $(C_FILES) -o $(OBJ)
$(OBJ_DEBUG): $(ASM_FILES) $(M4_ASM_OUTPUT) $(C_FILES) $(MADE_FILES) $(C_HEADERS)
tigcc $(TIGCCFLAGS) $(TIGCCFLAGS_DEBUG) $(ASM) $(C_FILES) -o $(OBJ_DEBUG)
# use the host system's native gcc for this
# utility to turn a romdump into a set of image files
packager: packager.c
gcc $(CFLAGS) packager.c -o packager
# preprocess asm files using m4 as necessary
%.s: %.s.m4
m4 $(M4_ASM_INCLUDES) $< > $@
# assemble z80 code
%.testbench.bin: %.testbench.z80
spasm $(*D)/$(*F).testbench.z80
# process a z80 binary into a header for inclusion into a 68k .c file
%.testbench.h: %.testbench.bin
echo 'char testbench[] = {' > $(*D)/$(*F).testbench.h
hexdump -v -e '12/1 "0x%02x, "' -e '"\n"' $(*D)/$(*F).testbench.bin | sed -e 's/0x *,//g' >> $(*D)/$(*F).testbench.h
echo '};' >> $(*D)/$(*F).testbench.h
loader.o: loader.c asm_vars.h global.h image.h testbenches/zexdoc.testbench.h
tigcc -c $(TIGCCFLAGS) loader.c -o loader.o
bankswap.o: bankswap.c asm_vars.h
tigcc -c $(TIGCCFLAGS) bankswap.c -o bankswap.o
video.o: video.c
tigcc -c $(TIGCCFLAGS) video.c -o video.o
misc.o: misc.c asm_vars.h
tigcc -c $(TIGCCFLAGS) misc.c -o misc.o
debug.o: debug.c
tigcc -c $(TIGCCFLAGS) debug.c -o debug.o
main.o: main.s global.inc tios.inc ports.s interrupts.s flags.s alu.s opcodes.s
tigcc -c $(TIGCCFLAGS) main.s -o main.o
|