Merged silc_1_0_branch to trunk.
[silc.git] / scripts / silcdoc / silcdoc
index beb173d6daab6a66d3dcba31369523d4ea247d36..57bb940018db6a6450f29c73ab17856235d984f0 100755 (executable)
@@ -21,8 +21,8 @@
 
 # Arguments checking
 if [ $# -lt "4" ]; then
-  echo "Usage: ./silcdoc <type> <source directory> <destination directory> <robodoc>"
-  echo "Supported types: HTML"
+  echo "Usage: ./silcdoc <type> <source directory> <destination directory/file> <robodoc>"
+  echo "Supported types: HTML PS"
 #  echo "Supported types: HTML, ASCII, LATEX or RTF"
   exit 1
 fi
@@ -35,6 +35,52 @@ ROBO=$4
 # Get all headers in the source directory
 headers=`find $SRC -name "silc*.h"`
 
+#
+# PS documentation (from LATEX)
+#
+if [ "$TYPE" = "PS" ]; then
+  TYPE="LATEX"
+  rm -rf /tmp/silcdoc.tex
+  mkdir /tmp/silcdoc.tex
+  cp $headers /tmp/silcdoc.tex
+
+  path=`pwd`
+  cd /tmp/silcdoc.tex
+
+  # Generate cross reference files
+  headers=`find . -name "silc*.h" |cut -d/  -f2 |cut -d.  -f1`
+  touch silcdoc_xref
+  for i in $headers
+  do
+    $ROBO $i.h $i.h.tex $TYPE INTERNAL GENXREF $i.h.xref
+    echo $i.h.xref >>silcdoc_xref
+  done
+
+  # Generate the detailed documentation
+  headers=`find . -name "silc*.h" |cut -d/  -f2 |cut -d.  -f1`
+  for i in $headers
+  do
+    # remove internals
+    rm -rf $i_i.h
+    $ROBO $i.h $i.h.tex XREF silcdoc_xref $TYPE C SORT NOSOURCE SINGLEDOC
+  done
+
+  # Generate the index
+  $ROBO silcdoc_xref toolkit_mi INDEX $TYPE TITLE "SILC Toolkit Reference Manual"
+
+  # Generate the postscript
+  latex toolkit_mi
+  makeindex toolkit_mi
+  latex toolkit_mi
+  latex toolkit_mi
+  dvips toolkit_mi.dvi -o $DST
+
+  cd $path
+
+  rm -rf /tmp/silcdoc.tex
+  exit 0
+fi
+
 #
 # ASCII documentation
 #
@@ -54,8 +100,8 @@ if [ "$TYPE" = "HTML" ]; then
 
   # Generate index template from the DIRECTORY files. The template for
   # the generated index template is INDEX.tmpl.
-  files=`find $SRC -name "DIRECTORY"`
-  for i in $files
+  dfiles=`find $SRC -name "DIRECTORY"`
+  for i in $dfiles
   do
     # Get library name
     name=`grep "@LIBRARY=" $i |cut -d=  -f2`
@@ -131,8 +177,7 @@ if [ "$TYPE" = "HTML" ]; then
   done
 
   # Generate the index and TOC files from the DIRECTORY files
-  files=`find $SRC -name "DIRECTORY"`
-  for i in $files
+  for i in $dfiles
   do
     # Get library name
     name=`grep "@LIBRARY=" $i |cut -d=  -f2`
@@ -156,7 +201,13 @@ if [ "$TYPE" = "HTML" ]; then
   sed -e "/@VERSION@/s//$version/" -e "/@DATE@/s//$curdate/" -e "/@BODY@/ r $DST/index.html.tmp" -e s/@BODY@//g $index >$DST/index.html
   sh gen.sh $DST gen_index.php 2 $DST/index.html $DST/index.html
 
+  # Generate the index toolkit_index.html file
+  $ROBO $DST/silcdoc_xref $DST/toolkit_index.html INDEX HTML TITLE "SILC Toolkit Index"
+  sh gen.sh $DST gen_index.php 2 $DST/toolkit_index.html $DST/toolkit_index.html
+
+  # Cleanup
   rm -rf $DST/index.html.tmp
   rm -rf /tmp/silcdoc.html
   rm -rf /tmp/silcdoc_html.html
+  exit 0
 fi