#! /bin/sh

# usage: manlist < DISTLIST

# Given a list DISTLIST of source files to distribute with a package,
# this script generates (on standard output) a list of installed man
# pages which should accompany that package.  The intended use is that
# you run the "distlist" script to generate a preliminary distribution
# list, which you then pipe to manlist.  The final distribution list is
# the concatentation of the preliminary list with the output of manlist,
# e.g. "manlist < DISTLIST >> DISTLIST".

# NOTE: This script assumes that all man page files end in .1, .3, or
# .5.  It also assumes that any file in the source tree ending with
# one of these suffixes is a man page.

# pick out pathnames from the src tree that end in .1, .3, or .5:
for file in `grep '\./src.*\.[135]$'` ; do
  basename $file ;
done |

# now replace the final ".n" with " n"; i.e. replace the last period
# with a space.  We do this just in case some names have more than
# one period in them.
sed -e 's:\.\([135]\)$: \1:' |

# now print the pathnames of the installed copies of the man pages;
# awk can now assume that $1 is the basename, $2 the suffix (= the man
# section number).
awk '{ printf "./man/man%s/%s.%s\n", $2,$1,$2 ;
      printf "./man/cat%s/%s.%s\n", $2,$1,$2 ; }' |

# and finally, just for prettiness, sort:
sort
