man-page-generation-20051220
[openafs.git] / doc / man-pages / generate-man
1 #!/bin/sh
2 #
3 # Generate the OpenAFS man pages from POD source.  This script is normally
4 # invoked by regen.sh but may be run at any time to rebuild all of the man
5 # pages (with a newer version of pod2man than was used for the release, for
6 # instance).
7
8 # Exit on any error.
9 set -e
10
11 if [ ! -d pod1 ] ; then
12     echo 'generate-man must be run from the doc/man-pages directory' >&2
13     exit 1
14 fi
15
16 if ! pod2man pod1/afs.pod > /dev/null ; then
17     echo 'pod2man not found, skipping man page generation' >&2
18     exit 1
19 fi
20 if ! perl -e 'use Pod::Man 2.04' > /dev/null 2>&1 ; then
21     echo 'Pod::Man is older than the recommended version of 2.04 or later' >&2
22     echo 'Continuing with man page generation anyway' >&2
23 fi
24
25 # Create the directories.  We generate each section into its own directory
26 # to make installation rules easier.
27 [ -d man1 ] || mkdir man1
28 [ -d man5 ] || mkdir man5
29 [ -d man8 ] || mkdir man8
30
31 # Generate each set of man pages.  For each, allow for the case of the
32 # directory being empty.  In that case, for won't expand the wildcard, and
33 # we want to avoid running pod2man with a wildcard as an argument.
34 pod1=`ls pod1`
35 if [ -n "$pod1" ] ; then
36     cd pod1
37     for f in *.pod ; do
38         pod2man -c 'AFS Command Reference' -r 'OpenAFS' -s 1 "$f" \
39             > ../man1/`echo "$f" | sed 's/\.pod$//'`.1
40     done
41     cd ..
42 fi
43 pod5=`ls pod5`
44 if [ -n "$pod5" ] ; then
45     cd pod5
46     for f in *.pod ; do
47         pod2man -c 'AFS File Reference' -r 'OpenAFS' -s 5 "$f" \
48             > ../man5/`echo "$f" | sed 's/\.pod$//'`.5
49     done
50     cd ..
51 fi
52 pod8=`ls pod8`
53 if [ -n "$pod8" ] ; then
54     cd pod8
55     for f in *.pod ; do
56         pod2man -c 'AFS Command Reference' -r 'OpenAFS' -s 8 "$f" \
57             > ../man8/`echo "$f" | sed 's/\.pod$//'`.8
58     done
59     cd ..
60 fi