-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
136 lines (95 loc) · 2.94 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
TARGET := xtramtest
ROMS = $(TARGET).8k $(TARGET).32k $(TARGET).64k
.DEFAULT: all
all: $(TARGET).bin $(ROMS) loadxtrt.com
loadxtrt.com: xtramtest.bin
# create a user name to indicate who compiled this
USER_ID := $(shell gh api user -q ".login" 2>/dev/null || git config --get user.email 2>/dev/null || echo local_user)
# get a branch name if it is not main or master
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo local)
ifeq ($(BRANCH),main)
BRANCH :=
endif
ifeq ($(BRANCH),master)
BRANCH :=
endif
ifneq ($(BRANCH),)
BRANCH := $(BRANCH)/
endif
# create a version string, including branch if it is not main or master
ifndef VERSION
VERSION := $(BRANCH)$(shell git describe --tags --always --dirty=+ --broken=-XX 2>/dev/null || echo local)
endif
ifeq ($(VERSION),)
VERSION := local
endif
# print the version string if this is not a make restart
$(if $(MAKE_RESTARTS),,$(info -- $(TARGET) $(VERSION) -- $(USER_ID) --))
# functions to create define options for nasm
defined = $(findstring undefined,$(origin $(1)))
DEFLIST = VERSION SHOWSTACK
# export $(DEFLIST)
VARDEF = $(if $(call defined,$(1)),,-d$(1)$(if $(value $(1)),="$(value $(1))"))
DEFS := $(foreach var,$(DEFLIST),$(call VARDEF,$(var)))
INC := -iinc
vpath % inc
SRC := $(TARGET).asm
NASM := nasm
DOSBOXX := dosbox-x
MAME := mame
SHASUM := shasum
RAM = 256
CYCLES = 4000
VIDEO = cga
export RAM VIDEO BREAK FLAGS
%.com: %.asm %.dep Makefile
$(NASM) $(INC) -f bin -o $@ -l $(@:%.com=%.lst) -Lm $(DEFS) $<
$(info )
@if [ -f $(@:%.com=%.map) ]; then tools/size $(@:%.com=%.map); fi
@$(SHASUM) $@
%.bin: %.asm %.dep Makefile
$(NASM) $(INC) -f bin -o $@ -l $(@:%.bin=%.lst) -Lm $(DEFS) $<
$(info )
@tools/size $(@:%.bin=%.map)
@$(SHASUM) $@
%.8k: %.bin
@tools/makerom $@
@$(SHASUM) $@
%.32k: %.bin
@tools/makerom $@
@$(SHASUM) $@
%.64k: %.bin
@tools/makerom $@
@$(SHASUM) $@
# $(ROMS): $(TARGET).bin
# tools/makerom $(ROMS)
# @echo
# @$(SHASUM) $^ $(ROMS)
# @echo
tidy:
rm -f $(ROMS) $(TARGET).bin $(TARGET).lst $(TARGET).map $(TARGET).debug loadxtrt.com loadxtrt.lst loadxtrt.map
clean: tidy
rm -f $(TARGET).dep
%.dep: %.asm
$(NASM) $(INC) -M -MF $@ -MT $@ $<
%.map: %.bin
@true
%.debug: %.map
tools/make_debugscript $< > $@
debug: DEBUG = -debug
debug: $(TARGET).debug run
run: all
$(MAME) ibm5160 -inipath ./test -isa1 $(VIDEO) -ramsize $(RAM)K $(DEBUG) $(FLAGS)
runx: all
$(DOSBOXX) -conf test/dosbox-x.conf --set "dosbox memsizekb=$(RAM)" --set "cpu cycles=$(CYCLES)" -machine $(VIDEO) $(FLAGS) -c "boot --bios b:xtramtest.8k" 2>/dev/null
runcom: all
$(DOSBOXX) -conf test/dosbox-x.conf --set "dosbox memsizekb=$(RAM)" --set "cpu cycles=$(CYCLES)" -machine $(VIDEO) $(FLAGS) -c "b:loadxtrt.com" 2>/dev/null
romburn: all
minipro -p 'W27C512@DIP28' -w $(TARGET).64k
romemu: all
eprom -mem 27256 $(TARGET).32k
.PHONY: all binaries clean run romburn romemu version debug deps
.NOTINTERMEDIATE:
# all: version $(ROMS)
deps: $(TARGET).dep
-include $(TARGET).dep