cosmetix in Jambase: use single-quoted string where appropriate
[k8jam.git] / defaults / Jambase.install
blob369ab244d86947a402e11add2b7d30250a2afa1b
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 ;
16 #DESTDIR
19 # override this and return non-empty string to use your own rule
20 # $(1): gristed source file
21 # $(2): source file
22 # $(3): directory to install
23 # $(LOCATE): will be bound in actions
24 rule InstallUserDefined {
25   return ;
29 rule InstallUserChown {
30   if $(OWNER) && $(CHOWN) {
31     InstallChown $(1) : $(2) ;
32     OWNER on $(1) = $(OWNER) ;
33   }
37 rule InstallUserChgrp {
38   if $(GROUP) && $(CHGRP) {
39     InstallChgrp $(1) : $(2) ;
40     GROUP on $(1) = $(GROUP) ;
41   }
45 rule InstallUserChmod {
46   if $(CHMOD) && $(3) {
47     InstallChmod $(1) : $(2) ;
48     MODE on $(1) = $(3) ;
49   }
54 # various install rules
57 # $(1): source file
58 # $(2): install directory
59 rule InstallUninistall {
60   Clean uninstall : $(1:D=$(2):G=$(INSTALLGRIST)) ;
64 rule InstallDestDir {
65   local ddd = [ AddTrailingSlash $(DESTDIR) ] ;
66   local spl = [ Split $(<) ] ;
67   #
68   PREFIX ?= /usr/local ; # fix it here, so 'configure' can override it
69   if $(spl[1]) != '/' {
70     local ppp = [ AddTrailingSlash $(PREFIX) ] ;
71     #
72     if $(ddd) {
73       spl = [ Split $(ppp) ] ;
74       if $(spl[1]) = '/' { ppp = $(spl[2-]:J) ; }
75       ppp = $(ddd)$(ppp) ;
76     }
77     return $(ppp)$(<);
78   } else {
79     ddd = [ RemoveTrailingSlashes $(DESTDIR) ] ;
80     return $(ddd)$(<) ;
81   }
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
91 # directory
93 rule InstallLocate {
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) ;
100   local odir ;
101   #
102   # don't
103   #if $(srcdir) ~= '^[\./]' {
104   #}
105   #
106   ## if $(srcdir) {
107   ##   odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
108   ## } else {
109   ##   odir = $(outdir) ;
110   ## }
111   odir = $(outdir) ;
112   #
113   ## Echo 'InstallLocate:' "$(<)" '|' "$(>)" ;
114   ## Echo 'srcname:' "$(srcname)" ;
115   ## Echo 'srcdir :' "$(srcdir)" ;
116   ## Echo 'outdir :' "$(outdir)" ;
117   ## Echo 'odir   :' "$(odir)" ;
118   #
119   if $(>) {
120     LOCATE on $(<) = $(>) ;
121     Depends $(<) : $(odir) ;
122     MkDir $(odir) ;
123     return $(>) ;
124   }
125   return ;
129 # InstallInto dir : sources : mode : deptarget ;
130 rule InstallInto {
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
139   # targets are in dir
141   ## Echo "InstallInto: ddir: $(ddir)" ;
142   ## Echo "InstallInto: t: $(t)" ;
144   Depends install : $(t) ;
145   if $(4) {
146     Depends install : $(4) ;
147     NoCare $(t) ;
148     NoCare $(2) ;
149   }
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
157   for i in $(>) {
158     local tt = $(i:G=$(INSTALLGRIST)) ;
159     local t1 = $(i:D=$(ddir)) ;
160     #
161     ## Echo "tt: $(tt)" ;
162     ## Echo "t1: $(t1)" ;
163     ## Echo " i: $(i)" ;
164     #
165     NotFile $(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) ;
171       #
172       if $(OWNER) && $(CHOWN) {
173         InstallChown $(tt) : $(t1) ;
174         OWNER on $(tt) = $(OWNER) ;
175       }
176       #
177       if $(GROUP) && $(CHGRP) {
178         InstallChgrp $(tt) : $(t1) ;
179         GROUP on $(tt) = $(GROUP) ;
180       }
181       #
182       if $(CHMOD) && $(3) {
183         InstallChmod $(tt) : $(t1) ;
184         MODE on $(tt) = $(3) ;
185       }
186     }
187   }
191 # /InstallBin dir : sources [ : deptarget ] ;
193 # Copy _sources_ into _dir_ with mode $(EXEMODE)
195 rule InstallBin {
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)
207 rule InstallFile {
208   InstallInto $(<) : $(>) : $(FILEMODE) : $(3) ;
209   #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
213 # /InstallLib dir : sources [ : deptarget ] ;
215 # Copy _sources_ into _dir_ with mode $(FILEMODE)
217 rule InstallLib {
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
227 #  sources.
229 rule InstallMan {
230   # Really this just strips the . from the suffix
231   local i s d ;
233   for i in $(>) {
234     switch $(i:S) {
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 ;
239     }
240     d = man$(s) ;
241     InstallInto $(d:R=$(<)) : $(i) : $(FILEMODE) : $(3) ;
242   }
243   #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
247 # /InstallShell dir : sources [ : deptarget ] ;
249 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
251 rule InstallShell {
252   InstallInto $(<) : $(>) : $(SHELLMODE) : $(3) ;
253   #MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
257 actions quietly Install {
258   echo installing: $(>) "->" $(LOCATE)
259   $(CP) $(>) $(LOCATE)
263 actions quietly InstallChgrp {
264   $(CHGRP) $(GROUP) $(>)
268 actions quietly InstallChmod {
269   $(CHMOD) $(MODE) $(>)
273 actions quietly InstallChown {
274   $(CHOWN) $(OWNER) $(>)