+# \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' \
+ ))
+