chmod takes options before modes
[maxima.git] / doc / info / build_html.sh.in
blobe9bca8b5980681cfe7c57548b4b90f827baf4b46
1 #!/bin/sh
3 usage () {
4 echo "build_html.sh [-Dh?]"
5 echo " -l Specify language"
6 echo " -D Enable simple debugging of this script"
7 echo " -h This help"
8 echo " -? This help"
9 echo "Build the html version of the manual, including both the single"
10 echo "page version and the multi-page version. This also builds all the"
11 echo "category information."
12 exit 1
15 while getopts "h?Dl:" arg
17 case $arg in
18 l) language=$OPTARG ;;
19 D) DEBUG=yes ;;
20 h) usage ;;
21 \?) usage ;;
22 esac
23 done
25 pwd=`pwd`
26 if [ "x$language" = "x" ]
27 then
28 language=en
29 languagedir=@abs_srcdir@
30 languagedestdir=$pwd
31 texiinitfile=$pwd/texi2html.init
32 else
33 languagedir=@abs_srcdir@/$language
34 languagedestdir=$pwd
35 if [ "$language" = "pt_BR" ]
36 then language=pt
38 texiinitfile=$pwd/../texi2html.init
41 echo "$0: abs_srcdir=@abs_srcdir@, pwd=$pwd, language=$language, languagedir=$languagedir, texiinitfile=$texiinitfile"
43 includerfile=include-maxima.texi
45 # Extract all filenames that are included using @include commands in the order
46 # they are included
47 includedfiles=`@AWK@ '/^[[:space:]]*@include/ { print $NF; }' $includerfile`
49 # If output dir exists, remove it so we start clean
50 if [ -d tmp_html ]; then
51 rm -rf tmp_html
53 mkdir tmp_html
54 cp -r @abs_srcdir@/figures tmp_html
55 # "make distcheck" write-protects the source tree. We don't want our
56 # figures to inherit that attribute as we want to delete the temp folder
57 # again, later.
58 chmod -R u+w tmp_html
60 cat include-maxima.texi > tmp_html/include-maxima.texi
62 cd tmp_html
64 for f in $includedfiles
66 # Find the absolute path of the current element of $includedfiles
67 if [ -e $languagedir/$f ]
68 then includedfile_absolute=$languagedir/$f
69 else if [ -e @abs_srcdir@/$f ]
70 then includedfile_absolute=@abs_srcdir@/$f
71 else if [ -e ../../$f ]
72 then includedfile_absolute=../../$f
73 else if [ -e ../$f ]
74 then includedfile_absolute=../$f
75 else
76 includedfile_absolute=`pwd`/../$f
82 if [ -e $includedfile_absolute ]
83 then
84 if [ "X$DEBUG" = "Xyes" ]; then
85 echo "Taking the file $f from the path $includedfile_absolute"
87 else
88 echo Error: File $f cannot be found.
89 exit -1
92 filenamebase=`echo $includedfile_absolute | @SED@ -e 's/^.*\///;s/\.texi//'`
93 @SED@ -e 's/^@deffnx* *{[^}]*} *\([^[:blank:]]*\).*/@anchor{Item: '$filenamebase'\/deffn\/\1}\
94 &/' \
95 -e 's/^@defvrx* *{[^}]*} *\([^[:blank:]]*\).*/@anchor{Item: '$filenamebase'\/defvr\/\1}\
96 &/' \
97 -e 's/^@node *\([^,]*\).*/@anchor{Item: '$filenamebase'\/node\/\1}\
98 &/' $includedfile_absolute \
99 | @AWK@ 'BEGIN { iftex = 0; } /^@iftex/ {iftex = 1;} {if (!iftex) {print;}} /^@end iftex/ {iftex = 0;}' \
100 | @AWK@ '/@anchor/ {if (!(foo[$0])) {foo[$0] = 1; print;}} !/@anchor/' > $(basename $includedfile_absolute)
101 done
103 catprogname=make-categories.lisp
104 for f in *.texi
106 filenamebase=`echo $f | @SED@ -e 's/^.*\///;s/\.texi//'`
107 echo "(setq *filenamebase* \"$filenamebase\")"
108 cat $f
109 done | @AWK@ '!/^@c / && !/^@c$/ && (/^@deffn/ || /^@defvr/ || /^@end deffn/ || /^@end defvr/ || /@category/ || /@node/ || /^.setq .filenamebase/)' | @SED@ -f @abs_srcdir@/extract_categories1.sed | @AWK@ -f @abs_srcdir@/extract_categories1.awk > $catprogname
111 if [ "@DEFAULTLISP@" = "gcl" ]
112 then lispprog="@GCL_NAME@"
113 lispargs="-batch -load $catprogname"
114 elif [ "@DEFAULTLISP@" = "clisp" ]
115 then lispprog="@CLISP_NAME@"
116 lispargs="$catprogname"
117 elif [ "@DEFAULTLISP@" = "cmucl" ]
118 then lispprog="@CMUCL_NAME@"
119 lispargs="-load $catprogname -eval (quit)"
120 elif [ "@DEFAULTLISP@" = "scl" ]
121 then lispprog="@SCL_NAME@"
122 lispargs="-load $catprogname -eval (quit)"
123 elif [ "@DEFAULTLISP@" = "ecl" ]
124 then lispprog="@ECL_NAME@"
125 lispargs="--shell $catprogname"
126 elif [ "@DEFAULTLISP@" = "ccl64" ]
127 then lispprog="@CCL64_NAME@"
128 lispargs="--load $catprogname --eval (quit)"
129 # NOT SURE ABOUT OPENMCL; SAME ARGS AS CCL/CCL64 OR DIFFERENT ??
130 elif [ "@DEFAULTLISP@" = "ccl" -o "@DEFAULTLISP@" = "openmcl" ]
131 then lispprog="@OPENMCL_NAME@"
132 lispargs="--load $catprogname --eval (quit)"
133 elif [ "@DEFAULTLISP@" = "sbcl" ]
134 then lispprog="@SBCL_NAME@"
135 lispargs="--script $catprogname"
136 elif [ "@DEFAULTLISP@" = "abcl" ]
137 then lispprog="@JRE@"
138 lispargs="-jar @ABCL_JAR@ --load $catprogname --eval (quit)"
139 elif [ "@DEFAULTLISP@" = "acl" ]
140 then lispprog="@ACL_NAME@"
141 lispargs="-L $catprogname --kill"
142 else
143 echo "$0: DEFAULTLISP = @DEFAULTLISP@ not recognized, assume '@DEFAULTLISP@ $catprogname' is acceptable."
144 lispprog="@DEFAULTLISP@"
145 lispargs="$catprogname"
148 echo "$0: execute category program: \"$lispprog\" $lispargs"
149 "$lispprog" $lispargs
151 @SED@ -e 's/^@bye/@node Documentation Categories, , Function and Variable Index\n@chapter Documentation Categories/' $languagedir/maxima.texi > maxima.texi
153 # Add all Category-*.texi files to maxima.texi.
154 # If there aren't any the file named "Category-*.texi" cannot be found
155 # and therefore will be excluded by the 'if'.
156 ( for f in Category-*.texi; do
157 if [ -e "$f" ]; then
158 echo '@include' $f
160 done
161 echo @bye
162 ) >> maxima.texi
164 if [ "X$DEBUG" = "Xyes" ]; then
165 set -x
168 # --no-node-files so we don't have thousands of little html files
169 # --force -e 10000 because the category stuff causes lots of errors.
170 TEXIOPT="--html -c INLINE_CONTENTS=0 -c OUTPUT_ENCODING_NAME=UTF-8 --force -e 10000 --document-lang=$language -I . -I $languagedir -I ../.. --css-include=@abs_srcdir@/manual.css -I @abs_srcdir@/figures --init-file $texiinitfile"
171 makeinfo --split=chapter --no-node-files --output="$languagedestdir" $TEXIOPT maxima.texi
172 makeinfo --no-split --output="$languagedestdir/maxima_singlepage.html" $TEXIOPT maxima.texi
174 if [ "X$DEBUG" = "Xyes" ]; then
175 set -x
178 cd ..
180 if [ "X$DEBUG" != "Xyes" ]; then
181 rm -r -f tmp_html