From: mdw Date: Tue, 6 Jul 1999 19:14:42 +0000 (+0000) Subject: Perl script to make `.so' links for all appropriate mLib functions. X-Git-Tag: 2.0.4~274 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/commitdiff_plain/9113b458490db7bb1d73c6071749f1fa270dfd31?ds=sidebyside Perl script to make `.so' links for all appropriate mLib functions. --- diff --git a/man/mksofiles b/man/mksofiles new file mode 100755 index 0000000..f5b28e8 --- /dev/null +++ b/man/mksofiles @@ -0,0 +1,73 @@ +#! /bin/sh +# -*-perl-*- + +exec perl -x $0 "$@"; + +#! perl + +# --- The idea --- +# +# Each manual page contains lines of the form +# +# .\" @function +# +# for each function and macro documented in it. This program sifts through +# all of the `toplevel' manual pages and creates little manpages which +# include the main text for each of the functions. +# +# The file `links' contains a generated list of little link manpages. This +# list is used for tidying (on a `make clean'), installing (for `make +# install') and for pruning out old links when they're not needed any more. + +%top = (); +%so = (); +if (open SO, "links") { while () { chomp; $so{$_} = -1; } } +if (open TOP, "toplevel") { while () { chomp; $top{$_} = -1; } } + +foreach $f (@ARGV) { + ($ext = $f) =~ s/^[^.]*\.//; + next unless $ext =~ /^\d/; + $sec = $&; + open FILE, $f or die "open($f): $!"; + $top = 0; + while () { + chomp; + next unless /^\.\\\"\s+\@/; + $top = 1; + $link = $'; + $full = "$link.$ext"; + next if $full eq $f; + open OUT, ">$full" or die "open(>$full): $!"; + print OUT ".so man$sec/$f\n"; + close OUT; + $so{$full}++; + } + $top{$f}++ if $top; + close FILE; +} + +$write = 0; +foreach $i (keys(%so)) { + next if $so{$i} == 0; + unlink $i if $so{$i} < 0; + $write = 1; +} +if ($write) { + open LINKS, ">links" or die "open(>links): $!"; + foreach $i (sort(keys(%so))) { + print LINKS "$i\n" if $so{$i} >= 0; + } + close LINKS; +} + +$write = 0; +foreach $i (keys(%top)) { + $write = 1 unless $top{$i} == 0; +} +if ($write) { + open TOP, ">toplevel" or die "open(>toplevel): $!"; + foreach $i (sort(keys(%top))) { + print TOP "$i\n" if $top{$i} >= 0; + } + close TOP; +}