[72] | 1 | # $Id: footer-pass2-installs.kmk 2529 2011-08-02 10:07:51Z bird $
|
---|
| 2 | ## @file
|
---|
[2521] | 3 | # kBuild - Footer - Target lists - Pass 2 - Installs.
|
---|
[72] | 4 | #
|
---|
[1547] | 5 |
|
---|
| 6 | #
|
---|
[2521] | 7 | # Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
---|
[72] | 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
[106] | 13 | # the Free Software Foundation; either version source of the License, or
|
---|
[72] | 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
[353] | 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
[72] | 24 | #
|
---|
| 25 | #
|
---|
[1547] | 26 | # As a special exception you are granted permission to include this file, via
|
---|
[1599] | 27 | # the kmk include directive, as you wish without this in itself causing the
|
---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
---|
[1547] | 29 | # This exception does not however invalidate any other reasons why the makefile,
|
---|
| 30 | # program, whatever should not be covered the GPL.
|
---|
| 31 | #
|
---|
| 32 | #
|
---|
[72] | 33 |
|
---|
| 34 |
|
---|
| 35 | #
|
---|
[353] | 36 | # INSTALLS
|
---|
| 37 | #
|
---|
[72] | 38 |
|
---|
[2475] | 39 | ##
|
---|
| 40 | # Generate the staging rules.
|
---|
| 41 | #
|
---|
| 42 | define def_install_src_rule_staging
|
---|
| 43 | $(stagedst) : $(srcsrc) | $(dir $(stagedst))
|
---|
| 44 | %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst))
|
---|
| 45 | $$(QUIET)$(stagecmd)
|
---|
[353] | 46 | endef
|
---|
[2475] | 47 | $(eval-opt-var def_install_src_rule_staging)
|
---|
[353] | 48 |
|
---|
[2475] | 49 | define def_install_src_rule_installing
|
---|
| 50 | $(instdst) : $(srcsrc) | $(dir $(instdst))
|
---|
| 51 | %$$(call MSG_INST_FILE,$(srcsrc),$(instdst))
|
---|
| 52 | $$(QUIET)$(instcmd)
|
---|
| 53 | endef
|
---|
| 54 | $(eval-opt-var def_install_src_rule_installing)
|
---|
| 55 |
|
---|
| 56 | ##
|
---|
| 57 | # Install one file.
|
---|
| 58 | #
|
---|
[353] | 59 | define def_install_src
|
---|
| 60 |
|
---|
| 61 | # deal with '=>' in the source file name.
|
---|
[2220] | 62 | ifeq ($(src),=>)
|
---|
| 63 | $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names)
|
---|
| 64 | endif
|
---|
| 65 | ifeq ($(substr $(src),1,2),=>)
|
---|
| 66 | $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
|
---|
| 67 | endif
|
---|
| 68 | ifeq ($(substr $(src),-2),=>)
|
---|
| 69 | $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
|
---|
| 70 | endif
|
---|
[2475] | 71 | local srcdst := $(subst =>, ,$(src))
|
---|
| 72 | local srcsrc := $(firstword $(srcdst))
|
---|
[1496] | 73 | local srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[2475] | 74 | local srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
[353] | 75 |
|
---|
[2518] | 76 | # instfun, mode, uid and gid.
|
---|
[353] | 77 | ifdef $(srcsrc)_INSTFUN
|
---|
[1496] | 78 | local instfun := $(srcsrc)_INSTFUN
|
---|
[353] | 79 | else
|
---|
[2475] | 80 | local instfun := $(top_instfun)
|
---|
[353] | 81 | endif
|
---|
[1496] | 82 | local mode := $(firstword \
|
---|
[2483] | 83 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 84 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
| 85 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE) \
|
---|
| 86 | $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 87 | $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
| 88 | $($(target)_$(srcdst)$(source_type_prefix)_MODE) \
|
---|
| 89 | $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 90 | $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
| 91 | $($(srcsrc)$(source_type_prefix)_MODE) \
|
---|
| 92 | $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 93 | $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
| 94 | $($(srcdst)$(source_type_prefix)_MODE) \
|
---|
| 95 | $(source_type_mode))
|
---|
[1496] | 96 | local uid := $(firstword \
|
---|
[481] | 97 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 98 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 99 | $($(target)_$(srcsrc)_UID) \
|
---|
[481] | 100 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 101 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 102 | $($(target)_$(srcdst)_UID) \
|
---|
[481] | 103 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 104 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 105 | $($(srcsrc)_UID) \
|
---|
[481] | 106 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 107 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 108 | $($(srcdst)_UID) \
|
---|
[2475] | 109 | $(top_uid))
|
---|
[1496] | 110 | local gid := $(firstword \
|
---|
[481] | 111 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 112 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 113 | $($(target)_$(srcsrc)_GID) \
|
---|
[481] | 114 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 115 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 116 | $($(target)_$(srcdst)_GID) \
|
---|
[481] | 117 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 118 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 119 | $($(srcsrc)_GID) \
|
---|
[481] | 120 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 121 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 122 | $($(srcdst)_GID) \
|
---|
[2475] | 123 | $(top_gid))
|
---|
[1496] | 124 | local flags := \
|
---|
[2475] | 125 | $(top_ifflags) \
|
---|
[2483] | 126 | $($(srcdst)$(source_type_prefix)_IFFLAGS) \
|
---|
| 127 | $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
| 128 | $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 129 | $($(srcsrc)$(source_type_prefix)_IFFLAGS) \
|
---|
| 130 | $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
| 131 | $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 132 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS) \
|
---|
| 133 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
| 134 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 135 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS) \
|
---|
| 136 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
| 137 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[1614] | 138 | clean_files += \
|
---|
| 139 | $($(srcdst)_CLEAN) \
|
---|
| 140 | $($(srcdst)_CLEAN.$(bld_trg)) \
|
---|
| 141 | $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 142 | $($(srcsrc)_CLEAN) \
|
---|
| 143 | $($(srcsrc)_CLEAN.$(bld_trg)) \
|
---|
| 144 | $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 145 | $($(target)_$(srcdst)_CLEAN) \
|
---|
| 146 | $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \
|
---|
| 147 | $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 148 | $($(target)_$(srcsrc)_CLEAN) \
|
---|
| 149 | $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \
|
---|
| 150 | $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch))
|
---|
[414] | 151 |
|
---|
[725] | 152 |
|
---|
| 153 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
[2477] | 154 | ifdef $(target)_DEFPATH
|
---|
| 155 | local defpath := $($(target)_DEFPATH)
|
---|
| 156 | else ifdef $(target)_PATH
|
---|
| 157 | local defpath := $($(target)_PATH)
|
---|
| 158 | else
|
---|
| 159 | local defpath :=
|
---|
| 160 | endif
|
---|
[1755] | 161 | ifneq ($(defpath),)
|
---|
| 162 | local srcsrc := $(abspathex $(srcsrc),$(defpath))
|
---|
[725] | 163 | endif
|
---|
| 164 |
|
---|
[2479] | 165 | # Generate the staging rule (requires double evaluation).
|
---|
[2517] | 166 | local stage := $(strip $(firstdefined $(srcsrc)_STAGE $(srcsrc)_INST $(target)_1_STAGE,value))
|
---|
| 167 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 168 | $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 169 | local stage := $(stage)/
|
---|
| 170 | endif
|
---|
| 171 | local stage := $(stage)$(dir $(srcdstdir))
|
---|
| 172 | ifeq ($(root $(stage)),)
|
---|
| 173 | local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE))
|
---|
| 174 | else
|
---|
[2518] | 175 | local stage := $(abspath $(stage))/
|
---|
[2517] | 176 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
[2518] | 177 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
[2517] | 178 | local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_OBJ))
|
---|
| 179 | else
|
---|
| 180 | $(error kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 181 | endif
|
---|
| 182 | endif
|
---|
[353] | 183 | ifdef $(srcsrc)_INSTALLER
|
---|
[2479] | 184 | local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
[830] | 185 | else ifdef $(target)_INSTALLER
|
---|
[2479] | 186 | local stagecmd := $(call $(target)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
[353] | 187 | else
|
---|
[2479] | 188 | local stagecmd := $$(INSTALL_STAGING)\
|
---|
[414] | 189 | $(if $(uid),-o $(uid))\
|
---|
| 190 | $(if $(gid),-g $(gid))\
|
---|
| 191 | $(if $(mode),-m $(mode))\
|
---|
[1599] | 192 | $(flags) -- \
|
---|
[2475] | 193 | $(srcsrc) $(stagedst)
|
---|
[353] | 194 | endif
|
---|
[2475] | 195 | $(eval $(def_install_src_rule_staging))
|
---|
| 196 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
[353] | 197 |
|
---|
[2475] | 198 | # Generate the install rule
|
---|
| 199 | ifeq ($(insttype),both)
|
---|
[2517] | 200 | local inst := $(strip $(firstdefined $(srcsrc)_INST $(target)_1_INST,value))
|
---|
| 201 | if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
|
---|
| 202 | $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 203 | local inst := $(inst)/
|
---|
| 204 | endif
|
---|
| 205 | local inst := $(inst)$(dir $(srcdstdir))
|
---|
| 206 | ifneq ($(root $(inst)),)
|
---|
| 207 | $(error kBuild: File $(srcsrc) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
| 208 | endif
|
---|
| 209 | local instdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
| 210 |
|
---|
[2479] | 211 | ifdef $(srcsrc)_INSTALLER
|
---|
[2517] | 212 | local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
[2479] | 213 | else ifdef $(target)_INSTALLER
|
---|
[2517] | 214 | local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
[2479] | 215 | else
|
---|
| 216 | local instcmd := $$(INSTALL)\
|
---|
| 217 | $(if $(uid),-o $(uid))\
|
---|
| 218 | $(if $(gid),-g $(gid))\
|
---|
| 219 | $(if $(mode),-m $(mode))\
|
---|
| 220 | $(flags) -- \
|
---|
| 221 | $(srcsrc) $(instdst)
|
---|
| 222 | endif
|
---|
[2475] | 223 | $(eval $(def_install_src_rule_installing))
|
---|
| 224 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
| 225 | endif
|
---|
| 226 |
|
---|
[2517] | 227 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
|
---|
[1936] | 228 | endef # def_install_src
|
---|
| 229 | $(eval-opt-var def_install_src)
|
---|
[353] | 230 |
|
---|
| 231 |
|
---|
[2475] | 232 | ##
|
---|
| 233 | # Generate the symlink rules.
|
---|
| 234 | #
|
---|
| 235 | define def_install_symlink_rule_staging
|
---|
| 236 | $(stagedst) : | $(dir $(stagedst))
|
---|
| 237 | %$$(call MSG_INST_SYM,$(stagedst),$(symdst))
|
---|
[1599] | 238 | $$(QUIET)$$(RM) -f -- $$@
|
---|
[2475] | 239 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst)
|
---|
| 240 | endef
|
---|
| 241 | $(eval-opt-var def_install_symlink_rule_staging)
|
---|
[353] | 242 |
|
---|
[2475] | 243 | define def_install_symlink_rule_installing
|
---|
| 244 | $(instdst) : | $(dir $(instdst))
|
---|
| 245 | %$$(call MSG_INST_SYM,$(instdst),$(symdst))
|
---|
| 246 | $$(QUIET)$$(RM) -f -- $$@
|
---|
| 247 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst)
|
---|
| 248 | endef
|
---|
| 249 | $(eval-opt-var def_install_symlink_rule_installing)
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | ##
|
---|
| 253 | # Create one symlink.
|
---|
| 254 | #
|
---|
[353] | 255 | define def_install_symlink
|
---|
| 256 |
|
---|
| 257 | # deal with '=>' in the source file name.
|
---|
[1496] | 258 | local symdst := $(subst =>, ,$(src))
|
---|
| 259 | local symlnk := $(firstword $(symdst))
|
---|
| 260 | local symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[2529] | 261 | local symlnkdir := $(dir $(symlnk))
|
---|
| 262 | ifeq ($(symlnkdir),./)
|
---|
| 263 | local symlnkdir :=
|
---|
| 264 | endif
|
---|
[353] | 265 |
|
---|
[2517] | 266 | # Figure which install function to use below.
|
---|
[380] | 267 | ifdef $(symlnk)_INSTFUN
|
---|
[1496] | 268 | local instfun := $(symlnk)_INSTFUN
|
---|
[353] | 269 | else
|
---|
[2475] | 270 | local instfun := $(top_instfun)
|
---|
[353] | 271 | endif
|
---|
| 272 |
|
---|
[2517] | 273 | # Calc stage destination and generate the rule (requires double evaluation).
|
---|
| 274 | local stage := $(strip $(firstdefined $(symlnk)_STAGE $(symlnk)_INST $(target)_1_STAGE,value))
|
---|
[2529] | 275 | $(info stage:=$(stage))
|
---|
[2517] | 276 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 277 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 278 | local stage := $(stage)/
|
---|
[353] | 279 | endif
|
---|
[2529] | 280 | local stage := $(stage)$(symlnkdir)
|
---|
[2517] | 281 | ifeq ($(root $(stage)),)
|
---|
| 282 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
|
---|
| 283 | else
|
---|
[2518] | 284 | local stage := $(abspath $(stage))/
|
---|
[2517] | 285 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
[2518] | 286 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
[2517] | 287 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_OBJ))
|
---|
| 288 | else
|
---|
| 289 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 290 | endif
|
---|
[2475] | 291 | endif
|
---|
[353] | 292 |
|
---|
[2475] | 293 | $(eval $(def_install_symlink_rule_staging))
|
---|
| 294 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
[353] | 295 |
|
---|
[2517] | 296 | # Calcuate the install destiation and generate the rule (if necessary).
|
---|
[2475] | 297 | ifeq ($(instmode),both)
|
---|
[2517] | 298 | local inst := $(strip $(firstdefined $(symlnk)_INST $(target)_1_INST,value))
|
---|
| 299 | if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
|
---|
| 300 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 301 | local inst := $(inst)/
|
---|
| 302 | endif
|
---|
| 303 | ifneq ($(root $(inst)),)
|
---|
| 304 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
| 305 | endif
|
---|
[2529] | 306 | local inst := $(inst)$(symlnkdir)
|
---|
[2517] | 307 | local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
[2475] | 308 | $(eval $(def_install_symlink_rule_installing))
|
---|
| 309 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
| 310 | endif
|
---|
| 311 |
|
---|
[2529] | 312 | $(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
|
---|
[1936] | 313 | endef # def_install_symlink
|
---|
| 314 | $(optmize def_install_symlink)
|
---|
[353] | 315 |
|
---|
[412] | 316 |
|
---|
[2475] | 317 | ##
|
---|
| 318 | # Generate an directory installtion rule.
|
---|
| 319 | # Note. Used both for staging and real install rules.
|
---|
| 320 | #
|
---|
[380] | 321 | define def_install_directory_rule
|
---|
| 322 | # the install rule
|
---|
| 323 | $(insdst):
|
---|
[1496] | 324 | %$$(call MSG_INST_DIR,$(insdst))
|
---|
[696] | 325 | $$(QUIET)$$(INSTALL) -d \
|
---|
[380] | 326 | $(if $(uid),-o $(uid))\
|
---|
| 327 | $(if $(gid),-g $(gid))\
|
---|
| 328 | $(if $(mode),-m $(mode))\
|
---|
[1599] | 329 | $(flags) -- \
|
---|
[380] | 330 | $(insdst)
|
---|
[412] | 331 |
|
---|
| 332 | .NOTPARALLEL: $(insdst)
|
---|
[1936] | 333 | endef # def_install_directory_rule
|
---|
| 334 | $(eval-opt-var def_install_directory_rule)
|
---|
[380] | 335 |
|
---|
[2475] | 336 | ##
|
---|
| 337 | # Create one directory.
|
---|
| 338 | #
|
---|
[380] | 339 | define def_install_directory
|
---|
| 340 |
|
---|
[2475] | 341 | # gather common properties.
|
---|
[1496] | 342 | local mode := $(firstword \
|
---|
[481] | 343 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 344 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 345 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 346 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 347 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 348 | $($(directory)_MODE) \
|
---|
[2475] | 349 | $(top_mode) )
|
---|
[1496] | 350 | local uid := $(firstword \
|
---|
[481] | 351 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 352 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 353 | $($(target)_$(directory)_UID) \
|
---|
[481] | 354 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 355 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 356 | $($(directory)_UID) \
|
---|
[2475] | 357 | $(top_uid) )
|
---|
[1496] | 358 | local gid := $(firstword \
|
---|
[481] | 359 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 360 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 361 | $($(target)_$(directory)_GID) \
|
---|
[481] | 362 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 363 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 364 | $($(directory)_GID) \
|
---|
[2475] | 365 | $(top_gid) )
|
---|
[1496] | 366 | local flags := \
|
---|
[2475] | 367 | $(top_idflags) \
|
---|
[830] | 368 | $($(directory)_IDFLAGS) \
|
---|
| 369 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 370 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 371 | $($(target)_$(directory)_IDFLAGS) \
|
---|
| 372 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
[2475] | 373 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 374 |
|
---|
[2475] | 375 | # The staging rule (requires double evaluation).
|
---|
[2517] | 376 | local stage := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value))
|
---|
| 377 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 378 | $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 379 | local stage := $(stage)/
|
---|
| 380 | endif
|
---|
| 381 | ifeq ($(root $(stage)),)
|
---|
| 382 | local insdst := $(PATH_STAGE)/$(stage)$(directory)/
|
---|
| 383 | else
|
---|
[2518] | 384 | local stage := $(abspath $(stage))/
|
---|
[2517] | 385 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
| 386 | local insdst := $(stage)$(directory)/
|
---|
| 387 | else
|
---|
| 388 | $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 389 | endif
|
---|
| 390 | endif
|
---|
| 391 |
|
---|
[2475] | 392 | $(target)_2_STAGE_DIR_TARGETS += $(insdst)
|
---|
[380] | 393 | $(eval $(def_install_directory_rule))
|
---|
| 394 |
|
---|
[2475] | 395 | # The install rule.
|
---|
| 396 | ifeq ($(insttype),both)
|
---|
[2517] | 397 | local inst := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value))
|
---|
| 398 | ifneq ($(substr $(inst),-1),/)
|
---|
| 399 | $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 400 | local inst := $(inst)/
|
---|
| 401 | endif
|
---|
[2519] | 402 | ifneq ($(root $(stage)),)
|
---|
| 403 | $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
[2517] | 404 | endif
|
---|
[2514] | 405 | local insdst := $(PATH_INS)/$(inst)$(directory)/
|
---|
[2475] | 406 | $(target)_2_INST_DIR_TARGETS += $(insdst)
|
---|
| 407 | $(eval $(def_install_directory_rule))
|
---|
| 408 | endif
|
---|
| 409 |
|
---|
[2517] | 410 | #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
[1936] | 411 | endef # def_install_directory
|
---|
| 412 | $(eval-opt-var def_install_directory)
|
---|
[380] | 413 |
|
---|
| 414 |
|
---|
[2475] | 415 | ##
|
---|
| 416 | # Process one install target.
|
---|
| 417 | #
|
---|
[353] | 418 | define def_install
|
---|
[744] | 419 | # the basics.
|
---|
[2475] | 420 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
| 421 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
| 422 | local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
| 423 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
| 424 | local insttype := $($(target)_1_INSTTYPE)
|
---|
[353] | 425 |
|
---|
[2475] | 426 | ifneq ($(insttype),none)
|
---|
| 427 | $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS)
|
---|
| 428 | else
|
---|
| 429 | $(target)_2_STAGE_TARGETS :=
|
---|
| 430 | endif
|
---|
| 431 | $(target)_2_STAGE_DIR_TARGETS :=
|
---|
| 432 |
|
---|
| 433 | ifeq ($(insttype),both)
|
---|
| 434 | $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS)
|
---|
| 435 | else
|
---|
| 436 | $(target)_2_INST_TARGETS :=
|
---|
| 437 | endif
|
---|
| 438 | $(target)_2_INST_DIR_TARGETS :=
|
---|
| 439 |
|
---|
| 440 |
|
---|
| 441 | local outbase := $(call TARGET_BASE,$(target),$(target))
|
---|
[2239] | 442 | $(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
|
---|
[2436] | 443 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
[380] | 444 |
|
---|
[2475] | 445 | ifneq ($(insttype),none)
|
---|
| 446 | # cache top level target properties.
|
---|
| 447 | local top_mode := $(firstword \
|
---|
| 448 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 449 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 450 | $($(target)_MODE) )
|
---|
[2483] | 451 | local top_exec_mode := $(firstword \
|
---|
| 452 | $($(target)_EXEC_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 453 | $($(target)_EXEC_MODE.$(bld_trg)) \
|
---|
| 454 | $($(target)_EXEC_MODE) )
|
---|
[2475] | 455 | local top_uid := $(firstword \
|
---|
| 456 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 457 | $($(target)_UID.$(bld_trg)) \
|
---|
| 458 | $($(target)_UID) )
|
---|
| 459 | local top_gid := $(firstword \
|
---|
| 460 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 461 | $($(target)_GID.$(bld_trg)) \
|
---|
| 462 | $($(target)_GID) )
|
---|
| 463 | local top_ifflags := \
|
---|
| 464 | $($(target)_IFFLAGS) \
|
---|
| 465 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
[2477] | 466 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[2475] | 467 | local top_idflags := \
|
---|
| 468 | $($(target)_IDFLAGS) \
|
---|
| 469 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
| 470 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
| 471 | ifdef $(target)_INSTFUN
|
---|
| 472 | local top_instfun := $(target)_INSTFUN
|
---|
| 473 | else
|
---|
| 474 | local top_instfun := _INSTALL_FILE
|
---|
| 475 | endif
|
---|
[1614] | 476 |
|
---|
[2475] | 477 | $(foreach directory, \
|
---|
| 478 | $($(target)_DIRS) \
|
---|
| 479 | $($(target)_DIRS.$(bld_trg)) \
|
---|
| 480 | $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 481 | $($(target)_DIRS.$(bld_trg_arch)) \
|
---|
| 482 | $($(target)_DIRS.$(bld_trg_cpu)) \
|
---|
| 483 | $($(target)_DIRS.$(bld_type)), \
|
---|
| 484 | $(evalval def_install_directory))
|
---|
[380] | 485 |
|
---|
[2475] | 486 | local clean_files := \
|
---|
| 487 | $($(target)_CLEAN) \
|
---|
| 488 | $($(target)_CLEAN.$(bld_trg)) \
|
---|
| 489 | $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 490 | $($(target)_CLEAN.$(bld_trg_arch)) \
|
---|
| 491 | $($(target)_CLEAN.$(bld_trg_cpu)) \
|
---|
| 492 | $($(target)_CLEAN.$(bld_type))
|
---|
[353] | 493 |
|
---|
[2483] | 494 | local source_type_prefix :=
|
---|
| 495 | local source_type_mode := $(firstword $(top_mode) a+r,u+w)
|
---|
[2475] | 496 | $(foreach src,\
|
---|
| 497 | $($(target)_SOURCES) \
|
---|
| 498 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 499 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 500 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 501 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 502 | $($(target)_SOURCES.$(bld_type)), \
|
---|
| 503 | $(evalval def_install_src))
|
---|
[353] | 504 |
|
---|
[2483] | 505 | local source_type_prefix := EXEC_
|
---|
| 506 | local source_type_mode := $(firstword $(top_exec_mode) a+xr,u+w)
|
---|
[2475] | 507 | $(foreach src,\
|
---|
[2483] | 508 | $($(target)_EXEC_SOURCES) \
|
---|
| 509 | $($(target)_EXEC_SOURCES.$(bld_trg)) \
|
---|
| 510 | $($(target)_EXEC_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 511 | $($(target)_EXEC_SOURCES.$(bld_trg_arch)) \
|
---|
| 512 | $($(target)_EXEC_SOURCES.$(bld_trg_cpu)) \
|
---|
| 513 | $($(target)_EXEC_SOURCES.$(bld_type)), \
|
---|
| 514 | $(evalval def_install_src))
|
---|
| 515 |
|
---|
| 516 | $(foreach src,\
|
---|
[2475] | 517 | $($(target)_SYMLINKS) \
|
---|
| 518 | $($(target)_SYMLINKS.$(bld_trg)) \
|
---|
| 519 | $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 520 | $($(target)_SYMLINKS.$(bld_trg_arch)) \
|
---|
| 521 | $($(target)_SYMLINKS.$(bld_trg_cpu)) \
|
---|
| 522 | $($(target)_SYMLINKS.$(bld_type)), \
|
---|
| 523 | $(evalval def_install_symlink))
|
---|
| 524 | else # none
|
---|
| 525 | local clean_files :=
|
---|
| 526 | endif
|
---|
| 527 |
|
---|
| 528 | # The collection targets (staging only).
|
---|
| 529 | local clean_files += $($(target)_1_TARGET)
|
---|
| 530 | $($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@)
|
---|
[827] | 531 | @$(QUIET2)$(APPEND) $@
|
---|
| 532 |
|
---|
[2238] | 533 | $(target): $$($(target)_1_TARGET)
|
---|
[827] | 534 |
|
---|
[2475] | 535 | # Update Global lists.
|
---|
| 536 | _INSTALLS += $($(target)_1_TARGET)
|
---|
| 537 | _STAGE_FILES += $($(target)_2_STAGE_TARGETS)
|
---|
| 538 | _STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 539 | _INSTALLS_FILES += $($(target)_2_INST_TARGETS)
|
---|
| 540 | _INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS)
|
---|
| 541 | _CLEAN_FILES += $(clean_files)
|
---|
| 542 | _DIRS += \
|
---|
| 543 | $($(target)_0_OUTDIR) \
|
---|
| 544 | $($(target)_BLDDIRS) \
|
---|
| 545 | $($(target)_BLDDIRS.$(bld_trg)) \
|
---|
| 546 | $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 547 | $($(target)_BLDDIRS.$(bld_trg_arch)) \
|
---|
| 548 | $($(target)_BLDDIRS.$(bld_trg_cpu)) \
|
---|
| 549 | $($(target)_BLDDIRS.$(bld_type))
|
---|
| 550 |
|
---|
| 551 | # Deprecated properties.
|
---|
| 552 | INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS)
|
---|
| 553 | INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 554 |
|
---|
[1936] | 555 | endef # def_install
|
---|
| 556 | $(eval-opt-var def_install)
|
---|
[353] | 557 |
|
---|
[2479] | 558 | ## Do pass 1 on the implicit targets and add them to the list.
|
---|
| 559 | $(foreach target, $(_ALL_INSTALLS_IMPLICIT), \
|
---|
| 560 | $(evalval def_pass1_install))
|
---|
| 561 | _ALL_INSTALLS += $(_ALL_INSTALLS_IMPLICIT)
|
---|
| 562 |
|
---|
| 563 | ## Do pass 2 on all install targets.
|
---|
[1648] | 564 | $(foreach target, $(_ALL_INSTALLS), \
|
---|
[1614] | 565 | $(evalvalctx def_install))
|
---|
[353] | 566 |
|
---|
[988] | 567 | ifdef KBUILD_PROFILE_SELF
|
---|
[2008] | 568 | $(evalcall def_profile_self, done install targets)
|
---|
[988] | 569 | endif
|
---|
[353] | 570 |
|
---|
[2475] | 571 | #
|
---|
[2227] | 572 | # Some introspection targets that can be useful for package maintainers.
|
---|
[2475] | 573 | #
|
---|
[2227] | 574 | .PHONY: kbuild-show-install-files kbuild-show-install-dirs
|
---|
| 575 | kbuild-show-install-files::
|
---|
| 576 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES)))
|
---|
| 577 |
|
---|
| 578 | kbuild-show-install-dirs::
|
---|
| 579 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS)))
|
---|
| 580 |
|
---|
[2475] | 581 | kbuild-show-stage-files::
|
---|
| 582 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES)))
|
---|
[2227] | 583 |
|
---|
[2475] | 584 | kbuild-show-stage-dirs::
|
---|
| 585 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS)))
|
---|
| 586 |
|
---|
| 587 |
|
---|