X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=latex_mk%2Flatex.mk;h=80453b8db24cec82970b8c97feffdc9928f6ecba;hb=32a3029baaff2e40bbda70867592079e0d9e5f20;hp=554e5ccbeb83cd82377f9a119e664e432b4b398d;hpb=02fb4f9c6ea56ebed19b322f980dc9a4e44aaf7e;p=makefiles.git diff --git a/latex_mk/latex.mk b/latex_mk/latex.mk index 554e5cc..80453b8 100644 --- a/latex_mk/latex.mk +++ b/latex_mk/latex.mk @@ -20,7 +20,7 @@ # # == 擬似ターゲット == # - tex-clean: TeX中間ファイル(auxなど)を削除。ターゲットに.dviが含まれていないときは.dviファイルを削除 -# - xbb-clean: バウンディング情報ファイル(.xbb)を削除 +# - tex-xbb-clean: バウンディング情報ファイル(.xbb)を削除 # - tex-distclean: TeX中間ファイル、バウンディング情報ファイル、ターゲットファイル(PDF、.dvi)を削除 # # === Makefile -- sample === @@ -30,10 +30,13 @@ # # include latex.mk -#debug -#SHELL = /bin/sh -x +# シェルスクリプトをデバッグするときは、DEBUGSH変数を設定してmakeを実行する +# 例: DEBUGSH=1 make +ifdef DEBUGSH + SHELL := /bin/sh -x +endif -.PHONY: tex-warning tex-xbb tex-clean tex-distclean +.PHONY: tex-warn tex-xbb tex-clean tex-distclean # シェルコマンド CAT := cat @@ -135,11 +138,12 @@ GRAPHICFILESre = $(eval GRAPHICFILES := \ $(shell \ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(TEXFILES) | \ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \ - $(SED) -n -e 's/\\includegraphics\(\[[^]]*\]\)\{0,1\}{[^}]*}/&\n/pg' | \ - $(SED) -n -e 's/.*{\([^}]*\)}$$/\1/p' \ + $(SED) -e 's/\\verb|[^|]*|//g' | \ + $(SED) -e 's/}/}%/g' | $(SED) -e 'y/}%/}\n/' | \ + $(SED) -n -e 's/.*\\includegraphics\(\[[^]]*\]\)\{0,1\}{\([^}]*\)}$$/\2/pg' \ ) \ $(filter $(addprefix %,$(GRAPHICSEXT)),$(INPUTFILES)) \ -)) + )) # そのほかの読み込みファイル OTHERFILES = \ @@ -150,11 +154,11 @@ BIBDB = $(BIBDBre) BIBDBre = $(eval BIBDB := \ $(addsuffix .bib,$(basename $(sort $(shell \ - $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(TEXFILES) | \ - $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \ - $(SED) -n -e 's/\\bibliography\(\[[^]]*\]\)\{0,1\}{[^}]*}/&\n/pg' | \ - $(SED) -n -e 's/.*{\([^}]*\)}$$/\1/p' | \ - $(SED) -e 's/,/ /g' \ + $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(TEXFILES) | \ + $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \ + $(SED) -e 's/}/}%/g' | $(SED) -e 'y/}%/}\n/' | \ + $(SED) -n -e 's/.*\\bibliography\(\[[^]]*\]\)\{0,1\}{\([^}]*\)}$$/\2/pg' | \ + $(SED) -e 's/,/ /g' \ ))))) # LaTeX処理(コンパイル) @@ -180,7 +184,9 @@ COMPILES.tex = \ # DVI -> PDF # 出力結果は.logファイルへ出力 DVIPDFCMD = $(DVIPDFMX) $(DVIPDFMXFLAG) $(BASE).dvi -COMPILE.dvi = $(ECHO) $(DVIPDFCMD); $(DVIPDFCMD) >>$(BASE).log 2>&1 || ($(SED) -n -e '/^Output written on toc_hyperref.dvi/,$$p' $(BASE).log; exit 1) +COMPILE.dvi = \ + $(ECHO) $(DVIPDFCMD); $(DVIPDFCMD) >>$(BASE).log 2>&1 || \ + ($(SED) -n -e '/^Output written on toc_hyperref.dvi/,$$p' $(BASE).log; exit 1) # 索引中間ファイル(.ind)作成 MENDEXCMD = $(MENDEX) $(MENDEXFLAG) $(BASE).idx @@ -333,26 +339,50 @@ extractbb: %.bbl_prev: %.bbl @$(CMPPREV) -# hyperref中間ファイル作成 -%.out: %.tex - @$(MAKE) -s $(BASE).aux +###################################################################### +# バウンディング情報ファイルを生成するパターンルール +###################################################################### +%.xbb: %.pdf + $(EXTRACTBB) $(EXTRACTBBFLAGS) $< -%.out_prev: %.out - @$(CMPPREV) +%.xbb: %.jpeg + $(EXTRACTBB) $(EXTRACTBBFLAGS) $< + +%.xbb: %.jpg + $(EXTRACTBB) $(EXTRACTBBFLAGS) $< + +%.xbb: %.png + $(EXTRACTBB) $(EXTRACTBBFLAGS) $< + +%.xbb: %.bmp + $(EXTRACTBB) $(EXTRACTBBFLAGS) $< + +###################################################################### +# ターゲット +###################################################################### + +# 警告 +tex-warn: + @$(ECHO) "check current directory, or set TEXTARGET in Makefile." + +# すべての画像ファイルに対してextractbbを実行 +tex-xbb: + $(MAKE) -s $(addsuffix .xbb,$(basename $(wildcard $(addprefix *,$(GRAPHICSEXT))))) -# tex-cleanターゲット +# 中間ファイルの削除 tex-clean: - $(RM) $(ALL_INTERFILES) + $(RM) $(ALLINTERFILES) + $(RM) -r $(FLSDIR) ifeq (,$(filter %.dvi,$(TEXTARGETS))) $(RM) *.dvi endif -# xbb-cleanターゲット -xbb-clean: +# .xbbファイルの削除 +tex-xbb-clean: $(RM) *.xbb -# tex-distcleanターゲット -tex-distclean: tex-clean xbb-clean +# 生成されたすべてのファイルの削除 +tex-distclean: tex-clean tex-xbb-clean ifneq (,$(filter %.dvi,$(TEXTARGETS))) $(RM) *.dvi endif