latex_mk/test/.gitignoreの追加
[makefiles.git] / latex_mk / latex.mk
index bef47ce..f3da143 100644 (file)
 #
 # include latex.mk
 
-#debug
-#SHELL = /bin/sh -x
+ifdef DEBUG
+  SHELL := /bin/sh -x
+endif
 
-.PHONY: tex-warning tex-clean tex-distclean
+.PHONY: tex-warning tex-xbb tex-clean tex-distclean
 
 # シェルコマンド
 CAT := cat
@@ -66,13 +67,14 @@ tex-warning:
 BASE = $(basename $<)
 
 # .aux、.fls以外のTeX中間ファイルの拡張子
-#   .lof: 図リスト(\tableoffigures)
-#   .lot: 表リスト(\tableoftables)
-#   .out: hyperrefパッケージ
-#   .toc: 目次(\tableofcontents)
-TEX_INT := .lof .lot .out .toc
+#   .glo: 用語集。\glossaryがあれば生成
+#   .lof: 図リスト。\listoffiguresがあれば生成
+#   .lot: 表リスト。\listoftablesがあれば生成
+#   .out: PDFブックマーク。hyperrefパッケージをbookmarksオプションtrue(初期値)で呼び出せば生成
+#   .toc: 目次。\tableofcontentsがあれば生成
+TEX_INT := .glo .lof .lot .out .toc
 # 索引中間ファイルの拡張子
-#   .idx: auxから作
+#   .idx: \makeindexがあれば生
 #   .ind: idxから作成
 IND_INT := .idx .ind
 # BiBTeX中間ファイルの拡張子
@@ -134,11 +136,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 = \
@@ -149,11 +152,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処理(コンパイル)
@@ -179,7 +182,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