+tex-warning:
+ @$(ECHO) "check current directory, or set TEXTARGET in Makefile."
+
+# ファイル名から拡張子を除いた部分
+BASE = $(basename $<)
+
+# TeX中間ファイルの拡張子
+# .aux: 相互参照
+# .fls: tex -recorderで生成されるファイルリスト
+# .lof: 図リスト(\tableoffigures)
+# .lot: 表リスト(\tableoftables)
+# .out: hyperrefパッケージ
+# .toc: 目次(\tableofcontents)
+# .log: ログ
+TEX_INT := .aux .fls .lof .lot .out .toc .log
+# 索引中間ファイルの拡張子
+# .idx: auxから作成
+# .ind: idxから作成
+# .ilg: 索引ログ
+IND_INT := .idx .ind .ilg
+# BiBTeX中間ファイルの拡張子
+# .bbl: auxから作成
+# .blg: BiBTeXログ
+BIB_INT := .bbl .blg
+
+ALL_INTERFILES = $(addprefix *,$(TEX_INT) $(IND_INT) $(BIB_INT) .d .*_prev)
+
+.SECONDARY: $(wildcard ALL_INTERFILES)
+
+# \tableofcontents命令をTeXファイルから検索する
+toc = \
+ $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/.*\(\\tableofcontents\)/\1/p' \
+ )
+
+# \listoffigures命令をTeXファイルから検索する
+lof = \
+ $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/.*\(\\listoffigures\)/\1/p' \
+ )
+
+# \listoftables命令をTeXファイルから検索する
+lot = \
+ $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/.*\(\\listoftables\)/\1/p' \
+ )
+
+# \makeindex命令をTeXファイルから検索する
+makeindex = \
+ $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/.*\(\\makeindex\)/\1/p' \
+ )
+
+# \bibliography命令で読み込まれる文献データベースファイルをTeXファイルから検索する
+bibdb = \
+ $(addsuffix .bib,$(basename $(strip $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(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' \
+ ))))
+
+# hyperrefパッケージ読み込みをTeXファイルから検索する
+hyperref = \
+ $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/.*\(\\usepackage\(\[[^]]*\]\)\{0,1\}{hyperref}\)/\1/p'\
+ )
+
+# $(BASE).texで使われるLaTeX中間ファイル
+INTERFILES = \
+ $(strip \
+ $(if $(toc),$(BASE).toc) \
+ $(if $(lof),$(BASE).lof) \
+ $(if $(lot),$(BASE).lot) \
+ $(if $(makeindex),$(BASE).ind) \
+ $(if $(bibdb),$(BASE).bbl) \
+ $(if $(hyperref),$(BASE).out) \
+ )
+
+INTERFILES_PREV = $(addsuffix _prev,$(INTERFILES))
+
+# \include命令で読み込まれるTeXファイル
+includetex = \
+ $(strip $(addsuffix .tex,$(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/\\include\(\[[^]]*\]\)\{0,1\}{[^}]*}/&\n/pg' | \
+ $(SED) -n -e 's/.*{\([^}]*\)}$$/\1/p' \
+ )))
+
+# \input命令で読み込まれるTeXファイル
+define get_inputtex
+ $(strip $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $1 | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/\\input\(\[[^]]*\]\)\{0,1\}{[^}]*}/&\n/pg' | \
+ $(SED) -n -e 's/.*{\([^}]*\)}$$/\1/p' \
+ ))
+endef
+
+inputtex = $(call get_inputtex,$(BASE).tex $(includetex))
+
+# \include命令または\input命令で読み込まれるTeXファイル
+intex = $(strip $(includetex) $(inputtex))
+
+# \includegraphics命令で読み込まれるグラフィックファイル
+ingraphics = \
+ $(strip $(shell \
+ $(SED) -e '/^\s*%/d' -e 's/\([^\]\)\s*%.*/\1/g' $(BASE).tex $(intex) | \
+ $(SED) -e '/\\begin{verbatim}/,/\\end{verbatim}/d' | \
+ $(SED) -n -e 's/\\includegraphics\(\[[^]]*\]\)\{0,1\}{[^}]*}/&\n/pg' | \
+ $(SED) -n -e 's/.*{\([^}]*\)}$$/\1/p' \
+ ))
+
+# LaTeX処理(コンパイル)
+LATEXCMD = $(LATEX) -interaction=batchmode $(LATEXFLAG) $(BASE).tex
+COMPILE.tex = $(ECHO) $(LATEXCMD); $(LATEXCMD) >/dev/null 2>&1 || ($(CAT) $(BASE).log; exit 1)