1#! /bin/sh
2# installman.sh --- install or uninstall manpages for Vim
3#
4# arguments:
5# 1  what: "install", "uninstall" or "xxd"
6# 2  target directory			   e.g., "/usr/local/man/it/man1"
7# 3  language addition			   e.g., "" or "-it"
8# 4  vim location as used in manual pages  e.g., "/usr/local/share/vim"
9# 5  runtime dir for menu.vim et al.	   e.g., "/usr/local/share/vim/vim81"
10# 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"
16
17errstatus=0
18
19what=$1
20destdir=$2
21langadd=$3
22vimloc=$4
23scriptloc=$5
24vimrcloc=$6
25helpsource=$7
26manmod=$8
27exename=$9
28# older shells don't support ${10}
29shift
30vimdiffname=$9
31shift
32evimname=$9
33
34helpsubloc=$scriptloc/doc
35printsubloc=$scriptloc/print
36synsubloc=$scriptloc/syntax
37tutorsubloc=$scriptloc/tutor
38
39if test $what = "install" -o $what = "xxd"; then
40   if test ! -d $destdir; then
41      echo creating $destdir
42      /bin/sh install-sh -c -d $destdir
43   fi
44fi
45
46# Note: setting LC_ALL to C is required to avoid illegal byte errors from sed
47# on some systems.
48
49if test $what = "install"; then
50   # vim.1
51   if test -r $helpsource/vim$langadd.1; then
52      echo installing $destdir/$exename.1
53      LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
54	      -e s+$vimloc/doc+$helpsubloc+ \
55	      -e s+$vimloc/print+$printsubloc+ \
56	      -e s+$vimloc/syntax+$synsubloc+ \
57	      -e s+$vimloc/tutor+$tutorsubloc+ \
58	      -e s+$vimloc/vimrc+$vimrcloc/vimrc+ \
59	      -e s+$vimloc/gvimrc+$vimrcloc/gvimrc+ \
60	      -e s+$vimloc/menu.vim+$scriptloc/menu.vim+ \
61	      -e s+$vimloc/bugreport.vim+$scriptloc/bugreport.vim+ \
62	      -e s+$vimloc/filetype.vim+$scriptloc/filetype.vim+ \
63	      -e s+$vimloc/scripts.vim+$scriptloc/scripts.vim+ \
64	      -e s+$vimloc/optwin.vim+$scriptloc/optwin.vim+ \
65	      -e 's+$vimloc/\*.ps+$scriptloc/\*.ps+' \
66	      $helpsource/vim$langadd.1 > $destdir/$exename.1
67      chmod $manmod $destdir/$exename.1
68   fi
69
70   # vimtutor.1
71   if test -r $helpsource/vimtutor$langadd.1; then
72      echo installing $destdir/$exename""tutor.1
73      LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
74	      -e s+$vimloc/tutor+$tutorsubloc+ \
75	      $helpsource/vimtutor$langadd.1 > $destdir/$exename""tutor.1
76      chmod $manmod $destdir/$exename""tutor.1
77   fi
78
79   # vimdiff.1
80   if test -r $helpsource/vimdiff$langadd.1; then
81      echo installing $destdir/$vimdiffname.1
82      cp $helpsource/vimdiff$langadd.1 $destdir/$vimdiffname.1
83      chmod $manmod $destdir/$vimdiffname.1
84   fi
85
86   # evim.1
87   if test -r $helpsource/evim$langadd.1; then
88      echo installing $destdir/$evimname.1
89      LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
90	      -e s+$vimloc/evim.vim+$scriptloc/evim.vim+ \
91	      $helpsource/evim$langadd.1 > $destdir/$evimname.1
92      chmod $manmod $destdir/$evimname.1
93   fi
94fi
95
96if test $what = "uninstall"; then
97   echo Checking for Vim manual pages in $destdir...
98   if test -r $destdir/$exename.1; then
99      echo deleting $destdir/$exename.1
100      rm -f $destdir/$exename.1
101   fi
102   if test -r $destdir/$exename""tutor.1; then
103      echo deleting $destdir/$exename""tutor.1
104      rm -f $destdir/$exename""tutor.1
105   fi
106   if test -r $destdir/$vimdiffname.1; then
107      echo deleting $destdir/$vimdiffname.1
108      rm -f $destdir/$vimdiffname.1
109   fi
110   if test -r $destdir/$evimname.1; then
111      echo deleting $destdir/$evimname.1
112      rm -f $destdir/$evimname.1
113   fi
114fi
115
116if test $what = "xxd" -a -r "$helpsource/xxd${langadd}.1"; then
117   echo installing $destdir/xxd.1
118   cp $helpsource/xxd$langadd.1 $destdir/xxd.1
119   chmod $manmod $destdir/xxd.1
120fi
121
122exit $errstatus
123
124# vim: set sw=3 sts=3 :
125