5 ## Copyright (C) Michael Still (mikal@stillhq.com)
6 ## Released under the terms of the GNU GPL
8 ## A script to make or install the manpages extracted by split-man
10 ## Arguements: $1 -- the word "convert" or "install"
11 ## $2 -- the directory containing the SGML files for the manpages
12 ## $3 -- the filename which contained the sgmldoc output
13 ## (I need this so I know which manpages to convert)
15 my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename, $tmpdir);
18 die "Usage: makeman [convert | install] <dir> <file>\n";
21 if( ! -d
"$ARGV[1]" ){
22 die "Output directory \"$ARGV[1]\" does not exist\n";
25 if($ENV{"TMPDIR"} ne ""){
26 $tmpdir = $ENV{"TMPDIR"};
32 if($ARGV[0] eq "convert"){
33 open LISTING
, "grep \"<refentrytitle>\" $ARGV[2] |";
43 print "Processing $filename\n";
45 # Open the input file to extract the front matter, generate the man page,
46 # and open it, and the rearrange everything until it is happy
47 open INPUT
, "< $ARGV[1]/$filename.sgml";
51 # The modes used here are:
53 # <!-- BEGINFRONTTAG -->
54 # <!-- <bookinfo> mode = 1
55 # <!-- <legalnotice> mode = 2
56 # <!-- ...GPL or whatever...
57 # <!-- </legalnotice> mode = 4
58 # <!-- </bookinfo> mode = 3
59 # <!-- ENDFRONTTAG -->
63 # I know that some of the if statements in this while loop are in a funny
64 # order, but that is deliberate...
78 $front = "$front.\\\" \n";
80 elsif(/<\/legalnotice
>/i
){
86 $front = "$front.\\\" $_";
91 if(/<title>(.*)<\/title
>/i
){
92 $front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n";
94 elsif(/<legalnotice>/i){
95 $front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n";
100 $front = "$front.\\\" Documentation by: ";
102 elsif(/<firstname>(.*)<\/firstname
>/i
){
103 $front = "$front$1 ";
105 elsif(/<surname>(.*)<\/surname
>/i
){
106 $front = "$front$1 ";
108 elsif(/<email>(.*)<\/email
>/i
){
109 $front = "$front($1)";
115 elsif(/<copyright>/i){
116 $front = "$front.\\\" Documentation copyright: ";
118 elsif(/<holder>(.*)<\/holder
>/i
){
119 $front = "$front$1 ";
121 elsif(/<year>(.*)<\/year
>/i
){
122 $front = "$front$1 ";
124 elsif(/\/copyright
>/i
){
130 || /<\/affiliation
>/i
134 || /<\/authorgroup
>/i
135 || /<\/legalnotice
>/i
144 print "Unknown tag in manpage conversion: $_";
162 system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 $tmpdir/$$.9\n");
163 open GENERATED
, "< $tmpdir/$$.9";
164 open OUTPUT
, "> $ARGV[1]/$filename.9";
166 print OUTPUT
"$front";
167 print OUTPUT
".\\\" For comments on the formatting of this manpage, please contact Michael Still <mikal\@stillhq.com>\n\n";
174 system("gzip -f $ARGV[1]/$filename.9\n");
175 unlink("$tmpdir/$$.9");
178 elsif($ARGV[0] eq "install"){
179 system("mkdir -p /usr/local/man/man9/; install $ARGV[1]/*.9.gz /usr/local/man/man9/");
182 die "Usage: makeman [convert | install] <dir> <file>\n";