chiark / gitweb /
build/maninst, build/pysetup.mk: Add proper header comments.
[cfd] / build / maninst
1 #! /bin/sh
2 ###
3 ### Install library manual pages with many symlinks
4 ###
5 ### (c) 2003, 2013, 2016, 2020 Straylight/Edgeware
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This file is part of the Common Files Distribution (`common').
11 ###
12 ### `Common' is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or
15 ### (at your option) any later version.
16 ###
17 ### `Common' is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ### GNU General Public License for more details.
21 ###
22 ### You should have received a copy of the GNU General Public License
23 ### along with `common'; if not, write to the Free Software Foundation,
24 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 set -e
27 ext="" mandir=/usr/local/man srcdir=. inst=install mode=644
28 while [ $# -gt 0 ]; do
29   case $1 in
30     -h)
31       echo "$0: [-e EXT] [-d DIR] [-i INSTALL] [-m MODE] [un]install FILE ..."
32       exit 0
33       ;;
34     -e) ext=$2; shift 2 ;;
35     -d) mandir=$2; shift 2 ;;
36     -i) inst=$2; shift 2 ;;
37     -m) mode=$2; shift 2 ;;
38     -s) srcdir=$2; shift 2 ;;
39     --) shift; break ;;
40     -*) echo >&2 "$0: unknown option \`$1'"; exit 1 ;;
41     *) break ;;
42   esac
43 done
44 op=$1; shift
45 case $op in
46   install | uninstall) ;;
47   *) echo >&2 "$0: unknown operation \`$1'"; exit 1 ;;
48 esac
49 for i; do
50   base=${i##*/} sec=${base##*.}
51   case $op in
52     install)
53       echo -n " Installing manpage $base$ext"
54       $inst -d "$mandir/man$sec"
55       $inst -m $mode "$srcdir/$i" "$mandir/man$sec/$base$ext"
56       ;;
57     uninstall)
58       rm -f "$mandir/man$sec/$base$ext"
59       ;;
60   esac
61   for l in `sed 's:^\.\\\"  *@::p; d' "$srcdir/$i"`; do
62     case $op in
63       install)
64         if [ "$l.$sec" != "$base" ]; then
65           echo -n "."
66           echo ".so man$sec/$base$ext" >"$mandir/man$sec/$l.$sec$ext"
67           chmod $mode "$mandir/man$sec/$l.$sec$ext"
68         fi
69         ;;
70       uninstall)
71         rm -f "$mandir/man$sec/$l.$sec$ext"
72         ;;
73     esac
74   done
75   case $op in
76     install) echo ;;
77   esac
78 done