blob: 98bbb281ab0ced0dfe27aa3560eac08699d5e360 [file] [log] [blame]
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00001#! /bin/sh
2# installman.sh --- install or uninstall manpages for Vim
3#
4# arguments:
5# 1 what: "install", "uninstall" or "xxd"
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00006# 2 target directory e.g., "/usr/local/man/it/man1"
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007# 3 language addition e.g., "" or "-it"
8# 4 vim location as used in manual pages e.g., "/usr/local/share/vim"
Bram Moolenaarad3ec762019-04-21 00:00:13 +02009# 5 runtime dir for menu.vim et al. e.g., "/usr/local/share/vim/vim81"
Bram Moolenaarc9b4b052006-04-30 18:54:39 +000010# 6 runtime dir for global vimrc file e.g., "/usr/local/share/vim"
11# 7 source dir for help files e.g., "../runtime/doc"
12# 8 mode bits for manpages e.g., "644"
13# 9 vim exe name e.g., "vim"
14# 10 name of vimdiff exe e.g., "vimdiff"
15# 11 name of evim exe e.g., "evim"
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000016
17errstatus=0
18
19what=$1
20destdir=$2
21langadd=$3
22vimloc=$4
23scriptloc=$5
24vimrcloc=$6
25helpsource=$7
26manmod=$8
27exename=$9
Bram Moolenaar910f66f2006-04-05 20:41:53 +000028# older shells don't support ${10}
29shift
30vimdiffname=$9
31shift
32evimname=$9
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000033
34helpsubloc=$scriptloc/doc
Bram Moolenaare37d50a2008-08-06 17:06:04 +000035printsubloc=$scriptloc/print
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000036synsubloc=$scriptloc/syntax
37tutorsubloc=$scriptloc/tutor
38
39if test $what = "install" -o $what = "xxd"; then
40 if test ! -d $destdir; then
41 echo creating $destdir
Bram Moolenaar1d4be822017-04-21 23:00:02 +020042 /bin/sh install-sh -c -d $destdir
Bram Moolenaar20563e02022-02-19 13:25:18 +000043 chmod 755 $destdir
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000044 fi
45fi
46
Bram Moolenaar72e8f0b2014-06-25 15:02:33 +020047# Note: setting LC_ALL to C is required to avoid illegal byte errors from sed
48# on some systems.
49
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000050if test $what = "install"; then
51 # vim.1
Bram Moolenaar73b4aba2018-07-28 18:16:48 +020052 if test -r $helpsource/vim$langadd.1; then
53 echo installing $destdir/$exename.1
54 LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
55 -e s+$vimloc/doc+$helpsubloc+ \
56 -e s+$vimloc/print+$printsubloc+ \
57 -e s+$vimloc/syntax+$synsubloc+ \
58 -e s+$vimloc/tutor+$tutorsubloc+ \
59 -e s+$vimloc/vimrc+$vimrcloc/vimrc+ \
60 -e s+$vimloc/gvimrc+$vimrcloc/gvimrc+ \
61 -e s+$vimloc/menu.vim+$scriptloc/menu.vim+ \
62 -e s+$vimloc/bugreport.vim+$scriptloc/bugreport.vim+ \
63 -e s+$vimloc/filetype.vim+$scriptloc/filetype.vim+ \
64 -e s+$vimloc/scripts.vim+$scriptloc/scripts.vim+ \
65 -e s+$vimloc/optwin.vim+$scriptloc/optwin.vim+ \
66 -e 's+$vimloc/\*.ps+$scriptloc/\*.ps+' \
67 $helpsource/vim$langadd.1 > $destdir/$exename.1
68 chmod $manmod $destdir/$exename.1
69 fi
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000070
71 # vimtutor.1
Bram Moolenaar73b4aba2018-07-28 18:16:48 +020072 if test -r $helpsource/vimtutor$langadd.1; then
73 echo installing $destdir/$exename""tutor.1
74 LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
75 -e s+$vimloc/tutor+$tutorsubloc+ \
76 $helpsource/vimtutor$langadd.1 > $destdir/$exename""tutor.1
77 chmod $manmod $destdir/$exename""tutor.1
78 fi
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000079
80 # vimdiff.1
Bram Moolenaar73b4aba2018-07-28 18:16:48 +020081 if test -r $helpsource/vimdiff$langadd.1; then
82 echo installing $destdir/$vimdiffname.1
83 cp $helpsource/vimdiff$langadd.1 $destdir/$vimdiffname.1
84 chmod $manmod $destdir/$vimdiffname.1
85 fi
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000086
87 # evim.1
Bram Moolenaar73b4aba2018-07-28 18:16:48 +020088 if test -r $helpsource/evim$langadd.1; then
89 echo installing $destdir/$evimname.1
90 LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
91 -e s+$vimloc/evim.vim+$scriptloc/evim.vim+ \
92 $helpsource/evim$langadd.1 > $destdir/$evimname.1
93 chmod $manmod $destdir/$evimname.1
94 fi
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000095fi
96
97if test $what = "uninstall"; then
98 echo Checking for Vim manual pages in $destdir...
99 if test -r $destdir/$exename.1; then
100 echo deleting $destdir/$exename.1
101 rm -f $destdir/$exename.1
102 fi
103 if test -r $destdir/$exename""tutor.1; then
104 echo deleting $destdir/$exename""tutor.1
105 rm -f $destdir/$exename""tutor.1
106 fi
107 if test -r $destdir/$vimdiffname.1; then
108 echo deleting $destdir/$vimdiffname.1
109 rm -f $destdir/$vimdiffname.1
110 fi
111 if test -r $destdir/$evimname.1; then
112 echo deleting $destdir/$evimname.1
113 rm -f $destdir/$evimname.1
114 fi
115fi
116
Bram Moolenaar73b4aba2018-07-28 18:16:48 +0200117if test $what = "xxd" -a -r "$helpsource/xxd${langadd}.1"; then
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +0000118 echo installing $destdir/xxd.1
119 cp $helpsource/xxd$langadd.1 $destdir/xxd.1
120 chmod $manmod $destdir/xxd.1
121fi
122
123exit $errstatus
124
Bram Moolenaar11cbeb12005-03-11 22:51:16 +0000125# vim: set sw=3 sts=3 :