Ignore:
Timestamp:
Jul 26, 2011, 1:34:10 PM (14 years ago)
Author:
bird
Message:

footer.kmk: allow absolute paths in _STAGE/_INST if they are under PATH_OBJ. The purpose is for tarball staging and similar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r2514 r2517  
    13201320
    13211321if1of ($(insttype), stage both)
    1322  local stage := $(evalcall FIRST-DEFINED-VAR, \
     1322 local stage := $(strip $(firstdefined \
    13231323        $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
    13241324        $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
     
    13351335        $(target)_STAGE \
    13361336        $(target)_INST \
    1337         definst )
     1337        definst \
     1338        ,value))
    13381339 $(target)_1_STAGE := $(stage)
    13391340 if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix.
     
    13511352
    13521353if1of ($(insttype), both)
    1353  local inst := $(evalcall FIRST-DEFINED-VAR, \
     1354 local inst := $(strip $(firstdefined \
    13541355        $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
    13551356        $(target)_INST.$(bld_trg).$(bld_trg_arch) \
     
    13591360        $(target)_INST.$(bld_type) \
    13601361        $(target)_INST \
    1361         definst )
     1362        definst \
     1363        ,value))
    13621364 $(target)_1_INST := $(inst)
    13631365 if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
     
    15261528# Determine the actual INST and STAGE sub-dirs to use for this target.
    15271529if1of ($(insttype), stage both)
    1528  local stage := $(evalcall FIRST-DEFINED-VAR, \
     1530 local stage := $(strip $(firstdefined \
    15291531        $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
    15301532        $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
     
    15411543        $(target)_STAGE \
    15421544        $(target)_INST \
    1543         definst )
     1545        definst \
     1546        ,value))
    15441547 if $(words $(stage)) > 1
    15451548  $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.)
     
    15521555
    15531556if1of ($(insttype), both)
    1554  local inst := $(evalcall FIRST-DEFINED-VAR, \
     1557 local inst := $(strip $(firstdefined \
    15551558        $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
    15561559        $(target)_INST.$(bld_trg).$(bld_trg_arch) \
     
    15601563        $(target)_INST.$(bld_type) \
    15611564        $(target)_INST \
    1562         definst )
     1565        definst \
     1566        ,value))
    15631567 if $(words $(inst)) > 1
    15641568  $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.)
    15651569  local inst := $(word 1, $(inst))
     1570 endif
     1571 ifneq ($(root $(stage)),)
     1572  $(error kBuild: The INST property should not start with a root specification)
    15661573 endif
    15671574 $(target)_1_INST := $(inst)
     
    30333040local srcdst    := $(word $(words $(srcdst)),$(srcdst))
    30343041
    3035 # Calc destinations.
     3042# instfun, mode, uid and gid
    30363043ifdef $(srcsrc)_INSTFUN
    30373044 local instfun := $(srcsrc)_INSTFUN
     
    30393046 local instfun := $(top_instfun)
    30403047endif
    3041 
    3042 local stage    := $(firstword $($(srcsrc)_STAGE) $($(srcsrc)_INST) $($(target)_1_STAGE))
    3043 ifneq ($(substr $(stage),-1),/)
    3044  $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE property without a trailing slash.)
    3045  local stage   := $(stage)/
    3046 endif
    3047 local stage    := $(stage)$(dir $(srcdstdir))
    3048 local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE))
    3049 
    3050 ifeq ($(insttype),both)
    3051  local inst     := $(firstword $($(srcsrc)_INST) $($(target)_1_INST))
    3052  ifneq ($(substr $(inst),-1),/)
    3053   $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash.)
    3054   local inst    := $(inst)/
    3055  endif
    3056  local inst     := $(inst)$(dir $(srcdstdir))
    3057  local instdst  := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
    3058 endif
    3059 
    3060 #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
    3061 
    3062 # mode, uid and gid
    30633048local mode := $(firstword \
    30643049        $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
     
    31453130
    31463131# Generate the staging rule (requires double evaluation).
     3132local stage      := $(strip $(firstdefined $(srcsrc)_STAGE $(srcsrc)_INST $(target)_1_STAGE,value))
     3133if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
     3134 $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
     3135 local stage     := $(stage)/
     3136endif
     3137local stage      := $(stage)$(dir $(srcdstdir))
     3138ifeq ($(root $(stage)),)
     3139 local stagedst  := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE))
     3140else
     3141 local stage     := $(abspath $(stage))
     3142 ifeq ($(pos $(PATH_OBJ),$(stage)),1)
     3143  local stage    := $(substr $(stage), 1, $(length-var PATH_OBJ))
     3144  local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_OBJ))
     3145 else
     3146  $(error kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
     3147 endif
     3148endif
    31473149ifdef $(srcsrc)_INSTALLER
    31483150 local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
     
    31623164# Generate the install rule
    31633165ifeq ($(insttype),both)
     3166 local inst     := $(strip $(firstdefined $(srcsrc)_INST $(target)_1_INST,value))
     3167 if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
     3168  $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash: '$(inst)')
     3169  local inst    := $(inst)/
     3170 endif
     3171 local inst     := $(inst)$(dir $(srcdstdir))
     3172 ifneq ($(root $(inst)),)
     3173  $(error kBuild: File $(srcsrc) in install target $(target) has a INST property with an absolute path: '$(inst)')
     3174 endif
     3175 local instdst  := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
     3176
    31643177 ifdef $(srcsrc)_INSTALLER
    3165   local instcmd  := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
     3178  local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
    31663179 else ifdef $(target)_INSTALLER
    3167   local instcmd  := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
     3180  local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
    31683181 else
    31693182  local instcmd := $$(INSTALL)\
     
    31783191endif
    31793192
     3193#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
    31803194endef # def_install_src
    31813195$(eval-opt-var def_install_src)
     
    32123226local symdst := $(word $(words $(symdst)),$(symdst))
    32133227
    3214 # Calc destinations
     3228# Figure which install function to use below.
    32153229ifdef $(symlnk)_INSTFUN
    32163230 local instfun := $(symlnk)_INSTFUN
     
    32193233endif
    32203234
    3221 local stage    := $(firstword $($(symlnk)_STAGE) $($(symlnk)_INST) $($(target)_1_STAGE))
    3222 ifneq ($(substr $(stage),-1),/)
    3223  $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE property without a trailing slash: '$(stage)')
    3224  local stage   := $(stage)/
    3225 endif
    3226 local stage    := $(stage)$(dir $(srcdstdir))
    3227 local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
    3228 
    3229 local inst     := $(firstword $($(symlnk)_INST) $($(target)_1_INST))
    3230 ifneq ($(substr $(inst),-1),/)
    3231  $(warning kBuild: Symlnk $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)')
    3232  local inst    := $(inst)/
    3233 endif
    3234 local inst     := $(inst)$(dir $(srcdstdir))
    3235 local instdst  := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
    3236 #$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
    3237 
    3238 # Generate the staging rule (requires double evaluation).
     3235# Calc stage destination and generate the rule (requires double evaluation).
     3236local stage      := $(strip $(firstdefined $(symlnk)_STAGE $(symlnk)_INST $(target)_1_STAGE,value))
     3237if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
     3238 $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
     3239 local stage     := $(stage)/
     3240endif
     3241local stage      := $(stage)$(dir $(srcdstdir))
     3242ifeq ($(root $(stage)),)
     3243 local stagedst  := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
     3244else
     3245 local stage     := $(abspath $(stage))
     3246 ifeq ($(pos $(PATH_OBJ),$(stage)),1)
     3247  local stage    := $(substr $(stage), 1, $(length-var PATH_OBJ))
     3248  local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_OBJ))
     3249 else
     3250  $(error kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
     3251 endif
     3252endif
     3253
    32393254$(eval $(def_install_symlink_rule_staging))
    32403255$(target)_2_STAGE_TARGETS += $(stagedst)
    32413256
    3242 # Generate the install rule.
     3257# Calcuate the install destiation and generate the rule (if necessary).
    32433258ifeq ($(instmode),both)
     3259 local inst    := $(strip $(firstdefined $(symlnk)_INST $(target)_1_INST,value))
     3260 if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
     3261  $(warning kBuild: Symlink $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)')
     3262  local inst   := $(inst)/
     3263 endif
     3264 ifneq ($(root $(inst)),)
     3265  $(error kBuild: Symlink $(symlnk) in install target $(target) has a INST property with an absolute path: '$(inst)')
     3266 endif
     3267 local inst    := $(inst)$(dir $(srcdstdir))
     3268 local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
    32443269 $(eval $(def_install_symlink_rule_installing))
    32453270 $(target)_2_INST_TARGETS += $(instdst)
    32463271endif
    32473272
     3273#$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
    32483274endef # def_install_symlink
    32493275$(optmize def_install_symlink)
     
    32753301
    32763302# gather common properties.
    3277 ifdef $(directory)_INST
    3278  local inst := $($(directory)_INST)
    3279 else
    3280  local inst := $($(target)_1_INST)
    3281 endif
    3282 ifneq ($(substr $(inst),-1),/)
    3283  $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash.)
    3284  local inst := $(inst)/
    3285 endif
    3286 ifdef $(directory)_STAGE
    3287  local stage := $($(directory)_STAGE)
    3288 else ifdef $(directory)_INST
    3289  local stage := $($(directory)_INST)
    3290 else
    3291  local stage := $($(target)_1_STAGE)
    3292 endif
    3293 ifneq ($(substr $(stage),-1),/)
    3294  $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash.)
    3295  local stage := $(stage)/
    3296 endif
    3297 
    32983303local mode := $(firstword \
    32993304        $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
     
    33283333        $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
    33293334        $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
    3330  #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
    33313335
    33323336# The staging rule (requires double evaluation).
    3333 local insdst := $(PATH_STAGE)/$(stage)$(directory)/
     3337local stage    := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value))
     3338if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
     3339 $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
     3340 local stage   := $(stage)/
     3341endif
     3342ifeq ($(root $(stage)),)
     3343 local insdst  := $(PATH_STAGE)/$(stage)$(directory)/
     3344else
     3345 local stage   := $(abspath $(stage))
     3346 ifeq ($(pos $(PATH_OBJ),$(stage)),1)
     3347  local insdst := $(stage)$(directory)/
     3348 else
     3349  $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
     3350 endif
     3351endif
     3352
    33343353$(target)_2_STAGE_DIR_TARGETS += $(insdst)
    33353354$(eval $(def_install_directory_rule))
     
    33373356# The install rule.
    33383357ifeq ($(insttype),both)
     3358 local inst   := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value))
     3359 ifneq ($(substr $(inst),-1),/)
     3360  $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)')
     3361  local inst  := $(inst)/
     3362 endif
     3363 ifeq ($(root $(stage)),)
     3364  $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absoluate path: '$(inst)')
     3365 endif
    33393366 local insdst := $(PATH_INS)/$(inst)$(directory)/
    33403367 $(target)_2_INST_DIR_TARGETS += $(insdst)
     
    33423369endif
    33433370
     3371#$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
    33443372endef # def_install_directory
    33453373$(eval-opt-var def_install_directory)
Note: See TracChangeset for help on using the changeset viewer.