-.PHONY: all build gtags check doc info html doc-inner install uninstall install-info uninstall-info install-casl2lib uninstall-casl2lib version clean clean-src clean-gtags clean-test clean-doc clean-doc-inner
+.PHONY: all build gtags \
+ check valgrind \
+ doc alldoc doc_inner \
+ install uninstall \
+ version gittag \
+ clean src-clean gtags-clean \
+ test-clean doc-clean doc_inner-clean
+CMD := casl2 comet2 dumpword casl2rev
+
+CAT := cat
+CP := cp
+ECHO := /bin/echo
+EXPR := expr
+GIT := git
+GREP := grep
GTAGS := gtags
-RMF := rm -f
-WHICH := which
-ECHO := echo
INSTALL := install
SED := sed
-CAT := cat
+WC := wc
+WHICH := which
+XARGS := xargs
prefix ?= ~
bindir ?= $(prefix)/bin
+libdir ?= $(prefix)/share
+
+VERSION := $(shell $(CAT) VERSION)
+
+VERSIONGITREF := $(shell $(GIT) show-ref -s --tags $(VERSION))
+
+MASTERGITREF := $(shell $(GIT) show-ref -s refs/heads/master)
-VERSIONFILES = include/package.h test/system/casl2/opt_v/0.txt test/system/comet2/opt_v/0.txt test/system/dumpword/opt_v/0.txt
+VERSIONFILES = include/version.h \
+ test/system/casl2_opt/opt_v/0.txt \
+ test/system/comet2_opt/opt_v/0.txt \
+ test/system/dumpword/opt_v/0.txt
-all: build docall gtags
+all: build INSTALL gtags
build:
$(MAKE) -C src all
+ $(CP) $(addprefix src/,$(CMD)) ./
gtags:
- @$(WHICH) $(GTAGS) >/dev/null && $(GTAGS) || $(ECHO) "$(GTAGS): not found"
+ $(if $(strip $(shell $(WHICH) $(GTAGS))),$(GTAGS),@$(ECHO) '$(GTAGS): not found')
-docall:
- $(MAKE) -C doc all
+INSTALL: doc/install.txt
+ $(CP) $< $@
-info:
- $(MAKE) -C doc info
+doc/install.txt:
+ $(MAKE) -C doc base
-html:
- $(MAKE) -C doc html
+alldoc:
+ $(MAKE) -C doc all
-doc-inner:
+doc_inner:
$(MAKE) -C doc_inner all
check:
$(MAKE) -sC test/system
-install: casl2 comet2 dumpword install-info install-casl2lib
- $(INSTALL) -d $(bindir)
- $(INSTALL) casl2 comet2 dumpword $(bindir)/
+valgrind:
+ $(MAKE) -sC test/system valgrind
-uninstall: uninstall-info uninstall-casl2lib
- $(RMF) $(bindir)/casl2 $(bindir)/comet2 $(bindir)/dumpword
+install: casl2 comet2 dumpword install-info
+ $(INSTALL) -d $(bindir)
+ $(INSTALL) $(CMD) $(bindir)/
install-info:
$(MAKE) -C doc install-info
-uninstall-info:
- @$(MAKE) -C doc uninstall-info
+uninstall: uninstall-info
+ $(RM) $(prefix $(bindir)/,$(CMD))
-install-casl2lib:
- $(MAKE) -C as/casl2lib install-casl2lib
+version: $(VERSIONFILES)
+ @$(ECHO) "YACASL2 Version: $(VERSION)"
-uninstall-casl2lib:
- @$(MAKE) -C as/casl2lib uninstall-casl2lib
+$(VERSIONFILES): VERSION
+ @$(SED) -e "s/@@VERSION@@/$(VERSION)/g" $@.version >$@
-version: VERSION $(VERSIONFILES)
- @$(ECHO) "YACASL2 Version:" `$(CAT) VERSION`
+gittag:
+ if test `$(GIT) status -s | $(WC) -l` -gt 0; then $(ECHO) "Error: commit, first."; exit 1; fi; if test "$(VERSIONGITREF)" != "$(MASTERGITREF)"; then $(GIT) tag $(VERSION); fi
-$(VERSIONFILES): VERSION
- $(SED) -e "s/@@VERSION@@/`cat VERSION`/g" $@.version >$@
+distclean: cmd-clean src-distclean gtags-clean version-clean clean
+
+clean: src-clean doc-clean doc_inner-clean
+
+cmd-clean:
+ $(RM) $(CMD)
-clean: clean-src clean-gtags clean-doc clean-doc-inner clean-version
+src-clean:
+ $(MAKE) -sC src clean
-clean-src:
- @$(MAKE) -sC src clean
+src-distclean:
+ $(MAKE) -sC src distclean
-clean-gtags:
- @$(RMF) GPATH GRTAGS GSYMS GTAGS
+gtags-clean:
+ $(RM) GPATH GRTAGS GSYMS GTAGS
-clean-doc:
- @$(MAKE) -sC doc clean
+doc-clean:
+ $(MAKE) -sC doc clean
-clean-doc-inner:
- @$(MAKE) -sC doc_inner clean
+doc_inner-clean:
+ $(MAKE) -sC doc_inner clean
-clean-test:
- @$(MAKE) -sC test clean
+version-clean:
+ $(RM) $(VERSIONFILES)
-clean-version:
- @$(RMF) $(VERSIONFILES)
+test-clean:
+ $(MAKE) -sC test clean