Skip to content

Commit 1690979

Browse files
committed
Improve Makefiles.
Add `maintcheck' to root Makefile for automatic code sanity check. Add `revbump' to root Makefile for revision bumping.
1 parent 5e03865 commit 1690979

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

Makefile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# vim:ft=make:ts=4:sw=4
22

33
TITLE = pkuthss
4-
VERSION = 1.4alpha1
5-
PROJECT = $(TITLE)-$(VERSION)
6-
DIST_DOC = $(PROJECT)/doc
7-
DOC_UTF8LF = $(DIST_DOC)/utf8lf
8-
DOC_GBKCRLF = $(DIST_DOC)/gbkcrlf
4+
MAJORVER = 1.4
5+
MINORVER = alpha1
96
README = README
107
TOLF = dos2unix -q
118
TOCRLF = unix2dos -q
129
# VCS directories are unwanted in packaged releases.
1310
FIND_VCSDIR = -type d -name '.git' -prune
14-
FIND_FILENOVCS = -not \( $(FIND_VCSDIR) \) -type f
11+
12+
NUMDATE = $(shell date +%Y/%m/%d)
13+
CNDATE = $(shell python3 -c 'print("$(shell date +%Y年%-m月)".translate(str.maketrans("0123456789", "〇一二三四五六七八九")))')
14+
15+
VER_GEN = $(if $(MINORVER),$(MAJORVER)$(1)$(MINORVER),$(MAJORVER))
16+
PROJECT = $(TITLE)-$(call VER_GEN,)
17+
DIST_DOC = $(PROJECT)/doc
18+
DOC_UTF8LF = $(DIST_DOC)/utf8lf
19+
DOC_GBKCRLF = $(DIST_DOC)/gbkcrlf
20+
FIND_FILENOVCS = -not '(' $(FIND_VCSDIR) ')' -type f
1521

1622
dist: dist-clean
1723
make dist-dir
@@ -48,5 +54,24 @@ dist-clean:
4854
cd doc && make dist-clean && cd -
4955
rm -rf $(PROJECT)/ $(PROJECT).zip
5056

51-
.PHONY: dist-clean
57+
maintcheck:
58+
@echo '========================================================================'
59+
@echo '$@: keep GBK and UTF-8 files synchronised'
60+
@echo '========================================================================'
61+
iconv -f GBK tex/pkuthss-gbk.def | diff - tex/pkuthss-utf8.def || true
62+
@echo '========================================================================'
63+
@echo '$@: use "模版" instead of "模板"'
64+
@echo '========================================================================'
65+
grep -r '模板' . || true
66+
@echo '========================================================================'
67+
@echo '$@: remember to update documentation after modifications'
68+
@echo '========================================================================'
69+
70+
revbump:
71+
sed -i '/\\Provides/,+1 s;\[[^ ]* [^ ]*;[$(NUMDATE) v$(call VER_GEN,-);g' tex/*
72+
sed -i '/\\newcommand{\\docversion}/ s;{[^{}]\+}$$;{v$(call VER_GEN, )};g' doc/pkuthss.tex
73+
sed -i '/date = / s;{[^{}]\+},$$;{$(CNDATE)},;g' doc/pkuthss.tex
74+
@echo '$@: remember to update the ChangeLog'
75+
@echo '$@: remember to tag the commit'
76+
@echo '$@: remember to use `git push --tags'\'
5277

doc/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,3 @@ clean:
5656
dist-clean: clean img-clean
5757
$(RM) $(JOBNAME).pdf
5858

59-
.PHONY: img img-clean clean dist-clean
60-

0 commit comments

Comments
 (0)