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
AS_OPT := MFSX
-.phony: all
-all: $(PROG).com
+.PHONY: all
+all: $(PROG).com prl2offz
-.intermediate: $(PROG).180
+.INTERMEDIATE: $(PROG).180
$(PROG).180: $(PROG).z80
cp $< $@
-$(PROG).com: $(PROG).prl Makefile
- @# Remove the PRL header record (256 bytes)
- dd status=none bs=256 skip=1 if=$< of=$@
+$(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 := $(VERS)-dirty
endif
-
-
version.inc: autorevision.cache
@echo update $@ to $(VERS)
@printf "defvers macro\r\n\
db '$(VERS)'\r\n\
endm\r\n\032" > $@
-config.inc: Makefile
- @printf "\
- CPM equ $(CPM)\r\n\
- \032" > $@
-
-.phony: dist
+.PHONY: dist
dist: $(PROG).com version.inc
$(GIT) archive --format=zip --prefix=$(PREFIX)/ -9 -o $(DIST_NAME) HEAD^{tree}
@mkdir -p $(PREFIX)
$(ZIP) -r -9 $(DIST_NAME) $(PREFIX) $(PROG).com
@$(RM) -r $(PREFIX)
-.phony: clean
+.PHONY: clean
clean:
rm -f $(PROG).com $(PROG).180 *.rel *.lst *.prl
define cpm-asm =
COMMAND="$(ASM) -$(basename $<)/$(AS_OPT)"; \
OUTPUT=$$(mktemp); echo $${COMMAND}; \
-$${COMMAND} > $${OUTPUT}; \
+$${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 ; \