*** empty log message ***
[m17n/m17n-docs.git] / utils / latex.sh
index 1da532a..a37e918 100755 (executable)
@@ -1,20 +1,53 @@
 #!/bin/sh
+#                                                      -*- coding: utf-8; -*-
 # $1: target directory (usr/latex, ja/latex, or dev/latex)
-# $2: latex commnad (latex, platex, or pdflatex)
 
 umask 002
 USR_JA_DEV=`dirname $1`
-TEXINPUTS=`pwd`/styles:`pwd`/data-${USR_JA_DEV}:.:
-export TEXINPUTS
+cp styles/m17n-lib.sty $1
 cd $1
-LATEX=$2
-PAPER='-t a4'
-${LATEX} m17n-lib.tex
-if [ "${USR_JA_DEV}" = "ja" ] ; then
-  nkf -e < m17n-lib.idx > temp.idx; mv temp.idx m17n-lib.idx
+LATEX=latex
+if [ $USR_JA_DEV = "ja" ] ; then
+  LATEX=platex
+  if [ -d /usr/local/teTeX/bin ] ; then
+    PATH=/usr/local/teTeX/bin:$PATH
+  fi
+  echo '\\appendix' > app.tex
+  sed -n -e '/コンパイル/,/include{m17nDBFormat}/ p' \
+      -e '/Tutorial for writing/,/include{GFDL}/ p' \
+      -e '/printindex/,$ p' < refman.tex >> app.tex
+  sed -e '/documentclass/ s/a4paper/a4paper,twoside/' \
+      -e '/inputenc/ d' \
+      -e '/コンパイル/,/include{GFDL}/ d' \
+      -e '/chapter{ファイル}/,$ d' < refman.tex > m17n-lib.tex
+  cat app.tex >> m17n-lib.tex
+  rm -rf tmp
+  mkdir tmp
+  for f in *; do 
+      case "$f" in
+         m17nDBData.tex) ;;
+         *.tex) mv "$f" tmp; iconv -f utf-8 -t euc-jp < "tmp/$f" > "$f";;
+         *.sty) mv "$f" tmp; iconv -f utf-8 -t euc-jp < "tmp/$f" > "$f";;
+      esac
+  done  
+  rm -rf tmp
+elif [ $USR_JA_DEV = "dev" ] ; then
+  sed -e '/documentclass/ s/a4paper/a4paper,twoside/' \
+      -e '/The m17n Library Module Index/,/pages/ d' \
+      -e '/The m17n Library File Documentation/,/textprop_8c/ d' \
+      -e '/The m17n Library Directory Documentation/,/dir_000001/ d' \
+      -e 's/The m17n Library Page Documentation/Appendix/' \
+    < refman.tex > m17n-lib.tex
+else
+  echo '\\appendix' > app.tex
+  sed -n -e '/Print compile/,/include{GFDL}/ p' \
+      -e '/printindex/,$ p' < refman.tex >> app.tex
+  sed -e '/documentclass/ s/a4paper/a4paper,twoside/' \
+      -e '/Print compile/,/include{GFDL}/ d' \
+      -e '/chapter{File Documentation}/,$ d' < refman.tex > m17n-lib.tex
+  cat app.tex >> m17n-lib.tex
 fi
+${LATEX} m17n-lib.tex
 makeindex m17n-lib.idx
 ${LATEX} m17n-lib.tex
-if [ "$LATEX" != "pdflatex" ] ; then
-  dvips ${PAPER} -o m17n-lib.ps m17n-lib.dvi
-fi
+${LATEX} m17n-lib.tex