1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 INSTALLGRIST ?= installed ;
15 #PREFIX ?= /usr/local ;
19 # override this and return non-empty string to use your own rule
20 # $(1): gristed source file
22 # $(3): directory to install
23 # $(LOCATE): will be bound in actions
24 rule InstallUserDefined {
29 rule InstallUserChown {
30 if $(OWNER) && $(CHOWN) {
31 InstallChown $(1) : $(2) ;
32 OWNER on $(1) = $(OWNER) ;
37 rule InstallUserChgrp {
38 if $(GROUP) && $(CHGRP) {
39 InstallChgrp $(1) : $(2) ;
40 GROUP on $(1) = $(GROUP) ;
45 rule InstallUserChmod {
47 InstallChmod $(1) : $(2) ;
54 # various install rules
58 # $(2): install directory
59 rule InstallUninistall {
60 Clean uninstall : $(1:D=$(2):G=$(INSTALLGRIST)) ;
65 local ddd = [ AddTrailingSlash $(DESTDIR) ] ;
66 local spl = [ Split $(<) ] ;
68 PREFIX ?= /usr/local ; # fix it here, so 'configure' can override it
70 local ppp = [ AddTrailingSlash $(PREFIX) ] ;
73 spl = [ Split $(ppp) ] ;
74 if $(spl[1]) = '/' { ppp = $(spl[2-]:J) ; }
79 ddd = [ RemoveTrailingSlashes $(DESTDIR) ] ;
85 # /InstallLocate targets : directory
87 # Creates _dir_ and causes _target_ to be built into _dir_
89 # This is done by setting the target-specific variable LOCATE
90 # on _targets_, and arranges with @MkDir to create the target
94 # Note we grist the directory name with 'dir',
95 # so that directory path components and other
96 # targets don't conflict.
97 local srcname = $(<[1]:G=) ;
98 local srcdir = $(srcname:D) ;
99 local outdir = $(>[1]:G=dir) ;
103 #if $(srcdir) ~= '^[\./]' {
107 ## odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
109 ## odir = $(outdir) ;
113 ## Echo 'InstallLocate:' "$(<)" '|' "$(>)" ;
114 ## Echo 'srcname:' "$(srcname)" ;
115 ## Echo 'srcdir :' "$(srcdir)" ;
116 ## Echo 'outdir :' "$(outdir)" ;
117 ## Echo 'odir :' "$(odir)" ;
120 LOCATE on $(<) = $(>) ;
121 Depends $(<) : $(odir) ;
129 # InstallInto dir : sources : mode : deptarget ;
131 local i t ddir locdir ;
133 t = $(>:G=$(INSTALLGRIST)) ;
134 ddir = [ InstallDestDir $(<) ] ;
136 # Arrange for jam install
137 # Arrange for jam uninstall
138 # sources are in SEARCH_SOURCE
141 ## Echo "InstallInto: ddir: $(ddir)" ;
142 ## Echo "InstallInto: t: $(t)" ;
144 Depends install : $(t) ;
146 Depends install : $(4) ;
150 #Clean uninstall : $(t) ;
151 #Clean uninstall : $(t) ;
152 SEARCH on $(ddir) = $(SEARCH_SOURCE) ;
153 locdir = [ InstallLocate $(t) : $(ddir) ] ;
155 # For each source, make gristed target name
156 # and Install, InstallChmod, InstallChown, and InstallChgrp
158 local tt = $(i:G=$(INSTALLGRIST)) ;
159 local t1 = $(i:D=$(ddir)) ;
161 ## Echo "tt: $(tt)" ;
162 ## Echo "t1: $(t1)" ;
166 Depends $(tt) : $(i) ;
167 #Clean uninstall : $(i:D=$(locdir):G=$(INSTALLGRIST)) ;
168 if ! [ InstallUserDefined $(tt) : $(i) : $(locdir) ] {
169 Install $(tt) : $(i) ;
170 InstallUninistall $(i) : $(locdir) ;
172 if $(OWNER) && $(CHOWN) {
173 InstallChown $(tt) : $(t1) ;
174 OWNER on $(tt) = $(OWNER) ;
177 if $(GROUP) && $(CHGRP) {
178 InstallChgrp $(tt) : $(t1) ;
179 GROUP on $(tt) = $(GROUP) ;
182 if $(CHMOD) && $(3) {
183 InstallChmod $(tt) : $(t1) ;
184 MODE on $(tt) = $(3) ;
191 # /InstallBin dir : sources [ : deptarget ] ;
193 # Copy _sources_ into _dir_ with mode $(EXEMODE)
196 local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
198 InstallInto $(<) : $(_t) : $(EXEMODE) : $(3) ;
199 #MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
203 # /InstallFile dir : sources [ : deptarget ] ;
205 # Copy _sources_ into _dir_ with mode $(FILEMODE)
208 InstallInto $(<) : $(>) : $(FILEMODE) : $(3) ;
209 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
213 # /InstallLib dir : sources [ : deptarget ] ;
215 # Copy _sources_ into _dir_ with mode $(FILEMODE)
218 InstallInto $(<) : $(>) : $(FILEMODE) : $(3) ;
219 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
223 # /InstallMan dir : sources [ : deptarget ] ;
225 # Copy _sources_ into the appropriate subdirectory of _dir_ with mode
226 # $(FILEMODE). The subdirectory is manS, where S is the suffix of each of
230 # Really this just strips the . from the suffix
235 case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
236 case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
237 case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
238 case .n : s = n ; case .man : s = 1 ;
241 InstallInto $(d:R=$(<)) : $(i) : $(FILEMODE) : $(3) ;
243 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
247 # /InstallShell dir : sources [ : deptarget ] ;
249 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
252 InstallInto $(<) : $(>) : $(SHELLMODE) : $(3) ;
253 #MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
257 actions quietly Install {
258 echo installing: $(>) "->" $(LOCATE)
263 actions quietly InstallChgrp {
264 $(CHGRP) $(GROUP) $(>)
268 actions quietly InstallChmod {
269 $(CHMOD) $(MODE) $(>)
273 actions quietly InstallChown {
274 $(CHOWN) $(OWNER) $(>)