summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLeo C2016-08-14 21:21:56 +0200
committerLeo C2016-08-14 21:21:56 +0200
commit8bc5ea2267aec88cc21937d962c3e077414e2c65 (patch)
treea6567eeba108f5b05945c41d7b294d8f3ee25f3a /Makefile
parent2d914eb7d607546546a41af99ded751e8e416dfb (diff)
downloadddt180-8bc5ea2267aec88cc21937d962c3e077414e2c65.zip
Add version stringv0.2
Minor optimizations (p_fill_space)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 43 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 7694f5b..bdfc336 100644
--- a/Makefile
+++ b/Makefile
@@ -4,12 +4,21 @@ PROG := ddt180
SRC := $(PROG).z80
+EXTRA_DIST := autorevision.cache version.inc
+
OBJ := $(SRC:.z80=.rel)
-AS_OPT := MFS
+DIST_NAME = $(PROG)_$(VERS).zip
+PREFIX = $(PROG)_$(VERS)
-ASM := zxcc slrz80.com
-LINK := zxcc link80.com
+ASM := zxcc slrz80.com
+LINK := zxcc link80.com
+CP := cp
+RM := rm -f
+GIT := git
+ZIP := zip
+
+AS_OPT := MFS
.phony: all
all: $(PROG).com
@@ -23,7 +32,38 @@ $(PROG).com: $(PROG).prl
$(PROG).prl: $(OBJ)
$(LINK) -'$(PROG)[op,$$SZ]'
+$(PROG).rel: version.inc
+
+$(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 $@
+ @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: