Sync usage with man page.
[netbsd-mini2440.git] / crypto / dist / heimdal / cf / install-catman.sh
blobbcc210cd51c77add01db42cf24fd3b602453d670
1 #!/bin/sh
3 # $Heimdal: install-catman.sh 20232 2007-02-16 11:03:13Z lha $
4 # $NetBSD$
6 # install preformatted manual pages
8 cmd="$1"; shift
9 INSTALL_DATA="$1"; shift
10 mkinstalldirs="$1"; shift
11 srcdir="$1"; shift
12 manbase="$1"; shift
13 suffix="$1"; shift
14 catinstall="${INSTALL_CATPAGES-yes}"
16 for f in "$@"; do
17 base=`echo "$f" | sed 's/\(.*\)\.\([^.]*\)$/\1/'`
18 section=`echo "$f" | sed 's/\(.*\)\.\([^.]*\)$/\2/'`
19 mandir="$manbase/man$section"
20 catdir="$manbase/cat$section"
21 c="$base.cat$section"
23 if test "$catinstall" = yes -a -f "$srcdir/$c"; then
24 if test "$cmd" = install ; then
25 if test \! -d "$catdir"; then
26 eval "$mkinstalldirs $catdir"
28 eval "echo $INSTALL_DATA $srcdir/$c $catdir/$base.$suffix"
29 eval "$INSTALL_DATA $srcdir/$c $catdir/$base.$suffix"
30 elif test "$cmd" = uninstall ; then
31 eval "echo rm -f $catdir/$base.$suffix"
32 eval "rm -f $catdir/$base.$suffix"
35 for link in `sed -n -e '/SYNOPSIS/q;/DESCRIPTION/q;s/^\.Nm \([^ ]*\).*/\1/p' $srcdir/$f`; do
36 if test "$link" = "$base" ; then
37 continue
39 if test "$cmd" = install ; then
40 target="$mandir/$link.$section"
41 for lncmd in "ln -f $mandir/$base.$section $target" \
42 "ln -s $base.$section $target" \
43 "cp -f $mandir/$base.$section $target"
45 if eval "$lncmd"; then
46 eval echo "$lncmd"
47 break
49 done
50 if test "$catinstall" = yes -a -f "$srcdir/$c"; then
51 target="$catdir/$link.$suffix"
52 for lncmd in "ln -f $catdir/$base.$suffix $target" \
53 "ln -fs $base.$suffix $target" \
54 "cp -f $catdir/$base.$suffix $target"
56 if eval "$lncmd"; then
57 eval echo "$lncmd"
58 break
60 done
62 elif test "$cmd" = uninstall ; then
63 target="$mandir/$link.$section"
64 eval "echo rm -f $target"
65 eval "rm -f $target"
66 if test "$catinstall" = yes; then
67 target="$catdir/$link.$suffix"
68 eval "echo rm -f $target"
69 eval "rm -f $target"
72 done
73 done