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