-SRC := bioskrnl.180 boot.180 chario.180 drvtbl.180
-SRC += move.180 misc.180 time.180 mm.180
-SRC += msgbuf.180 conbuf.180 ascip.180 sdio.180
+SRC := bioskrnl.180 boot.180 chario.180
+SRC += msgbuf.180 conbuf.180 ascii.180
+SRC += drvtbl.180 sdio.180 cfio.180 stampf.180
+SRC += move.180 time.180 fifo.180 utils.180 misc.180 mm.180
SRC += scb.180
+ALLSRC := $(SRC) ldrbios.180
-INC := config.inc z180reg.inc z180.lib
+INC := config.inc z180reg.inc z180.lib ioctl.inc
+
+EXTRA_DIST := autorevision.cache version.inc
OBJ := $(SRC:.180=.rel)
+ALLOBJ := $(ALLSRC:.180=.rel)
+ALLLST := $(ALLSRC:.180=.lst)
+
+
+$(foreach X,$(subst =,:=,$(subst ",,$(filter VCS_%,\
+ $(shell autorevision -t sh -o $(CURDIR)/autorevision.cache)))),$(eval $X))
+
+VERS := $(shell echo "$(VCS_TAG)" | sed -e 's/hexrel-/0./g' -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
+
+
+SYSFILE = cpm3_$(VERS).sys
+MAPFILE = bnkbios3_$(VERS).map
+ASYMFILE = bnkbios3_$(VERS).sym
+DIST_NAME = z180-stamp-cpm3_$(VERS).zip
+DIST_NAME_BIN = z180-stamp-cpm3-bin_$(VERS).zip
+PREFIX = z180-stamp-cpm3_$(VERS)
+
+SHELL = /bin/sh
+CP = cp
+RM = rm -f
+GIT = git
+ZIP = zip
#CP/M emulator
CPMEMU = zxcc
#LNKCMD =
LN_VERB = /V
LN_PROG = 0
-LN_DATA = C000
+LN_DATA = F000
.suffixes:
.phony: all
all: sys
+.phony: sys bios map asym ldr
+sys: $(SYSFILE)
bios: bnkbios3.spr
+map: $(MAPFILE)
+asym: $(ASYMFILE)
+ldr: cpmldr.com
+
+cpmldr.com: cpmldr.rel ldrbios.rel
+ ld80 -P 100 -o $@ $^
-sys: cpm3.sys
+$(ALLOBJ): $(INC)
+boot.rel: version.inc
+
+version.inc: autorevision.cache
+ @echo update $@
+ @printf "defvers macro\r\n\
+ db '$(VERS)'\r\n\
+ endm\r\n\032" > $@
-$(OBJ): $(INC)
comma:= ,
empty:=
OUTPUT=$$(mktemp); echo $${COMMAND};\
$${COMMAND} > $${OUTPUT} || exit 1;\
ERROR=0;\
- grep -Ev '^[@?$$. 0-9A-Z]{7} [0-9A-F]{4}' $${OUTPUT};\
- grep -q ':' $${OUTPUT} && ERROR=2; \
+ grep -Ev '^[@?$$._ 0-9A-Z]{7} [0-9A-F]{4}' $${OUTPUT};\
+ grep -Eq ':|UNRECOGNIZED' $${OUTPUT} && ERROR=2; \
[ "$${ERROR}" != "0" ] && rm -f $@; \
exit $${ERROR}
endef
exit $${ERROR}
endef
-cpm3.sys: bnkbios3.spr
- zxcc gencpm -auto
+PSEG = $(call SEGMENT-ADDR, 1)
+DSEG = $(call SEGMENT-ADDR, 2)
+
+#(call SEGMENT-ADDR,SEGNUM)
+SEGMENT-ADDR = $(shell dd if=$(SYSFILE) bs=128 count=1 skip=1 2>/dev/null |\
+ awk -vn=$(strip $1) '/BNKBIOS3/ {if (++seg == n) print $$3}')
+
+$(MAPFILE): $(SYSFILE)
+ ld80 -o /dev/null -ms $@ -P $(PSEG) -D $(DSEG) $(OBJ)
+
+$(ASYMFILE): $(SYSFILE)
+ cvtsym -o $@ -b $< bnkbios3.sym
+
+
+$(SYSFILE): bnkbios3.spr gencpm.dat
+ zxcc gencpm -AUTO
+ @mv cpm3.sys $@
@echo
@$(cpm-asm)
+.phony: bin-dist
+bin-dist: $(SYSFILE) $(MAPFILE) cpmldr.com
+ $(ZIP) -9 $(DIST_NAME_BIN) $(SYSFILE) $(MAPFILE) $(ASYMFILE) cpmldr.com
+
+.phony: dist
+dist: $(SYSFILE) $(MAPFILE) $(ASYMFILE) cpmldr.com
+ $(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) $(SYSFILE) $(MAPFILE) $(ASYMFILE) cpmldr.com
+ @$(RM) -r $(PREFIX)
+
+
.phony: clean realclean
clean:
- rm -f $(OBJ) $(OBJ:.rel=.lst) $(OBJ:.rel=.sym)
+ $(RM) $(ALLOBJ) $(ALLLST) *.sym
realclean: clean
- rm -f *.prn *~
+ $(RM) *.map *.prn *~
#==================================================================