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