.gitignoreを、latex用と汎用に分離
[makefiles.git] / latex_mk / test / toc_hyperref / Makefile
index 170b540..4b63a53 100644 (file)
@@ -1,20 +1,42 @@
 TEXTARGETS := toc_hyperref.pdf
 
+CMP := cmp -s
+DIFF := diff
+PATCH := patch
+
 .PHONY: all update rebase clean distclean
 
-all: $(TEXTARGETS)
+$(TEXTARGETS):
 
-update: toc_hyperref.tex
-       $(CP) toc_hyperref.tex.6th toc_hyperref.tex
+all:
+       @$(MAKE) -s toc_hyperref_1.pdf
+       @$(ECHO) '--------------------'
+       @$(MAKE) -s toc_hyperref_2.pdf
 
-rebase:
-       $(CP) toc_hyperref.tex.5th toc_hyperref.tex
+toc_hyperref_1.pdf: rebase
+       @$(ECHO) '---------- $@: $^ ----------'
+       @$(MAKE) -s toc_hyperref.pdf
+       @$(CP) -v toc_hyperref.pdf $@
+
+toc_hyperref_2.pdf: update
+       @$(ECHO) '---------- $@: $^ ----------'
+       @$(MAKE) -s toc_hyperref.pdf
+       @$(CP) -v toc_hyperref.pdf $@
 
-toc_hyperref.tex: toc_hyperref.tex.5th
-       $(CP) $< $@
+update: toc_hyperref.tex.6th.patch
+       @$(PATCH) <$<
+
+toc_hyperref.tex.6th.patch:
+       @$(MAKE) -s rebase
+       @$(DIFF) -u toc_hyperref.tex toc_hyperref.tex.6th >$@ || exit 0
+
+rebase:
+       $(CMP) toc_hyperref.tex.5th toc_hyperref.tex || $(CP) -v toc_hyperref.tex.5th toc_hyperref.tex
 
 include latex.mk
 
 clean: tex-clean
 
-distclean: tex-distclean
+distclean: rebase tex-distclean
+       $(RM) *.patch
+       $(RM) toc_hyperref_*.pdf