From: j8takagi Date: Sat, 13 Jun 2026 08:11:35 +0000 (+0900) Subject: Makefileの修正 X-Git-Url: https://www.j8takagi.net/gitweb?a=commitdiff_plain;h=fb8e1409c4f23e1ae843c88f1c199352164fbe62;p=autotest_mk.git Makefileの修正 --- diff --git a/.gitignore b/.gitignore index 4d73bda..16498d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.log 1.txt sample/sort/sort.c +*___stamp diff --git a/Makefile b/Makefile index e4d3465..442c759 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,20 @@ -CAT := cat -GIT := git -PRINTF := printf -WC = wc -XARGS := xargs +.PHONY: release docbase docall gitpush gittag clean distclean -VERSION := $(shell $(CAT) VERSION) +release: -VERSIONGITREF := $(shell $(GIT) show-ref -s --tags $(VERSION)) - -MAINGITREF := $(shell $(GIT) show-ref -s refs/heads/main) - -.PHONY: docall gittag version - -doc: +docbase: $(MAKE) -C doc base docall: $(MAKE) -C doc all -gittag: - if test `$(GIT) status -s | $(WC) -l` -gt 0; then $(PRINTF) "Error: commit, first.\n"; exit 1; fi; if test "$(VERSIONGITREF)" != "$(MAINGITREF)"; then $(GIT) tag $(VERSION); fi +gitpush: gitpush___stamp + +gittag: gittag___stamp + +include git.mk + +distclean: clean -version: VERSION - @$(PRINTF) "Autotest.mk Version: $(VERSION)" +clean: gitclean + $(MAKE) -C doc clean diff --git a/VERSION b/VERSION index b05cf89..025ae89 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2p26 +v0.2p27 diff --git a/git.mk b/git.mk new file mode 100644 index 0000000..2e9d8f8 --- /dev/null +++ b/git.mk @@ -0,0 +1,32 @@ +CAT := cat +EXPR := expr +GIT := git +PRINTF := printf +SED := sed + +# VERSION FORMAT: vp (Example: v0.1p00) +VERSION = $(shell $(CAT) VERSION) +VERSIONNO = $(shell $(CAT) VERSION | $(SED) 's/v\([0-9]*\.[0-9]*\)p.*$$/\1/' ) +PATCHNO = $(shell $(CAT) VERSION | $(SED) 's/^.*p//' ) + +gitpush___stamp: gittag___stamp + $(GIT) push origin main --follow-tags + $(GIT) push github main --follow-tags + $(GIT) rev-parse HEAD > $@ + +gittag___stamp: commit___stamp + $(GIT) tag $(VERSION) main + $(PRINTF) "%s\n" "$(VERSION)" > $@ + +commit___stamp: version_up___stamp + $(GIT) add VERSION + $(GIT) commit + $(GIT) rev-parse HEAD > $@ + +version_up___stamp: VERSION + if [ -n "$$($(GIT) status -s)" ]; then $(PRINTF) "Error: commit, first.\n"; exit 1; fi + while $(GIT) rev-parse -q --verify $$($(CAT) VERSION) >/dev/null 2>&1; do $(PRINTF) "v%sp%s\n" $(VERSIONNO) $$($(EXPR) $(PATCHNO) + 1) >$<; done + $(CAT) $< >$@ + +gitclean: + $(RM) *___stamp