# Build ddt180.com from ddt180.z80 CPM := 0 PROG := ddt180 OBJ := $(PROG).rel ifneq ($(CPM),0) SUFFIX := z80 else SUFFIX := 180 endif CURCPM := $(shell awk -e '/CPM/ {print $$3}' config.inc 2>/dev/null) ifneq ($(CPM),$(CURCPM)) $(shell printf " CPM equ $(CPM)\r\n\032" > config.inc) endif EXTRA_DIST := autorevision.cache version.inc DIST_NAME = $(PROG)_$(VERS).zip PREFIX = $(PROG)_$(VERS) ASM := zxcc slr$(SUFFIX).com LINK := zxcc link80.com CP := cp RM := rm -f GIT := git ZIP := zip AS_OPT := MFSX .PHONY: all all: $(PROG).com prl2offz .INTERMEDIATE: $(PROG).180 $(PROG).180: $(PROG).z80 cp $< $@ $(PROG).com: $(PROG).prl Makefile prl2offz @# Convert relocation bitmap to compressed list of offsets ./prl2offz $< $@ $(PROG).prl: $(OBJ) $(LINK) -'$(PROG)[op]' $(PROG).rel: config.inc version.inc prl2offz: prl2offz.c gcc -Wall -Wextra -O2 -g -o $@ $< $(foreach X,$(subst =,:=,$(subst ",,$(filter VCS_%,\ $(shell autorevision -t sh -o $(CURDIR)/autorevision.cache)))),$(eval $X)) VERS := $(shell echo "$(VCS_TAG)" | sed -e 's/^v//g') ifneq ($(VCS_TICK),0) VERS := $(VERS)-$(VCS_TICK) endif ifneq ($(VCS_BRANCH),master) VERS := $(VERS)-$(VCS_BRANCH) endif ifeq ($(VCS_WC_MODIFIED),1) VERS := $(VERS)-dirty endif version.inc: autorevision.cache @echo update $@ to $(VERS) @printf "defvers macro\r\n\ db '$(VERS)'\r\n\ endm\r\n\032" > $@ .PHONY: dist dist: $(PROG).com version.inc $(GIT) archive --format=zip --prefix=$(PREFIX)/ -9 -o $(DIST_NAME) HEAD^{tree} @mkdir -p $(PREFIX) @$(CP) -p $(EXTRA_DIST) $(PREFIX) $(ZIP) -r -9 $(DIST_NAME) $(PREFIX) $(PROG).com @$(RM) -r $(PREFIX) .PHONY: clean clean: rm -f $(PROG).com $(PROG).180 *.rel *.lst *.prl .SUFFIXES: .SUFFIXES: .z80 .180 .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 $@; \ else awk -f filter-unref.awk ddt180.lst; fi ; \ exit $${ERROR} endef %.rel %lst: %.$(SUFFIX) @$(cpm-asm)