[72] | 1 | # $Id: footer-pass2-installs.kmk 3373 2020-06-10 11:01:43Z bird $
|
---|
| 2 | ## @file
|
---|
[2521] | 3 | # kBuild - Footer - Target lists - Pass 2 - Installs.
|
---|
[72] | 4 | #
|
---|
[1547] | 5 |
|
---|
| 6 | #
|
---|
[3121] | 7 | # Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@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)
|
---|
[3120] | 45 | $(stagedst) : $(srcsrc) $(top_deps) | $(dir $(stagedst)) $(top_orderdeps)
|
---|
[2475] | 46 | %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst))
|
---|
[2537] | 47 | $(top_pre_file_cmds)
|
---|
[2475] | 48 | $$(QUIET)$(stagecmd)
|
---|
[2537] | 49 | $(top_post_file_cmds)
|
---|
[353] | 50 | endef
|
---|
[2475] | 51 | $(eval-opt-var def_install_src_rule_staging)
|
---|
[353] | 52 |
|
---|
[2475] | 53 | define def_install_src_rule_installing
|
---|
[2531] | 54 | $$(call KB_FN_ASSERT_ABSPATH, instdst)
|
---|
| 55 | $$(call KB_FN_ASSERT_ABSPATH, srcsrc)
|
---|
[3120] | 56 | $(instdst) : $(srcsrc) $(top_deps) | $(dir $(instdst)) $(top_orderdeps)
|
---|
[2475] | 57 | %$$(call MSG_INST_FILE,$(srcsrc),$(instdst))
|
---|
[2537] | 58 | $(top_pre_file_cmds)
|
---|
[2475] | 59 | $$(QUIET)$(instcmd)
|
---|
[2537] | 60 | $(top_post_file_cmds)
|
---|
[2475] | 61 | endef
|
---|
| 62 | $(eval-opt-var def_install_src_rule_installing)
|
---|
| 63 |
|
---|
| 64 | ##
|
---|
| 65 | # Install one file.
|
---|
| 66 | #
|
---|
[353] | 67 | define def_install_src
|
---|
| 68 |
|
---|
| 69 | # deal with '=>' in the source file name.
|
---|
[2220] | 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
|
---|
[2475] | 79 | local srcdst := $(subst =>, ,$(src))
|
---|
| 80 | local srcsrc := $(firstword $(srcdst))
|
---|
[1496] | 81 | local srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[2531] | 82 | ifeq ($(srcdstdir),./)
|
---|
| 83 | local srcdstdir:=
|
---|
| 84 | endif
|
---|
[2475] | 85 | local srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
[353] | 86 |
|
---|
[2518] | 87 | # instfun, mode, uid and gid.
|
---|
[353] | 88 | ifdef $(srcsrc)_INSTFUN
|
---|
[1496] | 89 | local instfun := $(srcsrc)_INSTFUN
|
---|
[353] | 90 | else
|
---|
[2475] | 91 | local instfun := $(top_instfun)
|
---|
[353] | 92 | endif
|
---|
[1496] | 93 | local mode := $(firstword \
|
---|
[2483] | 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))
|
---|
[1496] | 107 | local uid := $(firstword \
|
---|
[481] | 108 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 109 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 110 | $($(target)_$(srcsrc)_UID) \
|
---|
[481] | 111 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 112 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 113 | $($(target)_$(srcdst)_UID) \
|
---|
[481] | 114 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 115 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 116 | $($(srcsrc)_UID) \
|
---|
[481] | 117 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 118 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 119 | $($(srcdst)_UID) \
|
---|
[2475] | 120 | $(top_uid))
|
---|
[1496] | 121 | local gid := $(firstword \
|
---|
[481] | 122 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 123 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 124 | $($(target)_$(srcsrc)_GID) \
|
---|
[481] | 125 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 126 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 127 | $($(target)_$(srcdst)_GID) \
|
---|
[481] | 128 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 129 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 130 | $($(srcsrc)_GID) \
|
---|
[481] | 131 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 132 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 133 | $($(srcdst)_GID) \
|
---|
[2475] | 134 | $(top_gid))
|
---|
[1496] | 135 | local flags := \
|
---|
[2475] | 136 | $(top_ifflags) \
|
---|
[2483] | 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))
|
---|
[1614] | 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))
|
---|
[414] | 162 |
|
---|
[725] | 163 |
|
---|
| 164 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
[2477] | 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
|
---|
[1755] | 172 | ifneq ($(defpath),)
|
---|
| 173 | local srcsrc := $(abspathex $(srcsrc),$(defpath))
|
---|
[725] | 174 | endif
|
---|
| 175 |
|
---|
[2479] | 176 | # Generate the staging rule (requires double evaluation).
|
---|
[2517] | 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
|
---|
[2518] | 186 | local stage := $(abspath $(stage))/
|
---|
[2517] | 187 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
[2518] | 188 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
[2517] | 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
|
---|
[353] | 194 | ifdef $(srcsrc)_INSTALLER
|
---|
[2479] | 195 | local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
[830] | 196 | else ifdef $(target)_INSTALLER
|
---|
[2479] | 197 | local stagecmd := $(call $(target)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
[353] | 198 | else
|
---|
[2479] | 199 | local stagecmd := $$(INSTALL_STAGING)\
|
---|
[414] | 200 | $(if $(uid),-o $(uid))\
|
---|
| 201 | $(if $(gid),-g $(gid))\
|
---|
| 202 | $(if $(mode),-m $(mode))\
|
---|
[1599] | 203 | $(flags) -- \
|
---|
[2475] | 204 | $(srcsrc) $(stagedst)
|
---|
[353] | 205 | endif
|
---|
[2475] | 206 | $(eval $(def_install_src_rule_staging))
|
---|
| 207 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
[353] | 208 |
|
---|
[2475] | 209 | # Generate the install rule
|
---|
| 210 | ifeq ($(insttype),both)
|
---|
[2517] | 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 |
|
---|
[2479] | 222 | ifdef $(srcsrc)_INSTALLER
|
---|
[2517] | 223 | local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
[2479] | 224 | else ifdef $(target)_INSTALLER
|
---|
[2517] | 225 | local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
[2479] | 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
|
---|
[2475] | 234 | $(eval $(def_install_src_rule_installing))
|
---|
| 235 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
| 236 | endif
|
---|
| 237 |
|
---|
[2517] | 238 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
|
---|
[1936] | 239 | endef # def_install_src
|
---|
| 240 | $(eval-opt-var def_install_src)
|
---|
[353] | 241 |
|
---|
| 242 |
|
---|
[2475] | 243 | ##
|
---|
| 244 | # Generate the symlink rules.
|
---|
| 245 | #
|
---|
| 246 | define def_install_symlink_rule_staging
|
---|
[2531] | 247 | $$(call KB_FN_ASSERT_ABSPATH, stagedst)
|
---|
[3120] | 248 | $(stagedst) : $(top_deps) | $(dir $(stagedst)) $(top_orderdeps)
|
---|
[2475] | 249 | %$$(call MSG_INST_SYM,$(stagedst),$(symdst))
|
---|
[1599] | 250 | $$(QUIET)$$(RM) -f -- $$@
|
---|
[2537] | 251 | $(top_pre_sym_cmds)
|
---|
[2475] | 252 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst)
|
---|
[2537] | 253 | $(top_post_sym_cmds)
|
---|
[2475] | 254 | endef
|
---|
| 255 | $(eval-opt-var def_install_symlink_rule_staging)
|
---|
[353] | 256 |
|
---|
[2475] | 257 | define def_install_symlink_rule_installing
|
---|
[2531] | 258 | $$(call KB_FN_ASSERT_ABSPATH, instdst)
|
---|
[3120] | 259 | $(instdst) : $(top_deps) | $(dir $(instdst)) $(top_orderdeps)
|
---|
[2475] | 260 | %$$(call MSG_INST_SYM,$(instdst),$(symdst))
|
---|
| 261 | $$(QUIET)$$(RM) -f -- $$@
|
---|
[2537] | 262 | $(top_pre_sym_cmds)
|
---|
[2475] | 263 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst)
|
---|
[2537] | 264 | $(top_post_sym_cmds)
|
---|
[2475] | 265 | endef
|
---|
| 266 | $(eval-opt-var def_install_symlink_rule_installing)
|
---|
| 267 |
|
---|
| 268 |
|
---|
| 269 | ##
|
---|
| 270 | # Create one symlink.
|
---|
| 271 | #
|
---|
[353] | 272 | define def_install_symlink
|
---|
| 273 |
|
---|
| 274 | # deal with '=>' in the source file name.
|
---|
[1496] | 275 | local symdst := $(subst =>, ,$(src))
|
---|
| 276 | local symlnk := $(firstword $(symdst))
|
---|
| 277 | local symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[2529] | 278 | local symlnkdir := $(dir $(symlnk))
|
---|
| 279 | ifeq ($(symlnkdir),./)
|
---|
| 280 | local symlnkdir :=
|
---|
| 281 | endif
|
---|
[353] | 282 |
|
---|
[2517] | 283 | # Figure which install function to use below.
|
---|
[380] | 284 | ifdef $(symlnk)_INSTFUN
|
---|
[1496] | 285 | local instfun := $(symlnk)_INSTFUN
|
---|
[353] | 286 | else
|
---|
[2475] | 287 | local instfun := $(top_instfun)
|
---|
[353] | 288 | endif
|
---|
| 289 |
|
---|
[2517] | 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)/
|
---|
[353] | 295 | endif
|
---|
[2529] | 296 | local stage := $(stage)$(symlnkdir)
|
---|
[2517] | 297 | ifeq ($(root $(stage)),)
|
---|
| 298 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
|
---|
| 299 | else
|
---|
[2518] | 300 | local stage := $(abspath $(stage))/
|
---|
[2517] | 301 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
[2518] | 302 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
[2517] | 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
|
---|
[2475] | 307 | endif
|
---|
[353] | 308 |
|
---|
[2475] | 309 | $(eval $(def_install_symlink_rule_staging))
|
---|
| 310 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
[353] | 311 |
|
---|
[2517] | 312 | # Calcuate the install destiation and generate the rule (if necessary).
|
---|
[2475] | 313 | ifeq ($(instmode),both)
|
---|
[2517] | 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
|
---|
[2529] | 322 | local inst := $(inst)$(symlnkdir)
|
---|
[2517] | 323 | local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
[2475] | 324 | $(eval $(def_install_symlink_rule_installing))
|
---|
| 325 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
| 326 | endif
|
---|
| 327 |
|
---|
[2530] | 328 | #$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
|
---|
[1936] | 329 | endef # def_install_symlink
|
---|
| 330 | $(optmize def_install_symlink)
|
---|
[353] | 331 |
|
---|
[412] | 332 |
|
---|
[2475] | 333 | ##
|
---|
| 334 | # Generate an directory installtion rule.
|
---|
| 335 | # Note. Used both for staging and real install rules.
|
---|
| 336 | #
|
---|
[380] | 337 | define def_install_directory_rule
|
---|
[2531] | 338 | $$(call KB_FN_ASSERT_ABSPATH, insdst)
|
---|
[3120] | 339 | $(insdst): $(top_deps) | $(top_orderdeps)
|
---|
[1496] | 340 | %$$(call MSG_INST_DIR,$(insdst))
|
---|
[2537] | 341 | $(top_pre_dir_cmds)
|
---|
[696] | 342 | $$(QUIET)$$(INSTALL) -d \
|
---|
[380] | 343 | $(if $(uid),-o $(uid))\
|
---|
| 344 | $(if $(gid),-g $(gid))\
|
---|
| 345 | $(if $(mode),-m $(mode))\
|
---|
[1599] | 346 | $(flags) -- \
|
---|
[380] | 347 | $(insdst)
|
---|
[2537] | 348 | $(top_post_dir_cmds)
|
---|
[412] | 349 |
|
---|
[1936] | 350 | endef # def_install_directory_rule
|
---|
| 351 | $(eval-opt-var def_install_directory_rule)
|
---|
[380] | 352 |
|
---|
[2475] | 353 | ##
|
---|
| 354 | # Create one directory.
|
---|
| 355 | #
|
---|
[380] | 356 | define def_install_directory
|
---|
| 357 |
|
---|
[2475] | 358 | # gather common properties.
|
---|
[1496] | 359 | local mode := $(firstword \
|
---|
[481] | 360 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 361 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 362 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 363 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 364 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 365 | $($(directory)_MODE) \
|
---|
[2475] | 366 | $(top_mode) )
|
---|
[1496] | 367 | local uid := $(firstword \
|
---|
[481] | 368 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 369 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 370 | $($(target)_$(directory)_UID) \
|
---|
[481] | 371 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 372 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 373 | $($(directory)_UID) \
|
---|
[2475] | 374 | $(top_uid) )
|
---|
[1496] | 375 | local gid := $(firstword \
|
---|
[481] | 376 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 377 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 378 | $($(target)_$(directory)_GID) \
|
---|
[481] | 379 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 380 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 381 | $($(directory)_GID) \
|
---|
[2475] | 382 | $(top_gid) )
|
---|
[1496] | 383 | local flags := \
|
---|
[2475] | 384 | $(top_idflags) \
|
---|
[830] | 385 | $($(directory)_IDFLAGS) \
|
---|
| 386 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 387 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 388 | $($(target)_$(directory)_IDFLAGS) \
|
---|
| 389 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
[2475] | 390 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 391 |
|
---|
[2475] | 392 | # The staging rule (requires double evaluation).
|
---|
[2517] | 393 | local stage := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value))
|
---|
| 394 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
| 395 | $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
| 396 | local stage := $(stage)/
|
---|
| 397 | endif
|
---|
| 398 | ifeq ($(root $(stage)),)
|
---|
| 399 | local insdst := $(PATH_STAGE)/$(stage)$(directory)/
|
---|
| 400 | else
|
---|
[2518] | 401 | local stage := $(abspath $(stage))/
|
---|
[2517] | 402 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
| 403 | local insdst := $(stage)$(directory)/
|
---|
| 404 | else
|
---|
| 405 | $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
| 406 | endif
|
---|
| 407 | endif
|
---|
| 408 |
|
---|
[2475] | 409 | $(target)_2_STAGE_DIR_TARGETS += $(insdst)
|
---|
[380] | 410 | $(eval $(def_install_directory_rule))
|
---|
| 411 |
|
---|
[2475] | 412 | # The install rule.
|
---|
| 413 | ifeq ($(insttype),both)
|
---|
[2517] | 414 | local inst := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value))
|
---|
| 415 | ifneq ($(substr $(inst),-1),/)
|
---|
| 416 | $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
| 417 | local inst := $(inst)/
|
---|
| 418 | endif
|
---|
[2519] | 419 | ifneq ($(root $(stage)),)
|
---|
| 420 | $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
[2517] | 421 | endif
|
---|
[2514] | 422 | local insdst := $(PATH_INS)/$(inst)$(directory)/
|
---|
[2475] | 423 | $(target)_2_INST_DIR_TARGETS += $(insdst)
|
---|
| 424 | $(eval $(def_install_directory_rule))
|
---|
| 425 | endif
|
---|
| 426 |
|
---|
[2517] | 427 | #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
[1936] | 428 | endef # def_install_directory
|
---|
| 429 | $(eval-opt-var def_install_directory)
|
---|
[380] | 430 |
|
---|
| 431 |
|
---|
[2475] | 432 | ##
|
---|
| 433 | # Process one install target.
|
---|
| 434 | #
|
---|
[353] | 435 | define def_install
|
---|
[744] | 436 | # the basics.
|
---|
[2475] | 437 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
| 438 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
| 439 | local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
| 440 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
| 441 | local insttype := $($(target)_1_INSTTYPE)
|
---|
[353] | 442 |
|
---|
[2475] | 443 | ifneq ($(insttype),none)
|
---|
| 444 | $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS)
|
---|
| 445 | else
|
---|
| 446 | $(target)_2_STAGE_TARGETS :=
|
---|
| 447 | endif
|
---|
| 448 | $(target)_2_STAGE_DIR_TARGETS :=
|
---|
| 449 |
|
---|
| 450 | ifeq ($(insttype),both)
|
---|
| 451 | $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS)
|
---|
| 452 | else
|
---|
| 453 | $(target)_2_INST_TARGETS :=
|
---|
| 454 | endif
|
---|
| 455 | $(target)_2_INST_DIR_TARGETS :=
|
---|
| 456 |
|
---|
| 457 |
|
---|
| 458 | local outbase := $(call TARGET_BASE,$(target),$(target))
|
---|
[2239] | 459 | $(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
|
---|
[2436] | 460 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
[380] | 461 |
|
---|
[2475] | 462 | ifneq ($(insttype),none)
|
---|
[2537] | 463 | # Cache top level target properties.
|
---|
[2475] | 464 | local top_mode := $(firstword \
|
---|
| 465 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 466 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 467 | $($(target)_MODE) )
|
---|
[2483] | 468 | local top_exec_mode := $(firstword \
|
---|
| 469 | $($(target)_EXEC_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 470 | $($(target)_EXEC_MODE.$(bld_trg)) \
|
---|
| 471 | $($(target)_EXEC_MODE) )
|
---|
[2475] | 472 | local top_uid := $(firstword \
|
---|
| 473 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 474 | $($(target)_UID.$(bld_trg)) \
|
---|
| 475 | $($(target)_UID) )
|
---|
| 476 | local top_gid := $(firstword \
|
---|
| 477 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 478 | $($(target)_GID.$(bld_trg)) \
|
---|
| 479 | $($(target)_GID) )
|
---|
| 480 | local top_ifflags := \
|
---|
| 481 | $($(target)_IFFLAGS) \
|
---|
| 482 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
[2477] | 483 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[2475] | 484 | local top_idflags := \
|
---|
| 485 | $($(target)_IDFLAGS) \
|
---|
| 486 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
| 487 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
| 488 | ifdef $(target)_INSTFUN
|
---|
| 489 | local top_instfun := $(target)_INSTFUN
|
---|
| 490 | else
|
---|
| 491 | local top_instfun := _INSTALL_FILE
|
---|
| 492 | endif
|
---|
[3120] | 493 | local top_deps := \
|
---|
| 494 | $($(target)_DEPS.$(bld_trg_cpu)) \
|
---|
| 495 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
| 496 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 497 | $($(target)_DEPS.$(bld_trg).$(bld_type)) \
|
---|
| 498 | $($(target)_DEPS.$(bld_trg_arch)) \
|
---|
| 499 | $($(target)_DEPS.$(bld_trg)) \
|
---|
| 500 | $($(target)_DEPS.$(bld_type)) \
|
---|
| 501 | $($(target)_DEPS)
|
---|
| 502 | local top_orderdeps := \
|
---|
| 503 | $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
|
---|
| 504 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
| 505 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 506 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
|
---|
| 507 | $($(target)_ORDERDEPS.$(bld_trg_arch)) \
|
---|
| 508 | $($(target)_ORDERDEPS.$(bld_trg)) \
|
---|
| 509 | $($(target)_ORDERDEPS.$(bld_type)) \
|
---|
| 510 | $($(target)_ORDERDEPS)
|
---|
| 511 | ifdef $(target)_DEFPATH
|
---|
| 512 | local top_defpath := $($(target)_DEFPATH)
|
---|
| 513 | else ifdef $(target)_PATH
|
---|
| 514 | local top_defpath := $($(target)_PATH)
|
---|
| 515 | else
|
---|
| 516 | local top_defpath :=
|
---|
| 517 | endif
|
---|
| 518 | ifneq ($(top_defpath),)
|
---|
| 519 | local top_deps := $(abspathex $(top_deps),$(top_defpath))
|
---|
| 520 | local top_orderdeps := $(abspathex $(top_orderdeps),$(top_defpath))
|
---|
| 521 | endif
|
---|
| 522 |
|
---|
[2537] | 523 | # The user have to use double expansion and can only use the above locals. Not 100% optimal...
|
---|
| 524 | local top_pre_file_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_XFILE_CMDS)
|
---|
| 525 | local top_post_file_cmds := $(evalcall def_fn_prop_get_first_defined,POST_XFILE_CMDS)
|
---|
| 526 | local top_pre_sym_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_SYMLINK_CMDS)
|
---|
| 527 | local top_post_sym_cmds := $(evalcall def_fn_prop_get_first_defined,POST_SYMLINK_CMDS)
|
---|
| 528 | local top_pre_dir_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_DIRECTORY_CMDS)
|
---|
| 529 | local top_post_dir_cmds := $(evalcall def_fn_prop_get_first_defined,POST_DIRECTORY_CMDS)
|
---|
[1614] | 530 |
|
---|
[2475] | 531 | $(foreach directory, \
|
---|
| 532 | $($(target)_DIRS) \
|
---|
| 533 | $($(target)_DIRS.$(bld_trg)) \
|
---|
| 534 | $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 535 | $($(target)_DIRS.$(bld_trg_arch)) \
|
---|
| 536 | $($(target)_DIRS.$(bld_trg_cpu)) \
|
---|
| 537 | $($(target)_DIRS.$(bld_type)), \
|
---|
| 538 | $(evalval def_install_directory))
|
---|
[380] | 539 |
|
---|
[2475] | 540 | local clean_files := \
|
---|
| 541 | $($(target)_CLEAN) \
|
---|
| 542 | $($(target)_CLEAN.$(bld_trg)) \
|
---|
| 543 | $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 544 | $($(target)_CLEAN.$(bld_trg_arch)) \
|
---|
| 545 | $($(target)_CLEAN.$(bld_trg_cpu)) \
|
---|
| 546 | $($(target)_CLEAN.$(bld_type))
|
---|
[353] | 547 |
|
---|
[2483] | 548 | local source_type_prefix :=
|
---|
| 549 | local source_type_mode := $(firstword $(top_mode) a+r,u+w)
|
---|
[2475] | 550 | $(foreach src,\
|
---|
| 551 | $($(target)_SOURCES) \
|
---|
| 552 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 553 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 554 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 555 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 556 | $($(target)_SOURCES.$(bld_type)), \
|
---|
| 557 | $(evalval def_install_src))
|
---|
[353] | 558 |
|
---|
[2483] | 559 | local source_type_prefix := EXEC_
|
---|
| 560 | local source_type_mode := $(firstword $(top_exec_mode) a+xr,u+w)
|
---|
[2475] | 561 | $(foreach src,\
|
---|
[2483] | 562 | $($(target)_EXEC_SOURCES) \
|
---|
| 563 | $($(target)_EXEC_SOURCES.$(bld_trg)) \
|
---|
| 564 | $($(target)_EXEC_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 565 | $($(target)_EXEC_SOURCES.$(bld_trg_arch)) \
|
---|
| 566 | $($(target)_EXEC_SOURCES.$(bld_trg_cpu)) \
|
---|
| 567 | $($(target)_EXEC_SOURCES.$(bld_type)), \
|
---|
| 568 | $(evalval def_install_src))
|
---|
| 569 |
|
---|
| 570 | $(foreach src,\
|
---|
[2475] | 571 | $($(target)_SYMLINKS) \
|
---|
| 572 | $($(target)_SYMLINKS.$(bld_trg)) \
|
---|
| 573 | $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 574 | $($(target)_SYMLINKS.$(bld_trg_arch)) \
|
---|
| 575 | $($(target)_SYMLINKS.$(bld_trg_cpu)) \
|
---|
| 576 | $($(target)_SYMLINKS.$(bld_type)), \
|
---|
| 577 | $(evalval def_install_symlink))
|
---|
| 578 | else # none
|
---|
| 579 | local clean_files :=
|
---|
| 580 | endif
|
---|
| 581 |
|
---|
| 582 | # The collection targets (staging only).
|
---|
| 583 | local clean_files += $($(target)_1_TARGET)
|
---|
| 584 | $($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@)
|
---|
[827] | 585 | @$(QUIET2)$(APPEND) $@
|
---|
| 586 |
|
---|
[2238] | 587 | $(target): $$($(target)_1_TARGET)
|
---|
[827] | 588 |
|
---|
[2475] | 589 | # Update Global lists.
|
---|
| 590 | _INSTALLS += $($(target)_1_TARGET)
|
---|
| 591 | _STAGE_FILES += $($(target)_2_STAGE_TARGETS)
|
---|
| 592 | _STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 593 | _INSTALLS_FILES += $($(target)_2_INST_TARGETS)
|
---|
| 594 | _INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS)
|
---|
| 595 | _CLEAN_FILES += $(clean_files)
|
---|
| 596 | _DIRS += \
|
---|
| 597 | $($(target)_0_OUTDIR) \
|
---|
| 598 | $($(target)_BLDDIRS) \
|
---|
| 599 | $($(target)_BLDDIRS.$(bld_trg)) \
|
---|
| 600 | $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 601 | $($(target)_BLDDIRS.$(bld_trg_arch)) \
|
---|
| 602 | $($(target)_BLDDIRS.$(bld_trg_cpu)) \
|
---|
| 603 | $($(target)_BLDDIRS.$(bld_type))
|
---|
| 604 |
|
---|
| 605 | # Deprecated properties.
|
---|
| 606 | INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS)
|
---|
| 607 | INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS)
|
---|
| 608 |
|
---|
[1936] | 609 | endef # def_install
|
---|
| 610 | $(eval-opt-var def_install)
|
---|
[353] | 611 |
|
---|
[2479] | 612 | ## Do pass 1 on the implicit targets and add them to the list.
|
---|
| 613 | $(foreach target, $(_ALL_INSTALLS_IMPLICIT), \
|
---|
| 614 | $(evalval def_pass1_install))
|
---|
| 615 | _ALL_INSTALLS += $(_ALL_INSTALLS_IMPLICIT)
|
---|
| 616 |
|
---|
| 617 | ## Do pass 2 on all install targets.
|
---|
[1648] | 618 | $(foreach target, $(_ALL_INSTALLS), \
|
---|
[1614] | 619 | $(evalvalctx def_install))
|
---|
[353] | 620 |
|
---|
[988] | 621 | ifdef KBUILD_PROFILE_SELF
|
---|
[2008] | 622 | $(evalcall def_profile_self, done install targets)
|
---|
[988] | 623 | endif
|
---|
[353] | 624 |
|
---|
[2475] | 625 | #
|
---|
[2227] | 626 | # Some introspection targets that can be useful for package maintainers.
|
---|
[2475] | 627 | #
|
---|
[2227] | 628 | .PHONY: kbuild-show-install-files kbuild-show-install-dirs
|
---|
| 629 | kbuild-show-install-files::
|
---|
| 630 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES)))
|
---|
| 631 |
|
---|
| 632 | kbuild-show-install-dirs::
|
---|
| 633 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS)))
|
---|
| 634 |
|
---|
[2475] | 635 | kbuild-show-stage-files::
|
---|
| 636 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES)))
|
---|
[2227] | 637 |
|
---|
[2475] | 638 | kbuild-show-stage-dirs::
|
---|
| 639 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS)))
|
---|
| 640 |
|
---|
| 641 |
|
---|