[72] | 1 | # $Id: footer-pass2-installs.kmk 2530 2011-08-02 10:57:48Z 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))
|
---|
| 275 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 276 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 277 | local stage := $(stage)/
|
---|
[353] | 278 | endif
|
---|
[2529] | 279 | local stage := $(stage)$(symlnkdir)
|
---|
[2517] | 280 | ifeq ($(root $(stage)),)
|
---|
| 281 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
|
---|
| 282 | else
|
---|
[2518] | 283 | local stage := $(abspath $(stage))/
|
---|
[2517] | 284 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
[2518] | 285 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
[2517] | 286 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_OBJ))
|
---|
| 287 | else
|
---|
| 288 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 289 | endif
|
---|
[2475] | 290 | endif
|
---|
[353] | 291 |
|
---|
[2475] | 292 | $(eval $(def_install_symlink_rule_staging))
|
---|
| 293 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
[353] | 294 |
|
---|
[2517] | 295 | # Calcuate the install destiation and generate the rule (if necessary).
|
---|
[2475] | 296 | ifeq ($(instmode),both)
|
---|
[2517] | 297 | local inst := $(strip $(firstdefined $(symlnk)_INST $(target)_1_INST,value))
|
---|
| 298 | if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
|
---|
| 299 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 300 | local inst := $(inst)/
|
---|
| 301 | endif
|
---|
| 302 | ifneq ($(root $(inst)),)
|
---|
| 303 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
| 304 | endif
|
---|
[2529] | 305 | local inst := $(inst)$(symlnkdir)
|
---|
[2517] | 306 | local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
[2475] | 307 | $(eval $(def_install_symlink_rule_installing))
|
---|
| 308 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
| 309 | endif
|
---|
| 310 |
|
---|
[2530] | 311 | #$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
|
---|
[1936] | 312 | endef # def_install_symlink
|
---|
| 313 | $(optmize def_install_symlink)
|
---|
[353] | 314 |
|
---|
[412] | 315 |
|
---|
[2475] | 316 | ##
|
---|
| 317 | # Generate an directory installtion rule.
|
---|
| 318 | # Note. Used both for staging and real install rules.
|
---|
| 319 | #
|
---|
[380] | 320 | define def_install_directory_rule
|
---|
| 321 | # the install rule
|
---|
| 322 | $(insdst):
|
---|
[1496] | 323 | %$$(call MSG_INST_DIR,$(insdst))
|
---|
[696] | 324 | $$(QUIET)$$(INSTALL) -d \
|
---|
[380] | 325 | $(if $(uid),-o $(uid))\
|
---|
| 326 | $(if $(gid),-g $(gid))\
|
---|
| 327 | $(if $(mode),-m $(mode))\
|
---|
[1599] | 328 | $(flags) -- \
|
---|
[380] | 329 | $(insdst)
|
---|
[412] | 330 |
|
---|
| 331 | .NOTPARALLEL: $(insdst)
|
---|
[1936] | 332 | endef # def_install_directory_rule
|
---|
| 333 | $(eval-opt-var def_install_directory_rule)
|
---|
[380] | 334 |
|
---|
[2475] | 335 | ##
|
---|
| 336 | # Create one directory.
|
---|
| 337 | #
|
---|
[380] | 338 | define def_install_directory
|
---|
| 339 |
|
---|
[2475] | 340 | # gather common properties.
|
---|
[1496] | 341 | local mode := $(firstword \
|
---|
[481] | 342 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 343 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 344 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 345 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 346 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 347 | $($(directory)_MODE) \
|
---|
[2475] | 348 | $(top_mode) )
|
---|
[1496] | 349 | local uid := $(firstword \
|
---|
[481] | 350 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 351 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 352 | $($(target)_$(directory)_UID) \
|
---|
[481] | 353 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 354 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 355 | $($(directory)_UID) \
|
---|
[2475] | 356 | $(top_uid) )
|
---|
[1496] | 357 | local gid := $(firstword \
|
---|
[481] | 358 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 359 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 360 | $($(target)_$(directory)_GID) \
|
---|
[481] | 361 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 362 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 363 | $($(directory)_GID) \
|
---|
[2475] | 364 | $(top_gid) )
|
---|
[1496] | 365 | local flags := \
|
---|
[2475] | 366 | $(top_idflags) \
|
---|
[830] | 367 | $($(directory)_IDFLAGS) \
|
---|
| 368 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 369 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 370 | $($(target)_$(directory)_IDFLAGS) \
|
---|
| 371 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
[2475] | 372 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 373 |
|
---|
[2475] | 374 | # The staging rule (requires double evaluation).
|
---|
[2517] | 375 | local stage := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value))
|
---|
| 376 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 377 | $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 378 | local stage := $(stage)/
|
---|
| 379 | endif
|
---|
| 380 | ifeq ($(root $(stage)),)
|
---|
| 381 | local insdst := $(PATH_STAGE)/$(stage)$(directory)/
|
---|
| 382 | else
|
---|
[2518] | 383 | local stage := $(abspath $(stage))/
|
---|
[2517] | 384 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
| 385 | local insdst := $(stage)$(directory)/
|
---|
| 386 | else
|
---|
| 387 | $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 388 | endif
|
---|
| 389 | endif
|
---|
| 390 |
|
---|
[2475] | 391 | $(target)_2_STAGE_DIR_TARGETS += $(insdst)
|
---|
[380] | 392 | $(eval $(def_install_directory_rule))
|
---|
| 393 |
|
---|
[2475] | 394 | # The install rule.
|
---|
| 395 | ifeq ($(insttype),both)
|
---|
[2517] | 396 | local inst := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value))
|
---|
| 397 | ifneq ($(substr $(inst),-1),/)
|
---|
| 398 | $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 399 | local inst := $(inst)/
|
---|
| 400 | endif
|
---|
[2519] | 401 | ifneq ($(root $(stage)),)
|
---|
| 402 | $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
[2517] | 403 | endif
|
---|
[2514] | 404 | local insdst := $(PATH_INS)/$(inst)$(directory)/
|
---|
[2475] | 405 | $(target)_2_INST_DIR_TARGETS += $(insdst)
|
---|
| 406 | $(eval $(def_install_directory_rule))
|
---|
| 407 | endif
|
---|
| 408 |
|
---|
[2517] | 409 | #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
[1936] | 410 | endef # def_install_directory
|
---|
| 411 | $(eval-opt-var def_install_directory)
|
---|
[380] | 412 |
|
---|
| 413 |
|
---|
[2475] | 414 | ##
|
---|
| 415 | # Process one install target.
|
---|
| 416 | #
|
---|
[353] | 417 | define def_install
|
---|
[744] | 418 | # the basics.
|
---|
[2475] | 419 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
| 420 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
| 421 | local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
| 422 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
| 423 | local insttype := $($(target)_1_INSTTYPE)
|
---|
[353] | 424 |
|
---|
[2475] | 425 | ifneq ($(insttype),none)
|
---|
| 426 | $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS)
|
---|
| 427 | else
|
---|
| 428 | $(target)_2_STAGE_TARGETS :=
|
---|
| 429 | endif
|
---|
| 430 | $(target)_2_STAGE_DIR_TARGETS :=
|
---|
| 431 |
|
---|
| 432 | ifeq ($(insttype),both)
|
---|
| 433 | $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS)
|
---|
| 434 | else
|
---|
| 435 | $(target)_2_INST_TARGETS :=
|
---|
| 436 | endif
|
---|
| 437 | $(target)_2_INST_DIR_TARGETS :=
|
---|
| 438 |
|
---|
| 439 |
|
---|
| 440 | local outbase := $(call TARGET_BASE,$(target),$(target))
|
---|
[2239] | 441 | $(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
|
---|
[2436] | 442 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
[380] | 443 |
|
---|
[2475] | 444 | ifneq ($(insttype),none)
|
---|
| 445 | # cache top level target properties.
|
---|
| 446 | local top_mode := $(firstword \
|
---|
| 447 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 448 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 449 | $($(target)_MODE) )
|
---|
[2483] | 450 | local top_exec_mode := $(firstword \
|
---|
| 451 | $($(target)_EXEC_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 452 | $($(target)_EXEC_MODE.$(bld_trg)) \
|
---|
| 453 | $($(target)_EXEC_MODE) )
|
---|
[2475] | 454 | local top_uid := $(firstword \
|
---|
| 455 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 456 | $($(target)_UID.$(bld_trg)) \
|
---|
| 457 | $($(target)_UID) )
|
---|
| 458 | local top_gid := $(firstword \
|
---|
| 459 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 460 | $($(target)_GID.$(bld_trg)) \
|
---|
| 461 | $($(target)_GID) )
|
---|
| 462 | local top_ifflags := \
|
---|
| 463 | $($(target)_IFFLAGS) \
|
---|
| 464 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
[2477] | 465 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[2475] | 466 | local top_idflags := \
|
---|
| 467 | $($(target)_IDFLAGS) \
|
---|
| 468 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
| 469 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
| 470 | ifdef $(target)_INSTFUN
|
---|
| 471 | local top_instfun := $(target)_INSTFUN
|
---|
| 472 | else
|
---|
| 473 | local top_instfun := _INSTALL_FILE
|
---|
| 474 | endif
|
---|
[1614] | 475 |
|
---|
[2475] | 476 | $(foreach directory, \
|
---|
| 477 | $($(target)_DIRS) \
|
---|
| 478 | $($(target)_DIRS.$(bld_trg)) \
|
---|
| 479 | $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 480 | $($(target)_DIRS.$(bld_trg_arch)) \
|
---|
| 481 | $($(target)_DIRS.$(bld_trg_cpu)) \
|
---|
| 482 | $($(target)_DIRS.$(bld_type)), \
|
---|
| 483 | $(evalval def_install_directory))
|
---|
[380] | 484 |
|
---|
[2475] | 485 | local clean_files := \
|
---|
| 486 | $($(target)_CLEAN) \
|
---|
| 487 | $($(target)_CLEAN.$(bld_trg)) \
|
---|
| 488 | $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 489 | $($(target)_CLEAN.$(bld_trg_arch)) \
|
---|
| 490 | $($(target)_CLEAN.$(bld_trg_cpu)) \
|
---|
| 491 | $($(target)_CLEAN.$(bld_type))
|
---|
[353] | 492 |
|
---|
[2483] | 493 | local source_type_prefix :=
|
---|
| 494 | local source_type_mode := $(firstword $(top_mode) a+r,u+w)
|
---|
[2475] | 495 | $(foreach src,\
|
---|
| 496 | $($(target)_SOURCES) \
|
---|
| 497 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 498 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 499 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 500 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 501 | $($(target)_SOURCES.$(bld_type)), \
|
---|
| 502 | $(evalval def_install_src))
|
---|
[353] | 503 |
|
---|
[2483] | 504 | local source_type_prefix := EXEC_
|
---|
| 505 | local source_type_mode := $(firstword $(top_exec_mode) a+xr,u+w)
|
---|
[2475] | 506 | $(foreach src,\
|
---|
[2483] | 507 | $($(target)_EXEC_SOURCES) \
|
---|
| 508 | $($(target)_EXEC_SOURCES.$(bld_trg)) \
|
---|
| 509 | $($(target)_EXEC_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 510 | $($(target)_EXEC_SOURCES.$(bld_trg_arch)) \
|
---|
| 511 | $($(target)_EXEC_SOURCES.$(bld_trg_cpu)) \
|
---|
| 512 | $($(target)_EXEC_SOURCES.$(bld_type)), \
|
---|
| 513 | $(evalval def_install_src))
|
---|
| 514 |
|
---|
| 515 | $(foreach src,\
|
---|
[2475] | 516 | $($(target)_SYMLINKS) \
|
---|
| 517 | $($(target)_SYMLINKS.$(bld_trg)) \
|
---|
| 518 | $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 519 | $($(target)_SYMLINKS.$(bld_trg_arch)) \
|
---|
| 520 | $($(target)_SYMLINKS.$(bld_trg_cpu)) \
|
---|
| 521 | $($(target)_SYMLINKS.$(bld_type)), \
|
---|
| 522 | $(evalval def_install_symlink))
|
---|
| 523 | else # none
|
---|
| 524 | local clean_files :=
|
---|
| 525 | endif
|
---|
| 526 |
|
---|
| 527 | # The collection targets (staging only).
|
---|
| 528 | local clean_files += $($(target)_1_TARGET)
|
---|
| 529 | $($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@)
|
---|
[827] | 530 | @$(QUIET2)$(APPEND) $@
|
---|
| 531 |
|
---|
[2238] | 532 | $(target): $$($(target)_1_TARGET)
|
---|
[827] | 533 |
|
---|
[2475] | 534 | # Update Global lists.
|
---|
| 535 | _INSTALLS += $($(target)_1_TARGET)
|
---|
| 536 | _STAGE_FILES += $($(target)_2_STAGE_TARGETS)
|
---|
| 537 | _STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 538 | _INSTALLS_FILES += $($(target)_2_INST_TARGETS)
|
---|
| 539 | _INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS)
|
---|
| 540 | _CLEAN_FILES += $(clean_files)
|
---|
| 541 | _DIRS += \
|
---|
| 542 | $($(target)_0_OUTDIR) \
|
---|
| 543 | $($(target)_BLDDIRS) \
|
---|
| 544 | $($(target)_BLDDIRS.$(bld_trg)) \
|
---|
| 545 | $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 546 | $($(target)_BLDDIRS.$(bld_trg_arch)) \
|
---|
| 547 | $($(target)_BLDDIRS.$(bld_trg_cpu)) \
|
---|
| 548 | $($(target)_BLDDIRS.$(bld_type))
|
---|
| 549 |
|
---|
| 550 | # Deprecated properties.
|
---|
| 551 | INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS)
|
---|
| 552 | INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 553 |
|
---|
[1936] | 554 | endef # def_install
|
---|
| 555 | $(eval-opt-var def_install)
|
---|
[353] | 556 |
|
---|
[2479] | 557 | ## Do pass 1 on the implicit targets and add them to the list.
|
---|
| 558 | $(foreach target, $(_ALL_INSTALLS_IMPLICIT), \
|
---|
| 559 | $(evalval def_pass1_install))
|
---|
| 560 | _ALL_INSTALLS += $(_ALL_INSTALLS_IMPLICIT)
|
---|
| 561 |
|
---|
| 562 | ## Do pass 2 on all install targets.
|
---|
[1648] | 563 | $(foreach target, $(_ALL_INSTALLS), \
|
---|
[1614] | 564 | $(evalvalctx def_install))
|
---|
[353] | 565 |
|
---|
[988] | 566 | ifdef KBUILD_PROFILE_SELF
|
---|
[2008] | 567 | $(evalcall def_profile_self, done install targets)
|
---|
[988] | 568 | endif
|
---|
[353] | 569 |
|
---|
[2475] | 570 | #
|
---|
[2227] | 571 | # Some introspection targets that can be useful for package maintainers.
|
---|
[2475] | 572 | #
|
---|
[2227] | 573 | .PHONY: kbuild-show-install-files kbuild-show-install-dirs
|
---|
| 574 | kbuild-show-install-files::
|
---|
| 575 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES)))
|
---|
| 576 |
|
---|
| 577 | kbuild-show-install-dirs::
|
---|
| 578 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS)))
|
---|
| 579 |
|
---|
[2475] | 580 | kbuild-show-stage-files::
|
---|
| 581 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES)))
|
---|
[2227] | 582 |
|
---|
[2475] | 583 | kbuild-show-stage-dirs::
|
---|
| 584 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS)))
|
---|
| 585 |
|
---|
| 586 |
|
---|