5 ## Copyright (C) Michael Still (mikal@stillhq.com)
6 ## Released under the terms of the GNU GPL
8 ## Hoon through the specified DocBook SGML file, and split out the
9 ## man pages. These can then be processed into groff format, and
10 ## installed if desired...
12 ## Arguements: $1 -- the name of the sgml file
13 ## $2 -- the directory to put the generated SGML files in
14 ## $3 -- kernel version
16 my($SGML, $REF, $front, $refdata, $mode, $filename);
18 if(($ARGV[0] eq "") || ($ARGV[1] eq "") || ($ARGV[2] eq "")){
19 die "Usage: split-man <sgml file> <output dir> <kernel version>\n";
22 open SGML
, "< $ARGV[0]" or die "Could not open input file \"$ARGV[0]\"\n";
23 if( ! -d
"$ARGV[1]" ){
24 die "Output directory \"$ARGV[1]\" does not exist\n";
28 # 0: Looking for input I care about
29 # 1: Inside book front matter
30 # 2: Inside a refentry
31 # 3: Inside a refentry, and we know the filename
38 if(/<bookinfo>/ || /<docinfo>/){
44 elsif(/<refentrytitle><phrase[^>]*>([^<]*)<.*$/){
48 $filename =~ s/struct //;
49 $filename =~ s/typedef //;
51 print "Found manpage for $filename\n";
52 open REF
, "> $ARGV[1]/$filename.sgml" or
53 die "Couldn't open output file \"$ARGV[1]/$filename.sgml\": $!\n";
55 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
57 <!-- BEGINFRONTTAG: The following is front matter for the parent book -->
59 <!-- ENDFRONTTAG: End front matter -->
69 $front = "$front<!-- $_ -->\n";
72 $refdata = "$refdata$_";
75 # There are some fixups which need to be applied
77 print REF
"<manvolnum>9</manvolnum>\n";
81 <refsect1><title>About this document</title>
83 This documentation was generated with kernel version $ARGV[2].
89 # For some reason, we title the synopsis twice in the main DocBook
90 if(! /<title>Synopsis<\/title
>/){
91 if(/<refentrytitle>/){
101 if(/<\/bookinfo
>/ || /<\
/docinfo>/){
104 elsif(/<\/refentry
>/){
110 # And make sure we don't process this unnessesarily
111 $ARGV[0] =~ s/\.sgml/.9/;