]> cloudbase.mooo.com Git - ddt180.git/blobdiff - Makefile
New relocator
[ddt180.git] / Makefile
index 0d11916b6a756f670ceb3e69c725be0cf9208857..4fb0f3e702635aae39f255efdec160c29f9646eb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,11 @@ ifneq ($(CPM),0)
 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
 
@@ -26,23 +31,26 @@ ZIP := zip
 
 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))
 
@@ -58,20 +66,13 @@ 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" > $@
 
-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)
@@ -79,7 +80,7 @@ dist: $(PROG).com version.inc
        $(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
 
@@ -90,7 +91,7 @@ clean:
 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 ; \