summaryrefslogtreecommitdiff
path: root/Makefile
blob: 7694f5ba417461ef9c837bfec5948edd850848e7 (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
# Build ddt180.com from ddt180.z80

PROG	:= ddt180

SRC	:= $(PROG).z80

OBJ	:= $(SRC:.z80=.rel)

AS_OPT	:= MFS

ASM  := zxcc slrz80.com
LINK := zxcc link80.com

.phony: all
all: $(PROG).com



$(PROG).com: $(PROG).prl
	@# Remove the PRL header record (256 bytes)
	dd status=none bs=256 skip=1  if=$< of=$@

$(PROG).prl: $(OBJ)
	$(LINK) -'$(PROG)[op,$$SZ]'



.phony: clean
clean:
	rm -f $(PROG).com *.rel *.lst *.prl

.SUFFIXES:
.SUFFIXES: .z80 .rel .prl


define cpm-asm =
COMMAND="$(ASM) -$(basename $<)/$(AS_OPT)"; \
OUTPUT=$$(mktemp); echo $${COMMAND}; \
$${COMMAND} > $${OUTPUT}; \
grep -q '^ 0 Error(s) Detected' $${OUTPUT}; ERROR=$$? ; \
if [ "$${ERROR}" != "0" ]; then cat $${OUTPUT}; rm -f $@; fi ; \
exit $${ERROR}
endef

%.rel %lst: %.z80
	@$(cpm-asm)