Imported Upstream version 4.0.17
[platform/upstream/mtools.git] / mkmanpages
1 #!/bin/bash
2
3 # Copyright 1997,1999,2001,2002,2004,2009,2010 Alain Knaff.
4 # This file is part of mtools.
5 #
6 # Mtools is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Mtools is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
18
19 # TODO
20 VERSION=`cat version.texi | awk '$2 == "VERSION" {print $3}'`
21 UPDATED=`cat version.texi | awk '$2 == "UPDATED" {print $3 " " $4}'`
22
23 # extracts the manpage for a given command out of a texinfo doc
24 unset LANG
25
26 date=`date +%d%b%y`
27 package="mtools-"`grep mversion patchlevel.c | sed 's/^.*"\(.*\)";/\1/'`
28
29 infile=/tmp/infile.$$
30
31 extract()
32 {
33   command=$1
34   echo extracting $command
35   outfile=`echo $command | tr '[A-Z]' '[a-z]'`.1
36   exec 4>&1
37   exec >$outfile
38
39   echo \'\\\" t
40 # '
41   echo .TH\ $command\ 1\ \"$date\" $package
42   echo .SH Name
43   egrep -i "^$command " cmdname | fgrep -v '#'
44   #echo ".SH Description"
45   
46   cat man-warning.texi mtools.texi man-warning-end.texi |
47   egrep -v '@end copying|@copying|@insertcopying' |
48   sed \
49    -e "/^@c\(omment\)\? skipskipskip/,/^@node $command/d" \
50    -e "/^@node [^,]*, [^,]*, $command, Commands$/,/^@bye/d" \
51    -e "/^@node [^,]*, [^,]*, Commands/,/^@bye/d" \
52    -e 's/^@section/@chapter/' \
53    -e 's/^@subs/@s/' \
54    -e 's/^@chapter.*$/@chapter Description/' \
55    -e 's/^@section/@chapter/' \
56    -e 's/^@subs/@s/' \
57    -e 's/^@c\(omment\)\? xMANoptions/@chapter Options/' \
58    -e "s/^@c\(omment\)\? MAN/@MAN/"  |
59   texi2roff -ma  |
60   sed -f strip-pp.sed |
61   sed -e '/^\.iX/d'
62   exec 1>&4
63 #  echo ".SH See Also"
64 #  echo "Mtools' texinfo doc"
65 }
66
67
68 for name in `fgrep -v '#' cmdname | cut -f1 -d\  ` ; do
69   extract $name
70 done
71
72 rm -f mtools.tmpl.1
73 exec >mtools.tmpl.1
74 echo \'\\\" t
75 # '
76 echo .TH mtools 1 \"$date\" $package
77 echo .SH Name
78 echo "mtools - utilities to access DOS disks in Unix."
79 cat mtools.texi |
80   egrep -v '@end copying|@copying|@insertcopying' |
81         sed \
82          -e "1,/^@c\(omment\)\? MANstart 1/d" \
83          -e '/^@c\(omment\)\? MANskip 1/,/^@c\(omment\)\? MANend-skip 1/d' \
84          -e '/^@c\(omment\)\? MANend-skip 5/d' \
85          -e '/^@c\(omment\)\? MANend 5/d' \
86          -e "s/^@c\(omment\)\? MAN/@MAN/" \
87          -e "s/@value{VERSION}/$VERSION/g" \
88          -e "s%@value{SYSCONFDIR}%SYSCONFDIR%g" |
89         texi2roff -ma  |
90         sed -f strip-pp.sed |
91         sed -e '/^\.iX/d'
92
93 echo .SH See also
94 echo floppyd_installtest
95 echo mattrib
96 echo mbadblocks
97 echo mcd
98 echo mclasserase
99 echo mcopy
100 echo mdel
101 echo mdeltree
102 echo mdir
103 echo mdu
104 echo mformat
105 echo minfo
106 echo mkmanifest
107 echo mlabel
108 echo mmd
109 echo mmount
110 echo mmove
111 echo mrd
112 echo mren
113 echo mshortname
114 echo mshowfat
115 echo mtoolstest
116 echo mtype
117
118 rm -f mtools.tmpl.5
119 exec >mtools.tmpl.5
120 echo \'\\\" t
121 # '
122 echo .TH mtools 5 \"$date\" "MTOOLS" "MTOOLS"
123 echo .SH Name
124 echo "mtools.conf - mtools configuration files"
125 cat mtools.texi |
126   egrep -v '@end copying|@copying|@insertcopying' |
127         sed \
128                 -e '1d' \
129                 -e '/^@c\(omment\)\? MANskip 5/,/^@c\(omment\)\? MANend-skip 5/d' \
130                 -e '/^@c\(omment\)\? MANend-skip 1/d' \
131                 -e '/^@c\(omment\)\? MANskip 1/d' \
132                 -e "s/^@c\(omment\)\? MAN/@MAN/"  \
133                 -e "/@include/ d" \
134                 -e "s/@value{VERSION}/$VERSION/g" \
135                 -e "s/@value{UPDATED}/$UPDATED/g" \
136                 -e "s%@value{SYSCONFDIR}%SYSCONFDIR%g" \
137                 -e "/@top/d" \
138                 -e "/@format/d" \
139                 -e "/@end format/d" \
140                 -e "/@ifnottex/d" \
141                 -e "/@end ifnottex/d" |
142         texi2roff -ma  |
143         sed -f strip-pp.sed |
144         sed -e '/^\.iX/d' -e 's/\.SS Description/.SH Description/'
145
146 echo .SH See also
147 echo mtools