バージョン表示機能を追加
[YACASL2.git] / Makefile
index ccc16d7..6e145d7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,38 +1,81 @@
-.PHONY: build check doc doxygen clean gtags htags
-MKDIR = mkdir -p
-DOXYGEN = doxygen
-GTAGS = gtags
-HTAGS = htags
-HTAGSFLAG = --map-file -anosx --tree-view
+.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
 
-build:
-       $(MAKE) -C src
+GTAGS ?= gtags
+RMF ?= rm -f
+WHICH ?= which
+ECHO ?= echo
+INSTALL ?= install
+SED ?= sed
 
-check:
-       @$(MAKE) -sC test/system
+prefix ?= ~
+bindir ?= $(prefix)/bin
+casl2libdir ?= $(prefix)/yacasl2/casl2lib
+
+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
 
-doc:
-       @$(MAKE) -sC doc
+all: build info html gtags
 
-doxygen: htags
-       @$(DOXYGEN)
+build: version
+       $(MAKE) -C src all
 
 gtags:
-       @$(GTAGS)
+       @$(WHICH) $(GTAGS) >/dev/null && $(GTAGS) || $(ECHO) "$(GTAGS): not found"
+
+docall: doc
+       $(MAKE) -C doc all
+
+info:
+       $(MAKE) -C doc info
+
+html:
+       $(MAKE) -C doc html
+
+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)/
+
+uninstall: uninstall-info uninstall-casl2lib
+       $(RMF) $(bindir)/casl2 $(bindir)/comet2 $(bindir)/dumpword
 
-htags: doc/doxygen/html gtags
-       @$(HTAGS) $(HTAGSFLAG) $</
+install-info:
+       $(MAKE) -C doc install-info
 
-doc/doxygen/html:
-       @$(MKDIR) $@
+uninstall-info:
+       @$(MAKE) -C doc uninstall-info
 
-clean:
+install-casl2lib:
+       $(MAKE) -C as/casl2lib install-casl2lib
+
+uninstall-casl2lib:
+       @$(MAKE) -C as/casl2lib uninstall-casl2lib
+
+version: $(VERSIONFILES)
+
+$(VERSIONFILES):
+       for f in $(VERSIONFILES); do $(SED) -e "s/@@VERSION@@/`cat VERSION`/g" $$f.version >$$f; done
+
+clean: clean-src clean-gtags clean-doc clean-doc-inner clean-version
+
+clean-src:
        @$(MAKE) -sC src clean
-       @$(MAKE) -sC test/system/casl2 clean
-       @$(MAKE) -sC test/system/comet2 clean
-       @$(MAKE) -sC test/system/dumpword clean
-       @$(MAKE) -sC test/unit clean
-       @rm -rf doc/doxygen/*
-       @rm -f casl2 comet2 dumpword
-       @rm -f GPATH GRTAGS GSYMS GTAGS
-       @rm -rf HTML
+
+clean-gtags:
+       @$(RMF) GPATH GRTAGS GSYMS GTAGS
+
+clean-doc:
+       @$(MAKE) -sC doc clean
+
+clean-doc-inner:
+       @$(MAKE) -sC doc_inner clean
+
+clean-test:
+       @$(MAKE) -sC test clean
+
+clean-version:
+       @$(RMF) $(VERSIONFILES)