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