make install機能を追加
[YACASL2.git] / doc / Makefile
index 4be074e..9eb81c3 100644 (file)
@@ -1,41 +1,63 @@
 DOCNAME = yacasl2
 SRC = $(DOCNAME).texi
 CSS = style.css
-TEXBIN = $(dir $(shell which ptex))
-PTEX = $(TEXBIN)/ptex
-TEXINDEX = $(TEXBIN)/texindex
-DVI2PDF = $(TEXBIN)/dvipdfmx
-MAKEINFO = makeinfo
+HTMLDIR = html
 
-.PHONY: all htmlnosplit pdf clean
+MV ?= mv
+CP ?= cp
+MKDIR ?= mkdir
+RMRF ?= rm -rf
+PTEX ?= ptex
+TEXI2DVI ?= texi2dvi
+DVI2PDF ?= dvipdfmx
+MAKEINFO ?= gmakeinfo
+INSTALL ?= install
+INSTALL-INFO ?= ginstall-info
 
-.INTERMEDIATE: yacasl2.dvi
+prefix ?= ~
+infodir ?= $(prefix)/share/info
 
-all: info htmlnosplit html pdf
+.PHONY: all info htmlnosplit html pdf install-info clean clean-docs clean-tex-tmp
 
-htmlnosplit: $(DOCNAME).html
+.INTERMEDIATE: $(DOCNAME).dvi
 
-html: $(SRC) $(CSS)
-       @if test ! -s $@; then mkdir $@; fi;
-       @cp $(CSS) $@/$(CSS)
-       @$(MAKEINFO) -o $@ --html --css-ref=style.css $(SRC)
-
-pdf: $(DOCNAME).pdf
+all: info html htmls pdf
 
 info: $(DOCNAME).info
 
-$(DOCNAME).info: $(SRC)
-       @$(MAKEINFO) -o $@ $^
+html: $(DOCNAME).html
+       $(MV) $< index.html
+
+htmls: $(SRC) $(CSS)
+       $(INSTALL) -d $(HTMLDIR)
+       $(INSTALL) $(CSS) $(HTMLDIR)/
+       $(MAKEINFO) -o $(HTMLDIR) --html --css-ref=$(CSS) $(SRC)
+
+pdf: $(DOCNAME).pdf
 
 $(DOCNAME).html: $(SRC) $(CSS)
-       @$(MAKEINFO) -o $@ --no-split --no-headers --html --css-include=$(CSS) $(SRC)
+       $(MAKEINFO) -o $@ --no-split --html --css-include=$(CSS) $(SRC)
 
 $(DOCNAME).pdf: $(DOCNAME).dvi
-       @$(DVI2PDF) $^
+       $(DVI2PDF) $^
 
 $(DOCNAME).dvi: $(SRC)
-       @TEX=ptex texi2dvi -q --texinfo=@afourpaper -o $@ $<
-       @rm -rf $(DOCNAME).aux $(DOCNAME).cp $(DOCNAME).cps $(DOCNAME).fn $(DOCNAME).ky $(DOCNAME).log $(DOCNAME).pg $(DOCNAME).pgs $(DOCNAME).tmp $(DOCNAME).toc $(DOCNAME).tp $(DOCNAME).vr
+       TEX=$(PTEX) $(TEXI2DVI) -q --texinfo=@afourpaper -o $@ $<
+       @$(MAKE) clean-tex-tmp
+
+install-info: $(DOCNAME).info
+       $(INSTALL) -d $(infodir)
+       $(INSTALL) $(DOCNAME).info $(infodir)/$(DOCNAME)
+       $(INSTALL-INFO) $(infodir)/$(DOCNAME) $(infodir)/dir
+
+uninstall-info: $(DOCNAME).info
+       $(INSTALL-INFO) --delete $(infodir)/$(DOCNAME) $(infodir)/dir
+       $(RM) $(infodir)/$(DOCNAME)
+
+clean: clean-docs clean-tex-tmp
+
+clean-docs:
+       @$(RMRF) html $(DOCNAME).info $(DOCNAME).pdf index.html
 
-clean:
-       @rm -rf html $(DOCNAME).info $(DOCNAME).pdf $(DOCNAME).html $(DOCNAME).dvi
+clean-tex-tmp:
+       @$(RMRF) $(DOCNAME).aux $(DOCNAME).cp $(DOCNAME).cps $(DOCNAME).fn $(DOCNAME).ky $(DOCNAME).log $(DOCNAME).pg $(DOCNAME).pgs $(DOCNAME).tmp $(DOCNAME).toc $(DOCNAME).tp $(DOCNAME).vr