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, version 3 of the License ONLY.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # InstallBin bin : sxedit ;
16 # InstallBinLink bin : sxrun : sxedit ;
19 # InstallMan man : $(TOP)/docs/sxedit.1 ;
22 INSTALLGRIST ?= installed ;
23 #PREFIX ?= /usr/local ;
27 # override this and return non-empty string to use your own rule
28 # $(1): gristed source file
30 # $(3): directory to install
31 # $(LOCATE): will be bound in actions
32 rule InstallUserDefined {
37 rule InstallUserChown {
38 if $(OWNER) && $(CHOWN) {
39 InstallChown $(1) : $(2) ;
40 OWNER on $(1) = $(OWNER) ;
45 rule InstallUserChgrp {
46 if $(GROUP) && $(CHGRP) {
47 InstallChgrp $(1) : $(2) ;
48 GROUP on $(1) = $(GROUP) ;
53 rule InstallUserChmod {
55 InstallChmod $(1) : $(2) ;
62 # various install rules
66 # $(2): install directory
67 rule InstallUninistall {
68 #Echo $(1:D=$(2):G=$(INSTALLGRIST)) ;
69 Clean uninstall : $(1:D=$(2):G=$(INSTALLGRIST)) ;
73 rule GetInstallDestDir {
74 local res = $(DESTDIR) ;
75 if $(res) = '' { res = $(DEST_DIR) ; }
81 local ddir = [ GetInstallDestDir ] ;
82 local ddd = [ AddTrailingSlash $(ddir) ] ;
83 local spl = [ Split $(<) ] ;
85 PREFIX ?= /usr/local ; # fix it here, so 'configure' can override it
87 local ppp = [ AddTrailingSlash $(PREFIX) ] ;
90 spl = [ Split $(ppp) ] ;
91 if $(spl[1]) = '/' { ppp = $(spl[2-]:J) ; }
96 ddd = [ RemoveTrailingSlashes $(ddir) ] ;
102 # /InstallLocate targets : directory
104 # Creates _dir_ and causes _target_ to be built into _dir_
106 # This is done by setting the target-specific variable LOCATE
107 # on _targets_, and arranges with @MkDir to create the target
111 # Note we grist the directory name with 'dir',
112 # so that directory path components and other
113 # targets don't conflict.
114 local srcname = $(<[1]:G=) ;
115 local srcdir = $(srcname:D) ;
116 local outdir = $(>[1]:G=dir) ;
120 #if $(srcdir) ~= '^[\./]' {
124 ## odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
126 ## odir = $(outdir) ;
130 ## Echo 'InstallLocate:' "$(<)" '|' "$(>)" ;
131 ## Echo 'srcname:' "$(srcname)" ;
132 ## Echo 'srcdir :' "$(srcdir)" ;
133 ## Echo 'outdir :' "$(outdir)" ;
134 ## Echo 'odir :' "$(odir)" ;
137 LOCATE on $(<) = $(>) ;
138 Depends $(<) : $(odir) ;
146 # InstallInto dir : sources : mode : deptarget [ : mklink-bin ] ;
148 local i t ddir locdir ;
150 t = $(>:G=$(INSTALLGRIST)) ;
151 ddir = [ InstallDestDir $(<) ] ;
153 # Arrange for jam install
154 # Arrange for jam uninstall
155 # sources are in SEARCH_SOURCE
158 ## Echo "InstallInto: ddir: $(ddir)" ;
159 ## Echo "InstallInto: t: $(t)" ;
161 Depends install : $(t) ;
163 Depends install : $(4) ;
167 #Clean uninstall : $(t) ;
168 #Clean uninstall : $(t) ;
169 SEARCH on $(ddir) = $(SEARCH_SOURCE) ;
170 locdir = [ InstallLocate $(t) : $(ddir) ] ;
172 # For each source, make gristed target name
173 # and Install, InstallChmod, InstallChown, and InstallChgrp
175 local tt = $(i:G=$(INSTALLGRIST)) ;
176 local t1 = $(i:D=$(ddir)) ;
178 ## Echo "tt: $(tt)" ;
179 ## Echo "t1: $(t1)" ;
183 Depends $(tt) : $(i) ;
184 #Clean uninstall : $(i:D=$(locdir):G=$(INSTALLGRIST)) ;
185 if ! [ InstallUserDefined $(tt) : $(i) : $(locdir) ] {
187 InstallFLink $(tt) : $(5) ;
189 Install $(tt) : $(i) ;
191 InstallUninistall $(i) : $(locdir) ;
193 if $(OWNER) && $(CHOWN) {
194 InstallChown $(tt) : $(t1) ;
195 OWNER on $(tt) = $(OWNER) ;
198 if $(GROUP) && $(CHGRP) {
199 InstallChgrp $(tt) : $(t1) ;
200 GROUP on $(tt) = $(GROUP) ;
203 if $(CHMOD) && $(3) {
204 InstallChmod $(tt) : $(t1) ;
205 MODE on $(tt) = $(3) ;
212 # /InstallBin dir : sources [ : deptarget ] ;
214 # Copy _sources_ into _dir_ with mode $(EXEMODE)
217 local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
219 InstallInto $(<) : $(_t) : $(EXEMODE) : $(3) ;
220 #MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
224 # /InstallBinLink dir : linkname : sources [ : deptarget ] ;
226 rule InstallBinLink {
227 local _t = [ FAppendSuffix $(2) : $(SUFEXE) ] ;
229 InstallInto $(<) : $(_t) : $(EXEMODE) : $(4) $(3) : $(3) ;
230 #MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
234 # /InstallFile dir : sources [ : deptarget ] ;
236 # Copy _sources_ into _dir_ with mode $(FILEMODE)
239 InstallInto $(<) : $(>) : $(FILEMODE) : $(3) ;
240 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
244 # /InstallLib dir : sources [ : deptarget ] ;
246 # Copy _sources_ into _dir_ with mode $(FILEMODE)
249 InstallInto $(<) : $(>) : $(FILEMODE) : $(3) ;
250 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
254 INSTALL_SO_LIB_WARNING_SHOWN = ona ;
256 # /InstallSoLib dir : sources [ : deptarget ] ;
258 # Copy _sources_ into _dir_ with mode $(FILEMODE)
261 #Echo "SOLIB: $(>)" ;
263 local tgtso = [ SharedLibraryGetVersionedName $(>) ] ;
264 #Echo "tgtso: " $(tgtso) ;
266 if [ IsSharedLibraryVersioned $(>) ] {
267 if $(INSTALL_SO_LIB_WARNING_SHOWN) = 'ona' {
268 INSTALL_SO_LIB_WARNING_SHOWN = tan ;
269 Echo "**************************************************************" ;
270 Echo "* WARNING: don't forget to execute 'ldconfig' after install! *" ;
271 Echo "**************************************************************" ;
275 #tgtso = $(>:S=$(SUFLIBSHR)) ;
277 InstallInto $(<) : $(tgtso) : $(EXEMODE) : $(3) ;
278 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
282 # /InstallMan dir : sources [ : deptarget ] ;
284 # Copy _sources_ into the appropriate subdirectory of _dir_ with mode
285 # $(FILEMODE). The subdirectory is manS, where S is the suffix of each of
289 # Really this just strips the . from the suffix
294 case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
295 case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
296 case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
297 case .n : s = n ; case .man : s = 1 ;
300 InstallInto $(d:R=$(<)) : $(i) : $(FILEMODE) : $(3) ;
302 #MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
306 # /InstallShell dir : sources [ : deptarget ] ;
308 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
311 InstallInto $(<) : $(>) : $(SHELLMODE) : $(3) ;
312 #MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
316 actions quietly Install {
317 echo installing: $(>) "->" $(LOCATE)
322 actions quietly InstallFLink {
323 echo linking: $(<) "->" $(>)
324 $(RM) $(<) 2>/dev/null
329 actions quietly InstallChgrp {
330 $(CHGRP) $(GROUP) $(>)
334 actions quietly InstallChmod {
335 $(CHMOD) $(MODE) $(>)
339 actions quietly InstallChown {
340 $(CHOWN) $(OWNER) $(>)