LSR: Update.
[lilypond.git] / buildscripts / install-info-html.sh
bloba116cd93d0a748e1061f5a8d0f1df6d59f2231fb
1 #!@BASH@
3 name=install-info-html
4 version=1.0
6 all=
7 index_dir=.
10 # debugging
12 debug_echo=:
16 # print usage
18 help ()
20 cat << EOF
21 $name $version
22 Install HTML info document.
24 Usage: $name [OPTIONS]... [DOCUMENT-DIR]...
26 Options:
27 -a, --all assume all subdirectories of index to be DOCUMENT-DIRs
28 -d, --dir=DIR set index directory to DIR (default=.)
29 -D, --debug print debugging info
30 -h, --help show this help text
31 -v, --version show version
32 EOF
36 cleanup ()
38 $debug_echo "cleaning ($?)..."
41 trap cleanup 0 9 15
44 # Find command line options and switches
47 # "x:" x takes argument
49 options="adhvW:"
51 # ugh, "\-" is a hack to support long options
52 # must be in double quotes for bash-2.0
54 while getopts "\-:$options" O
56 $debug_echo "O: \`$O'"
57 $debug_echo "arg: \`$OPTARG'"
58 case $O in
60 all=yes
63 [ "$debug_echo" = "echo" ] && set -x
64 debug_echo=echo
67 help;
68 exit 0
71 echo $name $version
72 exit 0
75 index_dir=$OPTARG
77 # a long option!
79 case "$OPTARG" in
80 a*|-a*)
81 all=yes
83 de*|-de*)
84 [ "$debug_echo" = "echo" ] && set -x
85 debug_echo=echo
87 h*|-h*)
88 help;
89 exit 0
91 di*|-di*)
92 index_dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"
94 version|-version)
95 echo $name $version
96 exit 0
98 *|-*)
99 echo "$0: invalid option -- \"$OPTARG\""
100 help;
101 exit -1
103 esac
104 esac
105 done
106 shift `expr $OPTIND - 1`
109 # Input file name
111 if [ -z "$all" -a -z "$1" ]; then
112 help
113 echo "$name: No HTML documents given"
114 exit 2
117 if [ -n "$all" -a -n "$1" ]; then
118 echo "$name: --all specified, ignoring DIRECTORY-DIRs"
121 if [ -n "$all" ]; then
122 document_dirs=`/bin/ls -d1 $index_dir`
123 else
124 document_dirs=$*
127 index_file=$index_dir/index.html
128 rm -f $index_file
129 echo -n "$name: Writing index: $index_file..."
131 # head
132 cat >> $index_file <<EOF
133 <html>
134 <title>Info documentation index</title>
135 <body>
136 <h1>Info documentation index</h1>
138 This is the directory file \`index.html' a.k.a. \`DIR', which contains the
139 topmost node of the HTML Info hierarchy.
140 </p>
141 <ul>
144 #list
145 for i in $document_dirs; do
146 cat <<EOF
147 <li> <a href="$i/index.html">$i</a> (<a href="$i.html">$i as one big page</a>)</li>
149 done >> $index_file
151 # foot
152 cat >> $index_file <<EOF
153 </ul>
154 </body>
155 </html>
157 echo