doc: add dependency on vars.texi
[heimdal.git] / cf / install-catman.sh
blobf1a258185b659f3ddc5d4b65cb7aa742db73fc0b
1 #!/bin/sh
3 # $Id$
5 # install preformatted manual pages
7 cmd="$1"; shift
8 INSTALL_DATA="$1"; shift
9 mkinstalldirs="$1"; shift
10 srcdir="$1"; shift
11 manbase="$1"; shift
12 suffix="$1"; shift
13 catinstall="${INSTALL_CATPAGES-yes}"
15 for f in "$@"; do
16 echo $f
17 base=`echo "$f" | sed 's~\.[^.]*$~~; s~.*/~~'`
18 section=`echo "$f" | sed 's/^[^.]*\.//'`
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 eval target="$catdir/$link.$suffix"
52 eval source="$catdir/$base.$suffix"
53 for lncmd in "ln -f $source $target" \
54 "ln -fs $source $target" \
55 "cp -f $catdir/$source $target"
57 if eval "$lncmd"; then
58 eval echo "$lncmd"
59 break
61 done
63 elif test "$cmd" = uninstall ; then
64 target="$mandir/$link.$section"
65 eval "echo rm -f $target"
66 eval "rm -f $target"
67 if test "$catinstall" = yes; then
68 target="$catdir/$link.$suffix"
69 eval "echo rm -f $target"
70 eval "rm -f $target"
73 done
74 done