[72] | 1 | # $Id: footer.kmk 1502 2008-04-08 00:23:15Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[782] | 6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
---|
[72] | 7 | #
|
---|
| 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 | #
|
---|
| 26 |
|
---|
| 27 | ifndef __footer_kmk__
|
---|
| 28 | # start-of-file-content
|
---|
[988] | 29 | ifdef KBUILD_PROFILE_SELF
|
---|
| 30 | _KBUILD_TS_FOOTER_START := $(nanots )
|
---|
| 31 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_PREV)) - start of footer.kmk)
|
---|
[1441] | 32 | $(info stat: $(make-stats ))
|
---|
[988] | 33 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_START)
|
---|
| 34 | endif
|
---|
[72] | 35 |
|
---|
| 36 | #
|
---|
| 37 | # Variables.
|
---|
[73] | 38 | # (Some of these need initialization before including definitions using them.)
|
---|
[72] | 39 | #
|
---|
| 40 |
|
---|
[985] | 41 | # All targets of each types.
|
---|
| 42 | _ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_CPU)) $(BLDPROGS.$(BUILD_TYPE))
|
---|
| 43 | _ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_CPU)) $(LIBRARIES.$(BUILD_TYPE))
|
---|
| 44 | _ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_CPU)) $(IMPORT_LIBS.$(BUILD_TYPE))
|
---|
| 45 | _ALL_DLLS := $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_CPU)) $(DLLS.$(BUILD_TYPE))
|
---|
| 46 | _ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_CPU)) $(PROGRAMS.$(BUILD_TYPE))
|
---|
| 47 | _ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_CPU)) $(SYSMODS.$(BUILD_TYPE))
|
---|
| 48 | _ALL_OTHERS := $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_CPU)) $(OTHERS.$(BUILD_TYPE))
|
---|
| 49 | _ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_CPU)) $(INSTALLS.$(BUILD_TYPE))
|
---|
| 50 | _ALL_FETCHES := $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_CPU)) $(FETCHES.$(BUILD_TYPE))
|
---|
| 51 | _ALL_PATCHES := $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_CPU)) $(PATCHES.$(BUILD_TYPE))
|
---|
| 52 |
|
---|
[72] | 53 | # all targets.
|
---|
[985] | 54 | _ALL_TARGETS = \
|
---|
| 55 | $(_ALL_FETCHES) \
|
---|
| 56 | $(_ALL_PATCHES) \
|
---|
| 57 | $(_ALL_BLDPROGS) \
|
---|
| 58 | $(_ALL_LIBRARIES) \
|
---|
| 59 | $(_ALL_IMPORT_LIBS) \
|
---|
| 60 | $(_ALL_DLLS) \
|
---|
| 61 | $(_ALL_PROGRAMS) \
|
---|
| 62 | $(_ALL_SYSMODS) \
|
---|
| 63 | $(_ALL_INSTALLS) \
|
---|
| 64 | $(_ALL_OTHERS)
|
---|
[72] | 65 |
|
---|
[447] | 66 | # all $(BUILD_TARGET) targets.
|
---|
[985] | 67 | _ALL_BUILD_TARGET_TARGETS = \
|
---|
| 68 | $(_ALL_FETCHES) \
|
---|
| 69 | $(_ALL_PATCHES) \
|
---|
| 70 | $(_ALL_LIBRARIES) \
|
---|
| 71 | $(_ALL_IMPORT_LIBS) \
|
---|
| 72 | $(_ALL_DLLS) \
|
---|
| 73 | $(_ALL_PROGRAMS) \
|
---|
| 74 | $(_ALL_SYSMODS) \
|
---|
| 75 | $(_ALL_INSTALLS) \
|
---|
| 76 | $(_ALL_OTHERS)
|
---|
[447] | 77 |
|
---|
[985] | 78 | # all $(BUILD_PLATFORM) targets.
|
---|
| 79 | _ALL_BUILD_PLATFORM_TARGETS = \
|
---|
| 80 | $(_ALL_BLDPROGS)
|
---|
[447] | 81 |
|
---|
[640] | 82 | # all targets making use of srcname.
|
---|
[985] | 83 | _ALL_SRCNAME_TARGETS = \
|
---|
| 84 | $(_ALL_FETCHES) \
|
---|
| 85 | $(_ALL_PATCHES)
|
---|
[640] | 86 |
|
---|
[75] | 87 | # dependency files.
|
---|
| 88 | _DEPFILES :=
|
---|
| 89 |
|
---|
[380] | 90 | # included dependency files.
|
---|
| 91 | _DEPFILES_INCLUDED :=
|
---|
| 92 |
|
---|
| 93 |
|
---|
[75] | 94 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 95 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 96 | # required dependency file must add those output files to this variable.
|
---|
| 97 | _OUT_FILES :=
|
---|
| 98 |
|
---|
[353] | 99 | # Files which only requires cleaning up.
|
---|
| 100 | _CLEAN_FILES :=
|
---|
| 101 |
|
---|
[72] | 102 | # all of a type
|
---|
[219] | 103 | _OBJS :=
|
---|
[640] | 104 | _FETCHES :=
|
---|
| 105 | _DOWNLOADS:=
|
---|
| 106 | _UNPACKS :=
|
---|
| 107 | _PATCHES :=
|
---|
[688] | 108 | _UNFETCHES:=
|
---|
[222] | 109 | _BLDPROGS :=
|
---|
[219] | 110 | _LIBS :=
|
---|
| 111 | _DLLS :=
|
---|
| 112 | _PROGRAMS :=
|
---|
| 113 | _SYSMODS :=
|
---|
[353] | 114 | _INSTALLS :=
|
---|
[827] | 115 | _INSTALLS_FILES :=
|
---|
[380] | 116 | _INSTALLS_DIRS :=
|
---|
[353] | 117 | _OTHERS :=
|
---|
[417] | 118 | _PACKING :=
|
---|
[897] | 119 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
|
---|
[189] | 120 | _IMPORT_LIBS :=
|
---|
[72] | 121 |
|
---|
[220] | 122 | # misc
|
---|
| 123 | pass_prev :=
|
---|
| 124 |
|
---|
| 125 |
|
---|
[984] | 126 |
|
---|
[72] | 127 | #
|
---|
[984] | 128 | # Footer macros
|
---|
[73] | 129 | #
|
---|
| 130 |
|
---|
[78] | 131 | ## Figure out the tool for a target.
|
---|
[753] | 132 | # @param $1 normalized target.
|
---|
| 133 | # @param $2 tooltype.
|
---|
[222] | 134 | # @param bld_trg build target.
|
---|
[481] | 135 | # @param bld_trg_arch build target architecture.
|
---|
[79] | 136 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[753] | 137 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 138 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
---|
| 139 | $($(1)_$(2)TOOL) \
|
---|
| 140 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 141 | $($(1)_TOOL.$(bld_trg)) \
|
---|
| 142 | $($(1)_TOOL) \
|
---|
| 143 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 144 | $($(2)TOOL.$(bld_trg)) \
|
---|
| 145 | $($(2)TOOL) \
|
---|
[481] | 146 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 147 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 148 | $(TOOL) \
|
---|
[79] | 149 | ))
|
---|
[183] | 150 |
|
---|
[353] | 151 | ## Figure out the actual name of an installed file.
|
---|
| 152 | # @param $1 The file to install.
|
---|
| 153 | # @param $2 The target name.
|
---|
| 154 | # @param $3 The _INST value (can be empty).
|
---|
| 155 | # @param $4 The default directory to use when $3 is empty.
|
---|
| 156 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
| 157 |
|
---|
| 158 |
|
---|
[1413] | 159 |
|
---|
| 160 | ## Inherit one keyword in a non-accumulative manner.
|
---|
| 161 | # @param $(trg) Target object.
|
---|
| 162 | # @param $(prop) The property.
|
---|
| 163 | # @param $(src_key) Source keyword.
|
---|
| 164 | # @param $(trg_key) Target keyword.
|
---|
| 165 | define def_inherit_one_keyword
|
---|
| 166 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 167 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 168 | $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
|
---|
| 169 | endif
|
---|
| 170 | endif
|
---|
| 171 | endef
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | # EXPAND_BY = overriding
|
---|
| 175 |
|
---|
| 176 | ## Inherit one keyword in a non-accumulative manner.
|
---|
| 177 | # @param $(trg) Target object.
|
---|
| 178 | # @param $(prop) The property.
|
---|
| 179 | # @param $(src_key) Source keyword.
|
---|
| 180 | # @param $(trg_key) Target keyword.
|
---|
| 181 | define def_inherit_one_keyword_overriding_now_l
|
---|
| 182 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 183 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 184 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
| 185 | endif
|
---|
| 186 | endif
|
---|
| 187 | endef
|
---|
| 188 |
|
---|
| 189 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
| 190 | define def_inherit_one_keyword_overriding_now_r
|
---|
| 191 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 192 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 193 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
| 194 | endif
|
---|
| 195 | endif
|
---|
| 196 | endef
|
---|
| 197 |
|
---|
| 198 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
| 199 | # @param $(trg) Target object.
|
---|
| 200 | # @param $(prop) The property.
|
---|
| 201 | # @param $(src_key) Source keyword.
|
---|
| 202 | # @param $(trg_key) Target keyword.
|
---|
| 203 | # @remark This define relies on double evaluation
|
---|
| 204 | define def_inherit_one_keyword_overriding_deferred
|
---|
| 205 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 206 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 207 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
| 208 | endif
|
---|
| 209 | endif
|
---|
| 210 | endef
|
---|
| 211 |
|
---|
| 212 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
| 213 | define def_inherit_one_keyword_overriding_deferred_l
|
---|
| 214 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 215 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 216 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
| 217 | endif
|
---|
| 218 | endif
|
---|
| 219 | endef
|
---|
| 220 |
|
---|
| 221 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
| 222 | define def_inherit_one_keyword_overriding_deferred_r
|
---|
| 223 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 224 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 225 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
| 226 | endif
|
---|
| 227 | endif
|
---|
| 228 | endef
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | # EXPAND_BY = prepending
|
---|
| 232 |
|
---|
| 233 | ## Inherit one keyword in a prepending manner.
|
---|
| 234 | # @param $(trg) Target object.
|
---|
| 235 | # @param $(prop) The property.
|
---|
| 236 | # @param $(src_key) Source keyword.
|
---|
| 237 | # @param $(trg_key) Target keyword.
|
---|
| 238 | define def_inherit_one_keyword_prepending_now_l
|
---|
| 239 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 240 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
| 241 | endif
|
---|
| 242 | endef
|
---|
| 243 |
|
---|
| 244 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
| 245 | define def_inherit_one_keyword_prepending_now_r
|
---|
| 246 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 247 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
| 248 | endif
|
---|
| 249 | endef
|
---|
| 250 |
|
---|
| 251 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
| 252 | # @param $(trg) Target object.
|
---|
| 253 | # @param $(prop) The property.
|
---|
| 254 | # @param $(src_key) Source keyword.
|
---|
| 255 | # @param $(trg_key) Target keyword.
|
---|
| 256 | # @remark This define relies on double evaluation
|
---|
| 257 | define def_inherit_one_keyword_prepending_deferred
|
---|
| 258 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 259 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 260 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
| 261 | endif
|
---|
| 262 | endif
|
---|
| 263 | endef
|
---|
| 264 |
|
---|
| 265 | ## Inherit one keyword in a prepending manner, deferred expansion.
|
---|
| 266 | # @param $(trg) Target object.
|
---|
| 267 | # @param $(prop) The property.
|
---|
| 268 | # @param $(src_key) Source keyword.
|
---|
| 269 | # @param $(trg_key) Target keyword.
|
---|
| 270 | define def_inherit_one_keyword_prepending_deferred_l
|
---|
| 271 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 272 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
| 273 | endif
|
---|
| 274 | endef
|
---|
| 275 |
|
---|
| 276 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
| 277 | define def_inherit_one_keyword_prepending_deferred_r
|
---|
| 278 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 279 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
| 280 | endif
|
---|
| 281 | endef
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 | # EXPAND_BY = appending
|
---|
| 285 |
|
---|
| 286 | ## Inherit one keyword in an appending manner.
|
---|
| 287 | # @param $(trg) Target object.
|
---|
| 288 | # @param $(prop) The property.
|
---|
| 289 | # @param $(src_key) Source keyword.
|
---|
| 290 | # @param $(trg_key) Target keyword.
|
---|
| 291 | define def_inherit_one_keyword_appending_now_l
|
---|
| 292 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 293 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
| 294 | endif
|
---|
| 295 | endef
|
---|
| 296 |
|
---|
| 297 | ## @copydoc def_inherit_one_appending_now_l
|
---|
| 298 | define def_inherit_one_keyword_appending_now_r
|
---|
| 299 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 300 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
| 301 | endif
|
---|
| 302 | endef
|
---|
| 303 |
|
---|
| 304 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
| 305 | # @param $(trg) Target object.
|
---|
| 306 | # @param $(prop) The property.
|
---|
| 307 | # @param $(src_key) Source keyword.
|
---|
| 308 | # @param $(trg_key) Target keyword.
|
---|
| 309 | # @remark This define relies on double evaluation
|
---|
| 310 | define def_inherit_one_keyword_appending_deferred
|
---|
| 311 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 312 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
| 313 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
| 314 | endif
|
---|
| 315 | endif
|
---|
| 316 | endef
|
---|
| 317 |
|
---|
| 318 | ## Inherit one keyword in an appending manner, deferred expansion.
|
---|
| 319 | # @param $(trg) Target object.
|
---|
| 320 | # @param $(prop) The property.
|
---|
| 321 | # @param $(src_key) Source keyword.
|
---|
| 322 | # @param $(trg_key) Target keyword.
|
---|
| 323 | define def_inherit_one_keyword_appending_deferred_l
|
---|
| 324 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 325 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
| 326 | endif
|
---|
| 327 | endef
|
---|
| 328 |
|
---|
| 329 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
| 330 | define def_inherit_one_keyword_appending_deferred_r
|
---|
| 331 | ifdef $(trg)_$(prop).$(src_key)
|
---|
| 332 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
| 333 | endif
|
---|
| 334 | endef
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 | ## Worker fro def_inherit that deals with one keyword that makes
|
---|
| 338 | # use of inheritance.
|
---|
| 339 | # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
|
---|
| 340 | # @param trg Object to consider for inheriting.
|
---|
| 341 | # @param properties List of the properties with straight expansion.
|
---|
| 342 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
| 343 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
| 344 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
| 345 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
| 346 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
| 347 | define def_inherit_keyword
|
---|
[1496] | 348 | local prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
|
---|
| 349 | local trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
|
---|
| 350 | local src_key := $($(prefix)_$(trg_key)_EXTENDS)
|
---|
| 351 | local by := $($(prefix)_$(trg_key)_EXTENDS_BY)
|
---|
[1413] | 352 |
|
---|
| 353 | # Inherit the properties.
|
---|
| 354 | $(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
|
---|
| 355 | $(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
|
---|
| 356 | $(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
|
---|
| 357 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
|
---|
| 358 | $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
|
---|
| 359 | $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
|
---|
| 360 |
|
---|
| 361 | endef # def_inherit_keyword
|
---|
| 362 |
|
---|
| 363 |
|
---|
[985] | 364 | ## Inherit one template property in a non-accumulative manner.
|
---|
| 365 | # @param $(prop) Property name
|
---|
| 366 | # @param $(src) Source (parent) object.
|
---|
| 367 | # @param $(trg) Target (child) object.
|
---|
| 368 | define def_inherit_one
|
---|
| 369 | ifdef $(src)_$(prop)
|
---|
| 370 | ifndef $(trg)_$(prop)
|
---|
| 371 | $(trg)_$(prop) = $($(src)_$(prop))
|
---|
| 372 | endif
|
---|
| 373 | endif
|
---|
[1413] | 374 | endef
|
---|
[723] | 375 |
|
---|
[1407] | 376 |
|
---|
| 377 | # EXPAND_BY = overriding
|
---|
| 378 |
|
---|
[985] | 379 | ## Inherit one template property in a non-accumulative manner.
|
---|
| 380 | # @param $(prop) Property name
|
---|
| 381 | # @param $(src) Source (parent) object.
|
---|
| 382 | # @param $(trg) Target (child) object.
|
---|
[1407] | 383 | define def_inherit_one_overriding_now_l
|
---|
[985] | 384 | ifdef $(src)_$(prop)
|
---|
| 385 | ifndef $(trg)_$(prop)
|
---|
| 386 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
| 387 | endif
|
---|
| 388 | endif
|
---|
[1413] | 389 | endef
|
---|
[185] | 390 |
|
---|
[1407] | 391 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
| 392 | define def_inherit_one_overriding_now_r
|
---|
| 393 | ifdef $(src)_$(prop)
|
---|
| 394 | ifndef $(trg)_$(prop)
|
---|
| 395 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
| 396 | endif
|
---|
| 397 | endif
|
---|
[1413] | 398 | endef
|
---|
[1407] | 399 |
|
---|
[985] | 400 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 401 | # @param $(prop) Property name
|
---|
| 402 | # @param $(src) Source
|
---|
| 403 | # @param $(trg) Target
|
---|
| 404 | # @remark This define relies on double evaluation
|
---|
[1407] | 405 | define def_inherit_one_overriding_deferred
|
---|
[985] | 406 | ifdef $(src)_$(prop)
|
---|
| 407 | ifndef $(trg)_$(prop)
|
---|
| 408 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 409 | endif
|
---|
[185] | 410 | endif
|
---|
[1413] | 411 | endef
|
---|
[185] | 412 |
|
---|
[1407] | 413 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
| 414 | define def_inherit_one_overriding_deferred_l
|
---|
| 415 | ifdef $(src)_$(prop)
|
---|
| 416 | ifndef $(trg)_$(prop)
|
---|
| 417 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 418 | endif
|
---|
| 419 | endif
|
---|
[1413] | 420 | endef
|
---|
[1407] | 421 |
|
---|
| 422 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
| 423 | define def_inherit_one_overriding_deferred_r
|
---|
| 424 | ifdef $(src)_$(prop)
|
---|
| 425 | ifndef $(trg)_$(prop)
|
---|
| 426 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 427 | endif
|
---|
| 428 | endif
|
---|
[1413] | 429 | endef
|
---|
[1407] | 430 |
|
---|
| 431 |
|
---|
| 432 | # EXPAND_BY = prepending
|
---|
| 433 |
|
---|
| 434 | ## Inherit one template property in a prepending manner.
|
---|
| 435 | # @param $(prop) Property name
|
---|
| 436 | # @param $(src) Source (parent) object.
|
---|
| 437 | # @param $(trg) Target (child) object.
|
---|
| 438 | define def_inherit_one_prepending_now_l
|
---|
| 439 | ifdef $(src)_$(prop)
|
---|
[1413] | 440 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
[1407] | 441 | endif
|
---|
[1413] | 442 | endef
|
---|
[1407] | 443 |
|
---|
| 444 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
| 445 | define def_inherit_one_prepending_now_r
|
---|
| 446 | ifdef $(src)_$(prop)
|
---|
[1413] | 447 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
[1407] | 448 | endif
|
---|
[1413] | 449 | endef
|
---|
[1407] | 450 |
|
---|
| 451 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 452 | # @param $(prop) Property name
|
---|
| 453 | # @param $(src) Source
|
---|
| 454 | # @param $(trg) Target
|
---|
| 455 | # @remark This define relies on double evaluation
|
---|
| 456 | define def_inherit_one_prepending_deferred
|
---|
| 457 | ifdef $(src)_$(prop)
|
---|
| 458 | ifndef $(trg)_$(prop)
|
---|
| 459 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 460 | endif
|
---|
| 461 | endif
|
---|
[1413] | 462 | endef
|
---|
[1407] | 463 |
|
---|
| 464 | ## Inherit one template property in a prepending manner, deferred expansion.
|
---|
| 465 | # @param $(prop) Property name
|
---|
| 466 | # @param $(src) Source (parent) object.
|
---|
| 467 | # @param $(trg) Target (child) object.
|
---|
| 468 | define def_inherit_one_prepending_deferred_l
|
---|
| 469 | ifdef $(src)_$(prop)
|
---|
| 470 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
| 471 | endif
|
---|
[1413] | 472 | endef
|
---|
[1407] | 473 |
|
---|
| 474 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
| 475 | define def_inherit_one_prepending_deferred_r
|
---|
| 476 | ifdef $(src)_$(prop)
|
---|
| 477 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
| 478 | endif
|
---|
[1413] | 479 | endef
|
---|
[1407] | 480 |
|
---|
| 481 |
|
---|
| 482 | # EXPAND_BY = appending
|
---|
| 483 |
|
---|
[1413] | 484 | ## Inherit one template property in an appending manner.
|
---|
[1407] | 485 | # @param $(prop) Property name
|
---|
| 486 | # @param $(src) Source (parent) object.
|
---|
| 487 | # @param $(trg) Target (child) object.
|
---|
| 488 | define def_inherit_one_appending_now_l
|
---|
| 489 | ifdef $(src)_$(prop)
|
---|
[1413] | 490 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
[1407] | 491 | endif
|
---|
[1413] | 492 | endef
|
---|
[1407] | 493 |
|
---|
| 494 | ## @copydoc def_inherit_one_appending_now_l
|
---|
| 495 | define def_inherit_one_appending_now_r
|
---|
| 496 | ifdef $(src)_$(prop)
|
---|
[1413] | 497 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
[1407] | 498 | endif
|
---|
[1413] | 499 | endef
|
---|
[1407] | 500 |
|
---|
| 501 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 502 | # @param $(prop) Property name
|
---|
| 503 | # @param $(src) Source
|
---|
| 504 | # @param $(trg) Target
|
---|
| 505 | # @remark This define relies on double evaluation
|
---|
| 506 | define def_inherit_one_appending_deferred
|
---|
| 507 | ifdef $(src)_$(prop)
|
---|
| 508 | ifndef $(trg)_$(prop)
|
---|
| 509 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 510 | endif
|
---|
| 511 | endif
|
---|
[1413] | 512 | endef
|
---|
[1407] | 513 |
|
---|
[1413] | 514 | ## Inherit one template property in an appending manner, deferred expansion.
|
---|
[1407] | 515 | # @param $(prop) Property name
|
---|
| 516 | # @param $(src) Source (parent) object.
|
---|
| 517 | # @param $(trg) Target (child) object.
|
---|
| 518 | define def_inherit_one_appending_deferred_l
|
---|
| 519 | ifdef $(src)_$(prop)
|
---|
| 520 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
| 521 | endif
|
---|
[1413] | 522 | endef
|
---|
[1407] | 523 |
|
---|
| 524 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
| 525 | define def_inherit_one_appending_deferred_r
|
---|
| 526 | ifdef $(src)_$(prop)
|
---|
| 527 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
| 528 | endif
|
---|
[1413] | 529 | endef
|
---|
[1407] | 530 |
|
---|
| 531 |
|
---|
[1413] | 532 | ## combines the specified properties $(1) with the $(_KEYWORDS) list.
|
---|
| 533 | _INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
---|
[1407] | 534 |
|
---|
[1413] | 535 |
|
---|
[985] | 536 | ## Generic inheritance for use with targets templates and tools.
|
---|
[1407] | 537 | # @param trg Object to consider for inheriting.
|
---|
| 538 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
---|
[1414] | 539 | # @param load_function Load function for stuff that needs
|
---|
[1407] | 540 | # @param properties List of the properties with straight expansion.
|
---|
| 541 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
| 542 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
| 543 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
| 544 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
| 545 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
[985] | 546 | define def_inherit
|
---|
[1414] | 547 |
|
---|
[1496] | 548 | # Load it - loading is a mess, fix.
|
---|
[1414] | 549 | ifneq ($(load_function),)
|
---|
[1496] | 550 | local loading := $(patsubst $(src_prefix)%,%,$(trg))
|
---|
| 551 | $(evalvalctx $(load_function))
|
---|
[1414] | 552 | endif
|
---|
| 553 |
|
---|
[1496] | 554 | local src := $(strip $($(trg)_EXTENDS))
|
---|
[985] | 555 | ifneq ($(src),)
|
---|
| 556 | ifndef $(trg)_EXTENDS_STATUS_
|
---|
| 557 | $(trg)_EXTENDS_STATUS_ := 0
|
---|
[1414] | 558 |
|
---|
| 559 | # Load the source.
|
---|
| 560 | ifneq ($(load_function),)
|
---|
[1496] | 561 | local loading := $(src)
|
---|
| 562 | $(evalvalctx $(load_function))
|
---|
[1414] | 563 | endif
|
---|
| 564 |
|
---|
| 565 | # less typing.
|
---|
[1496] | 566 | local src := $(src_prefix)$(src)
|
---|
[185] | 567 |
|
---|
[985] | 568 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
---|
| 569 | ifdef $(src)_EXTENDS
|
---|
| 570 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
---|
| 571 | # 'foreach' will create 'trg' in a new variable context hiding
|
---|
[1502] | 572 | # out current variable. 'src' OTOH will be overwritten.
|
---|
[1496] | 573 | $(foreach trg, $(src), $(evalval def_inherit))
|
---|
| 574 | local src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
---|
[985] | 575 | endif
|
---|
| 576 | endif
|
---|
[984] | 577 |
|
---|
[1407] | 578 | # Get & check EXTENDS_BY.
|
---|
[1496] | 579 | local by = $(strip $($(trg)_EXTENDS_BY))
|
---|
[1407] | 580 | ifeq ($(by),)
|
---|
[1496] | 581 | local by = overriding
|
---|
[1407] | 582 | else ifn1of ($(by), overriding appending prepending)
|
---|
| 583 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
|
---|
| 584 | endif
|
---|
| 585 |
|
---|
| 586 | # Inherit the properties.
|
---|
[1413] | 587 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
|
---|
| 588 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
|
---|
| 589 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
|
---|
| 590 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
|
---|
| 591 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
|
---|
| 592 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
|
---|
[1407] | 593 |
|
---|
| 594 | # Mark the target as done.
|
---|
[985] | 595 | $(trg)_EXTENDS_STATUS_ := 42
|
---|
| 596 | else
|
---|
| 597 | # Check for inheritance loops.
|
---|
[1266] | 598 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
| 599 | $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
|
---|
[985] | 600 | endif
|
---|
| 601 | endif
|
---|
| 602 | endif
|
---|
[984] | 603 |
|
---|
[1413] | 604 | # Keyword inheritance.
|
---|
[1496] | 605 | $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
|
---|
[985] | 606 |
|
---|
[1413] | 607 | endef # def_inherit
|
---|
[1399] | 608 |
|
---|
| 609 |
|
---|
[984] | 610 | #
|
---|
[985] | 611 | # Determin all the templates that is being used and make
|
---|
[1415] | 612 | # sure they are present before we try collect keywords.
|
---|
[72] | 613 | #
|
---|
| 614 | _TEMPLATES := $(TEMPLATE)
|
---|
| 615 | define def_templates
|
---|
| 616 | ifdef $(target)_TEMPLATE
|
---|
[985] | 617 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
| 618 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
---|
| 619 | endif
|
---|
| 620 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
[72] | 621 | endif
|
---|
[985] | 622 | endef # def_templates
|
---|
[984] | 623 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
---|
[72] | 624 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 625 |
|
---|
[1417] | 626 | ## Template load function.
|
---|
| 627 | # @param loading The template name. This is prefixed.
|
---|
| 628 | define def_templates_load_function
|
---|
| 629 | ifndef TEMPLATE_$(loading)
|
---|
| 630 | TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
[1496] | 631 | ifeq ($(TEMPLATE_$(loading)_KMK_FILE),)
|
---|
[1417] | 632 | $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS))
|
---|
[985] | 633 | endif
|
---|
[1417] | 634 | include $(TEMPLATE_$(loading)_KMK_FILE)
|
---|
| 635 | ifndef TEMPLATE_$(loading)
|
---|
| 636 | $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
|
---|
| 637 | endif
|
---|
[72] | 638 | endif
|
---|
[1456] | 639 | endef # def_templates_load_function
|
---|
[1496] | 640 | $(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function))
|
---|
[72] | 641 |
|
---|
[74] | 642 |
|
---|
[72] | 643 | #
|
---|
[1415] | 644 | # Determin the keywords required for correct inherting and setup keyword inheritance.
|
---|
[412] | 645 | #
|
---|
[1415] | 646 | # This means walking all the lists of immediate template and targets and
|
---|
| 647 | # pick up all the BLD_T* keywords. Since templates that are referenced
|
---|
| 648 | # indirectly in the inheritance hierarchy, the result from this exercise
|
---|
| 649 | # might not be 100% accurate... :-/
|
---|
[985] | 650 | #
|
---|
| 651 | _BLD_TYPES := $(BUILD_TYPE)
|
---|
| 652 | _BLD_TARGETS := $(BUILD_TARGET) $(BUILD_PLATFORMS)
|
---|
| 653 | _BLD_ARCHES := $(BUILD_TARGET_ARCH) $(BUILD_PLATFORM_ARCH)
|
---|
| 654 | _BLD_CPUS := $(BUILD_TARGET_CPU) $(BUILD_PLATFORM_CPU)
|
---|
| 655 |
|
---|
| 656 | define def_collect_bld_xyz
|
---|
[1410] | 657 | ifdef $(src)_BLD_TYPE
|
---|
| 658 | ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
| 659 | $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
|
---|
| 660 | endif
|
---|
[1394] | 661 | _BLD_TYPES += $($(src)_BLD_TYPE)
|
---|
[412] | 662 | endif
|
---|
[1410] | 663 | ifdef $(src)_BLD_TRG
|
---|
| 664 | ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
|
---|
| 665 | $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
|
---|
| 666 | endif
|
---|
[985] | 667 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
---|
| 668 | endif
|
---|
[1410] | 669 | ifdef $(src)_BLD_TRG_ARCH
|
---|
| 670 | ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
|
---|
| 671 | $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
|
---|
| 672 | endif
|
---|
[985] | 673 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
---|
| 674 | endif
|
---|
[1410] | 675 | ifdef $(src)_BLD_TRG_CPU
|
---|
| 676 | if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
|
---|
| 677 | $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
|
---|
| 678 | endif
|
---|
[1394] | 679 | _BLD_CPUS += $($(src)_BLD_TRG_CPU)
|
---|
[985] | 680 | endif
|
---|
| 681 | endef # def_collect_bld_xyz
|
---|
[1410] | 682 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
|
---|
[1496] | 683 | ,$(evalval def_collect_bld_xyz))
|
---|
[412] | 684 |
|
---|
[1410] | 685 | # Drop duplicate values.
|
---|
[1413] | 686 | # WARNING! These list might not include keywords only involved in inheritance.
|
---|
[985] | 687 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
---|
| 688 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
---|
| 689 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
---|
| 690 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
---|
[552] | 691 |
|
---|
[1413] | 692 | ## Look for keywords which extends others and order them.
|
---|
| 693 | # @param keyword
|
---|
| 694 | # @param prefix
|
---|
| 695 | # @param valid
|
---|
[1410] | 696 | define def_keyword_ordering
|
---|
[1413] | 697 | # Check for EXTENDS, fix and validate it if found.
|
---|
[1496] | 698 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
[1410] | 699 | ifneq ($(src),)
|
---|
| 700 | ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
|
---|
| 701 | ifn1of ($(src), $(valid))
|
---|
| 702 | $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
|
---|
| 703 | endif
|
---|
| 704 |
|
---|
[1413] | 705 | # Recursivly process the parent (src).
|
---|
[1410] | 706 | ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
|
---|
[1413] | 707 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
|
---|
| 708 | # 'foreach' will create 'keyword' in a new variable context hiding
|
---|
| 709 | # out current variable. 'src' OTOH will be overwritten.
|
---|
[1496] | 710 | $(foreach keyword, $(src), $(evalval def_keyword_ordering))
|
---|
| 711 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
[1410] | 712 | endif
|
---|
| 713 |
|
---|
[1413] | 714 | # Check and strip EXTENDS_BY.
|
---|
[1496] | 715 | local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
|
---|
[1410] | 716 | ifeq ($(by),)
|
---|
[1496] | 717 | local by = overriding
|
---|
[1410] | 718 | else ifn1of ($(by), overriding appending prepending)
|
---|
| 719 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
|
---|
| 720 | endif
|
---|
| 721 |
|
---|
[1413] | 722 | # Update the attributes with stripped
|
---|
| 723 | $(prefix)_$(keyword)_EXTENDS_BY := $(by)
|
---|
| 724 | $(prefix)_$(keyword)_EXTENDS := $(src)
|
---|
| 725 |
|
---|
[1410] | 726 | # Add it to the list and mark it as done.
|
---|
[1413] | 727 | _KEYWORDS_EXTENDS += $(keyword)
|
---|
| 728 | _KEYWORDS_PREFIX += $(prefix)
|
---|
[1410] | 729 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
|
---|
| 730 | else
|
---|
| 731 | # Check for inheritance loops.
|
---|
| 732 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
| 733 | $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
|
---|
| 734 | endif
|
---|
| 735 | endif
|
---|
[1413] | 736 | else
|
---|
| 737 | # Add it to the ordered list and mark it as done.
|
---|
| 738 | _KEYWORDS_ORDERED += $(keyword)
|
---|
| 739 | $(prefix)_$(src)_EXTENDS_STATUS_ := 42
|
---|
[1410] | 740 | endif
|
---|
[1413] | 741 | endef # def_keyword_ordering
|
---|
[1410] | 742 |
|
---|
[1413] | 743 | # Look for keywords which extends others and their parents, and from this
|
---|
| 744 | # construct two lists.
|
---|
| 745 | _KEYWORDS_ORDERED :=
|
---|
| 746 | _KEYWORDS_EXTENDS :=
|
---|
| 747 | _KEYWORDS_PREFIX :=
|
---|
[1410] | 748 |
|
---|
| 749 | prefix := BLD_TYPE
|
---|
| 750 | valid := $(KBUILD_BLD_TYPES)
|
---|
[1496] | 751 | $(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
|
---|
[1410] | 752 |
|
---|
[1413] | 753 | prefix := BLD_TRG
|
---|
| 754 | valid := $(KBUILD_OSES)
|
---|
[1496] | 755 | $(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
|
---|
[1413] | 756 |
|
---|
[1410] | 757 | prefix := BLD_ARCH
|
---|
| 758 | valid := $(KBUILD_ARCHES)
|
---|
[1496] | 759 | $(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
|
---|
[1410] | 760 |
|
---|
| 761 | prefix := BLD_CPU
|
---|
| 762 | valid := $(KBUILD_CPUS)
|
---|
[1496] | 763 | $(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering))
|
---|
[1410] | 764 |
|
---|
[1413] | 765 | ## @todo Inherit bld_trg.bld_arch for too?
|
---|
[1410] | 766 |
|
---|
[1413] | 767 | # Construct all the possible keywords.
|
---|
| 768 | _KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
|
---|
| 769 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
---|
| 770 |
|
---|
[988] | 771 | ifdef KBUILD_PROFILE_SELF
|
---|
| 772 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 773 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done keywords)
|
---|
[1441] | 774 | $(info stat: $(make-stats ))
|
---|
[988] | 775 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 776 | endif
|
---|
[552] | 777 |
|
---|
[988] | 778 |
|
---|
[985] | 779 | #
|
---|
| 780 | # Target inheritance.
|
---|
| 781 | #
|
---|
| 782 | # This has to be done on a per target list basis as to avoid adding
|
---|
| 783 | # incorrect properties that will wast memory, time, and may confuse
|
---|
| 784 | # later strictness checks. This also has to be done *before* templates
|
---|
| 785 | # are applied to the targets. Since we're doing that part rather
|
---|
| 786 | # early on, the target inheritance feature is a bit restricted at
|
---|
| 787 | # the moment. However, this will be addressed in a little(?) while.
|
---|
| 788 | #
|
---|
[552] | 789 |
|
---|
[985] | 790 | src_prefix :=
|
---|
[1414] | 791 | load_function :=
|
---|
[1407] | 792 | properties_deferred_l :=
|
---|
| 793 | properties_deferred_r :=
|
---|
| 794 |
|
---|
[985] | 795 | # Fetches.
|
---|
[1413] | 796 | properties := $(PROPS_FETCHES_SINGLE)
|
---|
| 797 | properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
|
---|
| 798 | properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
|
---|
| 799 | properties_deferred := $(PROPS_FETCHES_DEFERRED)
|
---|
[1496] | 800 | $(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit))
|
---|
[412] | 801 |
|
---|
[985] | 802 | ## Patches. - not implemented yet.
|
---|
[1413] | 803 | #properties := $(PROPS_PATCHES_SINGLE)
|
---|
| 804 | #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
|
---|
| 805 | #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
|
---|
| 806 | #properties_deferred := $(PROPS_PATCHES_DEFERRED)
|
---|
[1496] | 807 | #$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit))
|
---|
[412] | 808 |
|
---|
[985] | 809 | # Programs and build programs.
|
---|
[1413] | 810 | properties := $(PROPS_PROGRAMS_SINGLE)
|
---|
| 811 | properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
|
---|
| 812 | properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
|
---|
| 813 | properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
|
---|
[1496] | 814 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit))
|
---|
[985] | 815 |
|
---|
| 816 | # Libraries and import libraries.
|
---|
[1413] | 817 | properties := $(PROPS_LIBRARIES_SINGLE)
|
---|
| 818 | properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
|
---|
| 819 | properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
|
---|
| 820 | properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
|
---|
[1407] | 821 | if1of ($(BUILD_TARGET), nt os2 win)
|
---|
[1496] | 822 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
[989] | 823 | else
|
---|
[1496] | 824 | $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
|
---|
[989] | 825 | endif
|
---|
[985] | 826 |
|
---|
| 827 | # DLLs.
|
---|
[1413] | 828 | properties := $(PROPS_DLLS_SINGLE)
|
---|
| 829 | properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
|
---|
| 830 | properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
|
---|
| 831 | properties_deferred := $(PROPS_DLLS_DEFERRED)
|
---|
[1407] | 832 | if1of ($(BUILD_TARGET), nt os2 win)
|
---|
[1496] | 833 | $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit))
|
---|
[989] | 834 | else
|
---|
[1496] | 835 | $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
[989] | 836 | endif
|
---|
[985] | 837 |
|
---|
[989] | 838 | # System modules.
|
---|
[1413] | 839 | properties := $(PROPS_SYSMODS_SINGLE)
|
---|
| 840 | properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
|
---|
| 841 | properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
|
---|
| 842 | properties_deferred := $(PROPS_SYSMODS_DEFERRED)
|
---|
[1496] | 843 | $(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit))
|
---|
[989] | 844 |
|
---|
[985] | 845 | # Installs.
|
---|
[1413] | 846 | properties := $(PROPS_INSTALLS_SINGLE)
|
---|
| 847 | properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
|
---|
| 848 | properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
|
---|
| 849 | properties_deferred := $(PROPS_INSTALLS_DEFERRED)
|
---|
[1496] | 850 | $(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit))
|
---|
[985] | 851 |
|
---|
[988] | 852 | ifdef KBUILD_PROFILE_SELF
|
---|
| 853 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 854 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done target inheritance)
|
---|
[1441] | 855 | $(info stat: $(make-stats ))
|
---|
[988] | 856 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 857 | endif
|
---|
[985] | 858 |
|
---|
[988] | 859 |
|
---|
[412] | 860 | #
|
---|
[985] | 861 | # Template Inheritance.
|
---|
| 862 | #
|
---|
| 863 | # This is much the same as with target inheritance, except we cannot
|
---|
[1370] | 864 | # restrict the properties involved since we haven't got a clue which
|
---|
| 865 | # target platforms/archs are using them. But, we can drop the instance
|
---|
| 866 | # expansion we're doing for targets since there won't be any more
|
---|
| 867 | # changes to either the source nor the target templates beyond this
|
---|
| 868 | # exercise.
|
---|
[985] | 869 | #
|
---|
| 870 |
|
---|
| 871 | src_prefix := TEMPLATE_
|
---|
[1417] | 872 | load_function := def_templates_load_function
|
---|
[985] | 873 | properties :=
|
---|
[1407] | 874 | properties_now_l :=
|
---|
| 875 | properties_now_r :=
|
---|
[1413] | 876 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
| 877 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
| 878 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
[1496] | 879 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit))
|
---|
[985] | 880 |
|
---|
[1407] | 881 | # done inheriting.
|
---|
| 882 | src_prefix :=
|
---|
[1414] | 883 | load_function :=
|
---|
[1407] | 884 | properties :=
|
---|
| 885 | properties_now_l :=
|
---|
| 886 | properties_now_r :=
|
---|
| 887 | properties_deferred :=
|
---|
| 888 | properties_deferred_l :=
|
---|
| 889 | properties_deferred_r :=
|
---|
| 890 |
|
---|
[1414] | 891 | ifdef KBUILD_PROFILE_SELF
|
---|
| 892 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 893 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template inheritance)
|
---|
[1441] | 894 | $(info stat: $(make-stats ))
|
---|
[1414] | 895 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 896 | endif
|
---|
[1407] | 897 |
|
---|
[1414] | 898 |
|
---|
| 899 |
|
---|
| 900 |
|
---|
[985] | 901 | #
|
---|
[1399] | 902 | # Template/Target Expansion.
|
---|
[72] | 903 | #
|
---|
[1399] | 904 | # Extend all targets with the values from the template. Doing this up front
|
---|
| 905 | # allows more generic code and less mess down in the pass 2 target handling.
|
---|
| 906 | # However it does eat a good deal of memory.
|
---|
| 907 | #
|
---|
[72] | 908 |
|
---|
[353] | 909 | ## Inherit one template property in a non-accumulative manner.
|
---|
[72] | 910 | # @param $(prop) Property name
|
---|
| 911 | # @param $(target) Target name
|
---|
[78] | 912 | # @todo fix the precedence order for some properties.
|
---|
[72] | 913 | define def_inherit_template_one
|
---|
[78] | 914 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 915 | ifndef $(target)_$(prop)
|
---|
[353] | 916 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[72] | 917 | endif
|
---|
| 918 | endif
|
---|
[447] | 919 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 920 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 921 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 922 | endif
|
---|
| 923 | endif
|
---|
[481] | 924 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 925 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 926 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 927 | endif
|
---|
| 928 | endif
|
---|
[455] | 929 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 930 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 931 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 932 | endif
|
---|
| 933 | endif
|
---|
| 934 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 935 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 936 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 937 | endif
|
---|
| 938 | endif
|
---|
[72] | 939 | endef
|
---|
| 940 |
|
---|
[353] | 941 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 942 | # @param 1: $(prop) Property name
|
---|
| 943 | # @param 2: $(target) Target name
|
---|
| 944 | # @todo fix the precedence order for some properties.
|
---|
| 945 | # @remark this define relies on double evaluation
|
---|
| 946 | define def_inherit_template_one_deferred
|
---|
| 947 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 948 | ifndef $(target)_$(prop)
|
---|
| 949 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 950 | endif
|
---|
| 951 | endif
|
---|
[447] | 952 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 953 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 954 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[353] | 955 | endif
|
---|
| 956 | endif
|
---|
[481] | 957 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 958 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 959 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 960 | endif
|
---|
| 961 | endif
|
---|
[455] | 962 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 963 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 964 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 965 | endif
|
---|
| 966 | endif
|
---|
| 967 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 968 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 969 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 970 | endif
|
---|
| 971 | endif
|
---|
[353] | 972 | endef
|
---|
| 973 |
|
---|
[660] | 974 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
---|
[78] | 975 | # @param $(prop) Property name
|
---|
| 976 | # @param $(target) Target name
|
---|
[660] | 977 | define def_inherit_template_one_accumulate_l
|
---|
[78] | 978 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[659] | 979 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[78] | 980 | endif
|
---|
[243] | 981 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[659] | 982 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[243] | 983 | endif
|
---|
[447] | 984 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[659] | 985 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 986 | endif
|
---|
[481] | 987 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
[659] | 988 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[481] | 989 | endif
|
---|
[447] | 990 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
[659] | 991 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[79] | 992 | endif
|
---|
[447] | 993 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
[659] | 994 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[79] | 995 | endif
|
---|
[78] | 996 | endef
|
---|
| 997 |
|
---|
[660] | 998 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
---|
| 999 | # @param $(prop) Property name
|
---|
| 1000 | # @param $(target) Target name
|
---|
[981] | 1001 | define def_inherit_template_one_accumulate_r
|
---|
[660] | 1002 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[981] | 1003 | $(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[660] | 1004 | endif
|
---|
| 1005 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[981] | 1006 | $(target)_$(prop).$(BUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[660] | 1007 | endif
|
---|
| 1008 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[981] | 1009 | $(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[660] | 1010 | endif
|
---|
| 1011 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
[981] | 1012 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[660] | 1013 | endif
|
---|
| 1014 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
[981] | 1015 | $(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[660] | 1016 | endif
|
---|
| 1017 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
[981] | 1018 | $(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[660] | 1019 | endif
|
---|
| 1020 | endef
|
---|
| 1021 |
|
---|
| 1022 |
|
---|
[72] | 1023 | ## Inherit template properties for on target.
|
---|
| 1024 | # @param $(target) Target name.
|
---|
| 1025 | define def_inherit_template
|
---|
[745] | 1026 | # sanity check.
|
---|
| 1027 | ifdef _$(target)_ALREADY_PROCESSED
|
---|
| 1028 | $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
|
---|
| 1029 | endif
|
---|
| 1030 | _$(target)_ALREADY_PROCESSED := 1
|
---|
| 1031 |
|
---|
[447] | 1032 | # Inherit any default template.
|
---|
| 1033 | ifdef TEMPLATE
|
---|
| 1034 | ifeq ($($(target)_TEMPLATE),)
|
---|
| 1035 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
| 1036 | endif
|
---|
| 1037 | endif
|
---|
| 1038 | # Expand the template if specified.
|
---|
| 1039 | ifneq ($($(target)_TEMPLATE),)
|
---|
[1496] | 1040 | $(foreach prop,$(PROPS_SINGLE),$(evalval def_inherit_template_one))
|
---|
[353] | 1041 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
[981] | 1042 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine without value
|
---|
| 1043 | $(foreach prop,$(PROPS_ACCUMULATE_R),$(eval $(def_inherit_template_one_accumulate_r))) # use <= (kmk addition)
|
---|
[447] | 1044 | endif
|
---|
[72] | 1045 | endef
|
---|
[353] | 1046 |
|
---|
[72] | 1047 | # Inherit template properties
|
---|
[447] | 1048 | bld_trg := $(BUILD_TARGET)
|
---|
| 1049 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 1050 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
[1496] | 1051 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(evalval def_inherit_template))
|
---|
[72] | 1052 |
|
---|
[447] | 1053 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 1054 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 1055 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
[1496] | 1056 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(evalval def_inherit_template))
|
---|
[72] | 1057 |
|
---|
[988] | 1058 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1059 | _KBUILD_TS_NOW := $(nanots )
|
---|
[1413] | 1060 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template/target expansion)
|
---|
[1441] | 1061 | $(info stat: $(make-stats ))
|
---|
[988] | 1062 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1063 | endif
|
---|
[447] | 1064 |
|
---|
[988] | 1065 |
|
---|
[72] | 1066 | #
|
---|
[460] | 1067 | # Include tools & sdks
|
---|
[183] | 1068 | #
|
---|
[985] | 1069 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
---|
| 1070 | # that should be included.
|
---|
| 1071 | #
|
---|
[592] | 1072 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 1073 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 1074 | $(TOOL)
|
---|
| 1075 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 1076 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 1077 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1078 | $(SDKS)
|
---|
[460] | 1079 | define def_tools_sdks_target_source
|
---|
[353] | 1080 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 1081 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
| 1082 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
[481] | 1083 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 1084 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 1085 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
| 1086 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
[353] | 1087 | $($(source)_$(prop)) \
|
---|
| 1088 | $($(target)_$(source)_$(prop))))
|
---|
[460] | 1089 | $(eval _SDKS += \
|
---|
| 1090 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
| 1091 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
[481] | 1092 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 1093 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 1094 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
| 1095 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
[592] | 1096 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1097 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
[460] | 1098 | $($(source)_SDKS) \
|
---|
| 1099 | $($(target)_$(source)_SDKS))
|
---|
[985] | 1100 | endef # def_tools_sdks_target_source
|
---|
[353] | 1101 |
|
---|
[460] | 1102 | define def_tools_sdks_target
|
---|
[1496] | 1103 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1104 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 1105 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 1106 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
[460] | 1107 |
|
---|
[353] | 1108 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 1109 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
| 1110 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
[481] | 1111 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[353] | 1112 | $($(target)_$(prop))))
|
---|
[460] | 1113 | $(eval _SDKS += \
|
---|
| 1114 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
| 1115 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
[481] | 1116 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 1117 | $($(target)_SDKS))
|
---|
[353] | 1118 | $(foreach source, \
|
---|
[460] | 1119 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 1120 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
[481] | 1121 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 1122 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
[985] | 1123 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
[353] | 1124 | $($(target)_SOURCES) \
|
---|
[1496] | 1125 | , $(evalval def_tools_sdks_target_source))
|
---|
[985] | 1126 | endef # def_tools_sdks_target
|
---|
[353] | 1127 |
|
---|
[640] | 1128 | define def_tools_srcname_target
|
---|
[1496] | 1129 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1130 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 1131 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 1132 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
[640] | 1133 |
|
---|
| 1134 | $(foreach source, $(notdir\
|
---|
| 1135 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 1136 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
| 1137 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 1138 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
[985] | 1139 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
[640] | 1140 | $($(target)_SOURCES) \
|
---|
[1496] | 1141 | ), $(evalval def_tools_sdks_target_source))
|
---|
[985] | 1142 | endef # def_tools_srcname_target
|
---|
[640] | 1143 |
|
---|
[460] | 1144 | bld_trg := $(BUILD_TARGET)
|
---|
| 1145 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 1146 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
[1496] | 1147 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(evalval def_tools_sdks_target))
|
---|
| 1148 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target))
|
---|
[72] | 1149 |
|
---|
[460] | 1150 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 1151 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 1152 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
[1496] | 1153 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(evalval def_tools_sdks_target))
|
---|
[460] | 1154 |
|
---|
[1414] | 1155 | _TOOLS := $(sort $(_TOOLS))
|
---|
| 1156 | _SDKS := $(sort $(_SDKS))
|
---|
[460] | 1157 |
|
---|
[1414] | 1158 | ## Tool load function.
|
---|
| 1159 | # @param loading The tool name
|
---|
| 1160 | define def_tools_load_function
|
---|
| 1161 | ifndef TOOL_$(loading)
|
---|
[1416] | 1162 | TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
[1414] | 1163 | ifeq ($(TOOL_$(loading)_KMK_FILE),)
|
---|
[1416] | 1164 | $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS))
|
---|
[985] | 1165 | endif
|
---|
[1414] | 1166 | include $(TOOL_$(loading)_KMK_FILE)
|
---|
| 1167 | ifndef TOOL_$(loading)
|
---|
| 1168 | $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
|
---|
[985] | 1169 | endif
|
---|
[72] | 1170 | endif
|
---|
[985] | 1171 | endef # def_tools_include
|
---|
[460] | 1172 |
|
---|
[1414] | 1173 | ## SDK load function.
|
---|
| 1174 | # @param loading The tool name
|
---|
| 1175 | define def_sdk_load_function
|
---|
| 1176 | ifndef SDK_$(loading)
|
---|
[1416] | 1177 | SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
[1414] | 1178 | ifeq ($(SDK_$(loading)_KMK_FILE),)
|
---|
[1416] | 1179 | $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS))
|
---|
[985] | 1180 | endif
|
---|
[1414] | 1181 | include $(SDK_$(loading)_KMK_FILE)
|
---|
| 1182 | ifndef SDK_$(loading)
|
---|
| 1183 | $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
|
---|
[985] | 1184 | endif
|
---|
[72] | 1185 | endif
|
---|
[1414] | 1186 | endef # def_sdk_load_function
|
---|
[460] | 1187 |
|
---|
[72] | 1188 |
|
---|
[1414] | 1189 | properties :=
|
---|
| 1190 | properties_now_l :=
|
---|
| 1191 | properties_now_r :=
|
---|
| 1192 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
| 1193 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
| 1194 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
[380] | 1195 |
|
---|
[1414] | 1196 | src_prefix := TOOL_
|
---|
| 1197 | load_function := def_tools_load_function
|
---|
[1496] | 1198 | $(foreach trg, $(_TOOLS), $(evalval def_inherit))
|
---|
[1414] | 1199 |
|
---|
| 1200 | src_prefix := SDK_
|
---|
| 1201 | load_function := def_sdk_load_function
|
---|
[1496] | 1202 | $(foreach trg, $(_SDKS) , $(evalval def_inherit))
|
---|
[1414] | 1203 |
|
---|
| 1204 | # done inheriting.
|
---|
| 1205 | src_prefix :=
|
---|
| 1206 | load_function :=
|
---|
| 1207 | properties :=
|
---|
| 1208 | properties_now_l :=
|
---|
| 1209 | properties_now_r :=
|
---|
| 1210 | properties_deferred :=
|
---|
| 1211 | properties_deferred_l :=
|
---|
| 1212 | properties_deferred_r :=
|
---|
| 1213 |
|
---|
| 1214 |
|
---|
[988] | 1215 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1216 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 1217 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done tools and sdks)
|
---|
[1441] | 1218 | $(info stat: $(make-stats ))
|
---|
[988] | 1219 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1220 | endif
|
---|
[640] | 1221 |
|
---|
[988] | 1222 |
|
---|
[1414] | 1223 |
|
---|
[828] | 1224 | #
|
---|
| 1225 | #
|
---|
| 1226 | # Target lists - Pass 1
|
---|
| 1227 | #
|
---|
| 1228 | # This pass is for defining variables that might be referenced in
|
---|
| 1229 | # properties of other targets.
|
---|
| 1230 | #
|
---|
| 1231 | #
|
---|
| 1232 |
|
---|
| 1233 | # Don't do anything for fetch targets (yet).
|
---|
| 1234 |
|
---|
| 1235 | ##
|
---|
| 1236 | # Link prolog for Pass 1.
|
---|
| 1237 | #
|
---|
| 1238 | # @param $(target) Normalized target name.
|
---|
| 1239 | # @param $(EXT) EXE,DLL,SYS,LIB.
|
---|
| 1240 | # @param $(EXTPRE) HOST or nothing.
|
---|
| 1241 | # @param $(definst) The default _INST value.
|
---|
| 1242 | # @param $(tool_prefix) LD or AR.
|
---|
| 1243 | # @param $(bld_trg_base_var) TARGET or PLATFORM.
|
---|
| 1244 | define def_pass1_link_common
|
---|
| 1245 |
|
---|
[1496] | 1246 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1247 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 1248 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 1249 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[828] | 1250 |
|
---|
[1496] | 1251 | local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
|
---|
| 1252 | local name := $(firstword\
|
---|
[889] | 1253 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1254 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 1255 | $($(target)_NAME.$(bld_trg))\
|
---|
| 1256 | $($(target)_NAME.$(bld_type))\
|
---|
| 1257 | $($(target)_NAME)\
|
---|
| 1258 | $(target))
|
---|
[1496] | 1259 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[828] | 1260 | ifndef PATH_$(target)
|
---|
| 1261 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1262 | else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1263 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1264 | endif
|
---|
| 1265 | ifeq ($(tool_prefix),AR) ## @todo fix this mess!
|
---|
[1496] | 1266 | local suff := $(firstword\
|
---|
[828] | 1267 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1268 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
---|
| 1269 | $($(target)_$(EXT)SUFF)\
|
---|
| 1270 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1271 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
|
---|
| 1272 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
|
---|
| 1273 | $(SUFF_LIB))
|
---|
| 1274 | else
|
---|
[1496] | 1275 | local suff := $(firstword \
|
---|
[828] | 1276 | $($(target)_$(EXT)SUFF) \
|
---|
| 1277 | $($(target)_$(EXT)SUFF) \
|
---|
| 1278 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF) \
|
---|
| 1279 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 1280 | endif
|
---|
[1496] | 1281 | local out := $(outbase)$(suff)
|
---|
[828] | 1282 |
|
---|
| 1283 | # TARGET_*
|
---|
| 1284 | TARGET_$(target) := $(out)
|
---|
| 1285 |
|
---|
| 1286 | # INSTARGET_*
|
---|
| 1287 | ifndef $(target)_NOINST
|
---|
| 1288 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1289 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 1290 |
|
---|
| 1291 | else # NOINST
|
---|
| 1292 | INSTARGET_$(target) :=
|
---|
| 1293 | endif # NOINST
|
---|
| 1294 |
|
---|
| 1295 | endef
|
---|
| 1296 |
|
---|
| 1297 |
|
---|
| 1298 | #
|
---|
| 1299 | # BLDPROGS (Pass 1)
|
---|
| 1300 | #
|
---|
| 1301 | define def_pass1_bldprog
|
---|
| 1302 | # set NOINST if not forced installation before doing the usual stuff.
|
---|
| 1303 | ifndef $(target)_INST
|
---|
| 1304 | $(target)_NOINST := 1
|
---|
| 1305 | endif
|
---|
[1496] | 1306 | $(evalval def_pass1_link_common)
|
---|
[828] | 1307 | endef
|
---|
| 1308 |
|
---|
| 1309 | EXT := EXE
|
---|
| 1310 | EXTPRE := HOST
|
---|
| 1311 | definst := $(PATH_BIN)
|
---|
| 1312 | tool_prefix := LD
|
---|
| 1313 | bld_trg_base_var := PLATFORM
|
---|
| 1314 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), \
|
---|
[1496] | 1315 | $(evalval def_pass1_bldprog))
|
---|
[828] | 1316 |
|
---|
| 1317 |
|
---|
| 1318 | #
|
---|
| 1319 | # LIBRARIES (Pass 1)
|
---|
| 1320 | #
|
---|
| 1321 | EXT := LIB
|
---|
| 1322 | EXTPRE :=
|
---|
| 1323 | definst := $(PATH_LIB)
|
---|
| 1324 | tool_prefix := AR
|
---|
| 1325 | bld_trg_base_var := TARGET
|
---|
| 1326 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1327 | $(evalval def_pass1_link_common))
|
---|
[828] | 1328 |
|
---|
| 1329 |
|
---|
| 1330 | #
|
---|
| 1331 | # DLLS (Pass 1)
|
---|
| 1332 | #
|
---|
| 1333 | EXT := DLL
|
---|
| 1334 | EXTPRE :=
|
---|
| 1335 | definst := $(PATH_DLL)
|
---|
| 1336 | tool_prefix := LD
|
---|
| 1337 | bld_trg_base_var := TARGET
|
---|
| 1338 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1339 | $(evalval def_pass1_link_common))
|
---|
[828] | 1340 |
|
---|
| 1341 |
|
---|
| 1342 | #
|
---|
| 1343 | # IMPORT LIBRARIES (Pass 1)
|
---|
| 1344 | #
|
---|
| 1345 | # - On OS/2 and windows these are libraries.
|
---|
| 1346 | # - On other platforms they are fake DLLs.
|
---|
| 1347 | #
|
---|
[1260] | 1348 | if1of ($(BUILD_TARGET), nt os2 win win64 win32)
|
---|
[828] | 1349 | EXT := LIB
|
---|
| 1350 | EXTPRE :=
|
---|
| 1351 | definst := $(PATH_LIB)
|
---|
| 1352 | tool_prefix := AR
|
---|
| 1353 | bld_trg_base_var := TARGET
|
---|
| 1354 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1355 | $(evalval def_pass1_link_common))
|
---|
[828] | 1356 | else
|
---|
| 1357 | EXT := DLL
|
---|
| 1358 | EXTPRE :=
|
---|
| 1359 | definst := $(PATH_DLL)
|
---|
| 1360 | tool_prefix := LD
|
---|
| 1361 | bld_trg_base_var := TARGET
|
---|
| 1362 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1363 | $(evalval def_pass1_link_common))
|
---|
[828] | 1364 | endif
|
---|
| 1365 |
|
---|
| 1366 |
|
---|
| 1367 | #
|
---|
| 1368 | # PROGRAMS (Pass 1)
|
---|
| 1369 | #
|
---|
| 1370 | EXT := EXE
|
---|
| 1371 | EXTPRE :=
|
---|
| 1372 | definst := $(PATH_BIN)
|
---|
| 1373 | tool_prefix := LD
|
---|
| 1374 | bld_trg_base_var := TARGET
|
---|
| 1375 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1376 | $(evalval def_pass1_link_common))
|
---|
[828] | 1377 |
|
---|
| 1378 |
|
---|
| 1379 | #
|
---|
| 1380 | # SYSMODS (Pass 1)
|
---|
| 1381 | #
|
---|
| 1382 | EXT := SYS
|
---|
| 1383 | EXTPRE :=
|
---|
| 1384 | definst := $(PATH_SYS)
|
---|
| 1385 | tool_prefix := LD
|
---|
| 1386 | bld_trg_base_var := TARGET
|
---|
| 1387 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1388 | $(evalval def_pass1_link_common))
|
---|
[828] | 1389 |
|
---|
| 1390 |
|
---|
| 1391 | #
|
---|
| 1392 | # INSTALLS (Pass 1)
|
---|
| 1393 | # Note! INSTARGET_* for INSTALLS aren't available until later.
|
---|
| 1394 | #
|
---|
| 1395 | define def_pass1_install
|
---|
[1496] | 1396 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1397 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 1398 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 1399 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
[828] | 1400 | # TARGET_*
|
---|
| 1401 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
| 1402 | # INSTARGET_ later.
|
---|
| 1403 | endef
|
---|
| 1404 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1405 | $(evalval def_pass1_install))
|
---|
[828] | 1406 |
|
---|
[988] | 1407 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1408 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 1409 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done pass 1)
|
---|
[1441] | 1410 | $(info stat: $(make-stats ))
|
---|
[988] | 1411 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1412 | endif
|
---|
[828] | 1413 |
|
---|
| 1414 |
|
---|
| 1415 |
|
---|
[988] | 1416 |
|
---|
[828] | 1417 | #
|
---|
| 1418 | #
|
---|
| 1419 | # Target lists - Pass 2
|
---|
| 1420 | #
|
---|
| 1421 | #
|
---|
| 1422 |
|
---|
| 1423 |
|
---|
[688] | 1424 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
---|
[73] | 1425 | #
|
---|
[688] | 1426 | # The targets listed in the the FETCHES target list have the following attributes:
|
---|
| 1427 | # SOURCES
|
---|
| 1428 | # INST
|
---|
| 1429 | # FETCHTOOL
|
---|
| 1430 | # FETCHFLAGS
|
---|
| 1431 | # FETCHDIR
|
---|
| 1432 | # UNPACKTOOL
|
---|
| 1433 | # UNPACKFLAGS
|
---|
[640] | 1434 | #
|
---|
[719] | 1435 | # As usual the target name is an alias for 'creating' the target. Other
|
---|
[688] | 1436 | # aliases are:
|
---|
| 1437 | # pass_fetches
|
---|
| 1438 | # fetch
|
---|
| 1439 | # unfetch
|
---|
| 1440 | # download
|
---|
| 1441 | # unpack
|
---|
| 1442 | #
|
---|
| 1443 | # @remark
|
---|
| 1444 | #
|
---|
| 1445 | # This is a little bit complex because we must guarantee that if a source file
|
---|
[719] | 1446 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
---|
| 1447 | # is also a desire that fetched archives and unpacked files can be deleted to
|
---|
[688] | 1448 | # save space.
|
---|
| 1449 | #
|
---|
[719] | 1450 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
---|
[688] | 1451 | # sources be removed. We do this by maintaining a file listing the files
|
---|
| 1452 | # and directories that was unpacked. This operation is named 'unfetch'.
|
---|
| 1453 | #
|
---|
[719] | 1454 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
---|
[689] | 1455 | # create a digest that is stored in the primary target file. Subsequent
|
---|
| 1456 | # runswill compare their digest with it to decide if a refetch is required.
|
---|
[719] | 1457 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
---|
[689] | 1458 | # clean out old files and directores. Note even changes in source order
|
---|
[719] | 1459 | # will cause a refetch due to the way the digest is constructed and
|
---|
[689] | 1460 | # evaluated.
|
---|
[688] | 1461 | #
|
---|
| 1462 | # By not depending directly on the archives (nor on any unpacked files)
|
---|
| 1463 | # but on a goal made up from the archive name, size and md5, we allow
|
---|
| 1464 | # the user to delete the archives. Naturally, this means we'll have to
|
---|
| 1465 | # check and fetch missing archives before attempting to unpack them.
|
---|
[689] | 1466 | #
|
---|
| 1467 | # @remark
|
---|
| 1468 | #
|
---|
[719] | 1469 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
---|
[689] | 1470 | # it makes use of includedep to avoid too many unnecessary files.
|
---|
[719] | 1471 | #
|
---|
[689] | 1472 | # @todo
|
---|
[1255] | 1473 | # 1. Download corruption / continuation.
|
---|
| 1474 | # 2. It's quite possible that there is one too many indirect dependency now...
|
---|
[688] | 1475 | #
|
---|
| 1476 |
|
---|
[640] | 1477 | ## generates the fetch rule
|
---|
| 1478 | define def_fetch_src_fetch_rule
|
---|
| 1479 | # Indirect goal for downloading something.
|
---|
[682] | 1480 | .PRECIOUS: $(out)
|
---|
[1030] | 1481 | $(out) + $($(target)_$(srcname)_FETCH_OUTPUT_) +| $($(target)_$(srcname)_FETCH_OUTPUT_MAYBE_) : \
|
---|
| 1482 | | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
[1496] | 1483 | %$$(call MSG_FETCH_DL,$(target),$(source),$(out))
|
---|
[696] | 1484 | @## @todo do fancy stuff like download continuation.
|
---|
[1255] | 1485 | $$(QUIET)$$(RM) -f $(out)
|
---|
[640] | 1486 | $($(target)_$(srcname)_FETCH_CMDS_)
|
---|
[1255] | 1487 | $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
|
---|
[640] | 1488 |
|
---|
| 1489 |
|
---|
[682] | 1490 |
|
---|
[640] | 1491 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
| 1492 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
[1496] | 1493 | %$$(call MSG_FETCH_CHK,$(target),$(source),$(out))
|
---|
[1255] | 1494 | $$(QUIET)$$(RM) -f $$@
|
---|
[688] | 1495 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
---|
[696] | 1496 | @## @todo do fancy stuff like download continuation.
|
---|
[1255] | 1497 | $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
|
---|
[696] | 1498 | || ( $$(RM_EXT) -f $(out) \
|
---|
| 1499 | && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
|
---|
| 1500 | $$(QUIET2)$$(APPEND) $$@
|
---|
[640] | 1501 |
|
---|
[719] | 1502 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
---|
[640] | 1503 |
|
---|
[688] | 1504 | # Just a little precaution.
|
---|
| 1505 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
---|
| 1506 |
|
---|
[640] | 1507 | endef
|
---|
| 1508 |
|
---|
| 1509 | ## generates the unpack rule
|
---|
| 1510 | define def_fetch_src_unpack_rule
|
---|
| 1511 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
[1030] | 1512 | $(out) + $($(target)_$(srcname)_UNPACK_OUTPUT_) +| $($(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_) : \
|
---|
| 1513 | $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
---|
[640] | 1514 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
---|
[1496] | 1515 | %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
|
---|
[696] | 1516 | $$(QUIET)$$(RM) -f $(out)
|
---|
[688] | 1517 | @# if the source archive doesn't exist fetch it (can have been deleted to save space).
|
---|
[696] | 1518 | $$(QUIET)test -f $(archive) \
|
---|
| 1519 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
---|
| 1520 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
|
---|
[640] | 1521 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
---|
[696] | 1522 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
---|
| 1523 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
|
---|
[640] | 1524 |
|
---|
| 1525 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
| 1526 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
| 1527 |
|
---|
[688] | 1528 | .NOTPARALLEL: $(out)
|
---|
| 1529 |
|
---|
[719] | 1530 | endef
|
---|
[640] | 1531 |
|
---|
| 1532 | ## Processes a fetch source
|
---|
| 1533 | #
|
---|
| 1534 | define def_fetch_src
|
---|
| 1535 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
| 1536 |
|
---|
| 1537 | # common
|
---|
[1496] | 1538 | local srcname := $(notdir $(source))
|
---|
| 1539 | local inst := $(firstword \
|
---|
[640] | 1540 | $($(target)_$(source)_INST)\
|
---|
| 1541 | $($(target)_$(srcname)_INST)\
|
---|
| 1542 | $($(source)_INST)\
|
---|
| 1543 | $($(srcname)_INST)\
|
---|
| 1544 | $($(target)_INST)\
|
---|
| 1545 | )
|
---|
| 1546 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
| 1547 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
| 1548 | endif
|
---|
| 1549 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
[1496] | 1550 | local fetchdir := $(firstword \
|
---|
[640] | 1551 | $($(target)_$(source)_FETCHDIR)\
|
---|
| 1552 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
| 1553 | $($(source)_FETCHDIR)\
|
---|
| 1554 | $($(srcname)_FETCHDIR)\
|
---|
| 1555 | $($(target)_FETCHDIR)\
|
---|
| 1556 | $(FETCHDIR)\
|
---|
| 1557 | $(PATH_TARGET)\
|
---|
| 1558 | )
|
---|
[1496] | 1559 | local deps := \
|
---|
[640] | 1560 | $($(target)_$(source)_DEPS)\
|
---|
| 1561 | $($(target)_$(srcname)_DEPS)\
|
---|
| 1562 | $($(source)_DEPS)\
|
---|
| 1563 | $($(srcname)_DEPS)\
|
---|
| 1564 | $($(target)_DEPS)
|
---|
[1496] | 1565 | local orderdeps := \
|
---|
[827] | 1566 | $($(target)_$(source)_ORDERDEPS)\
|
---|
| 1567 | $($(target)_$(srcname)_ORDERDEPS)\
|
---|
| 1568 | $($(source)_ORDERDEPS)\
|
---|
| 1569 | $($(srcname)_ORDERDEPS)\
|
---|
| 1570 | $($(target)_ORDERDEPS)
|
---|
[1496] | 1571 | local md5 := $(firstword \
|
---|
[640] | 1572 | $($(target)_$(source)_MD5)\
|
---|
| 1573 | $($(target)_$(srcname)_MD5)\
|
---|
| 1574 | $($(source)_MD5)\
|
---|
| 1575 | $($(srcname)_MD5)\
|
---|
| 1576 | $($(target)_MD5)\
|
---|
| 1577 | )
|
---|
[1496] | 1578 | local size := $(firstword \
|
---|
[640] | 1579 | $($(target)_$(source)_SIZE)\
|
---|
| 1580 | $($(target)_$(srcname)_SIZE)\
|
---|
| 1581 | $($(source)_SIZE)\
|
---|
| 1582 | $($(srcname)_SIZE)\
|
---|
| 1583 | $($(target)_SIZE)\
|
---|
| 1584 | )
|
---|
[1496] | 1585 | local dep := # not legal for fetch and unpack tools
|
---|
[640] | 1586 |
|
---|
| 1587 |
|
---|
| 1588 | #
|
---|
| 1589 | # The fetching.
|
---|
| 1590 | #
|
---|
[1496] | 1591 | local out := $(fetchdir)/$(srcname)
|
---|
| 1592 | local archive := $(out)
|
---|
[640] | 1593 | TARGET_$(target)_$(srcname) := $(out)
|
---|
[1496] | 1594 | local dirdep := $(call DIRDEP,$(fetchdir))
|
---|
| 1595 | local tool := $(firstword \
|
---|
[640] | 1596 | $($(target)_$(source)_FETCHTOOL)\
|
---|
| 1597 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 1598 | $($(target)_$(source)_TOOL)\
|
---|
| 1599 | $($(target)_$(srcname)_TOOL)\
|
---|
| 1600 | $($(source)_FETCHTOOL)\
|
---|
| 1601 | $($(srcname)_FETCHTOOL)\
|
---|
| 1602 | $($(source)_TOOL)\
|
---|
| 1603 | $($(srcname)_TOOL)\
|
---|
| 1604 | $($(target)_FETCHTOOL)\
|
---|
| 1605 | $($(target)_TOOL)\
|
---|
| 1606 | )
|
---|
[1496] | 1607 | local flags :=\
|
---|
[640] | 1608 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
| 1609 | $(FETCHFLAGS)\
|
---|
| 1610 | $($(target)_FETCHFLAGS)\
|
---|
| 1611 | $($(srcname)_FETCHFLAGS)\
|
---|
| 1612 | $($(source)_FETCHFLAGS)\
|
---|
| 1613 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
| 1614 | $($(target)_$(source)_FETCHFLAGS)
|
---|
| 1615 |
|
---|
| 1616 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
| 1617 |
|
---|
| 1618 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
| 1619 | $(warning kBuild: tools: \
|
---|
| 1620 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
| 1621 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 1622 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 1623 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 1624 | 5 $($(source)_FETCHTOOL)\
|
---|
| 1625 | 6 $($(srcname)_FETCHTOOL)\
|
---|
| 1626 | 7 $($(source)_TOOL)\
|
---|
| 1627 | 8 $($(srcname)_TOOL)\
|
---|
| 1628 | 9 $($(target)_FETCHTOOL)\
|
---|
| 1629 | 10 $($(target)_TOOL) )
|
---|
| 1630 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 1631 | endif
|
---|
| 1632 |
|
---|
| 1633 | # call the tool
|
---|
| 1634 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
| 1635 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
[1030] | 1636 | $(target)_$(srcname)_FETCH_OUTPUT_MAYBE_ := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
|
---|
[640] | 1637 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
[827] | 1638 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
|
---|
[640] | 1639 |
|
---|
| 1640 | # generate the fetch rule.
|
---|
| 1641 | $(eval $(def_fetch_src_fetch_rule))
|
---|
| 1642 |
|
---|
| 1643 |
|
---|
| 1644 | #
|
---|
| 1645 | # The unpacking / installing.
|
---|
| 1646 | #
|
---|
[1496] | 1647 | local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
| 1648 | local dirdep := $(call DIRDEP,$(inst))
|
---|
| 1649 | local tool := $(firstword \
|
---|
[640] | 1650 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 1651 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 1652 | $($(target)_$(source)_TOOL)\
|
---|
| 1653 | $($(target)_$(srcname)_TOOL)\
|
---|
| 1654 | $($(source)_UNPACKTOOL)\
|
---|
| 1655 | $($(srcname)_UNPACKTOOL)\
|
---|
| 1656 | $($(source)_TOOL)\
|
---|
| 1657 | $($(srcname)_TOOL)\
|
---|
| 1658 | $($(target)_UNPACKTOOL)\
|
---|
| 1659 | $($(target)_TOOL) \
|
---|
| 1660 | )
|
---|
| 1661 | ifeq ($(tool),)
|
---|
[1496] | 1662 | local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
| 1663 | $(evalval def_tools_include)
|
---|
[640] | 1664 | endif
|
---|
[1496] | 1665 | local flags :=\
|
---|
[640] | 1666 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
| 1667 | $(UNPACKFLAGS)\
|
---|
| 1668 | $($(target)_UNPACKFLAGS)\
|
---|
| 1669 | $($(srcname)_UNPACKFLAGS)\
|
---|
| 1670 | $($(source)_UNPACKFLAGS)\
|
---|
| 1671 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
| 1672 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
| 1673 |
|
---|
| 1674 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
| 1675 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
| 1676 | $(warning kBuild: tools: \
|
---|
| 1677 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 1678 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 1679 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 1680 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 1681 | 5 $($(source)_UNPACKTOOL)\
|
---|
| 1682 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
| 1683 | 7 $($(source)_TOOL)\
|
---|
| 1684 | 8 $($(srcname)_TOOL)\
|
---|
| 1685 | 9 $($(target)_UNPACKTOOL)\
|
---|
| 1686 | 10 $($(target)_TOOL) \
|
---|
| 1687 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
| 1688 | )
|
---|
| 1689 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 1690 | endif
|
---|
| 1691 |
|
---|
| 1692 | # call the tool
|
---|
| 1693 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
| 1694 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
[1030] | 1695 | $(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_ := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
|
---|
[640] | 1696 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
[827] | 1697 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
|
---|
[640] | 1698 |
|
---|
| 1699 | # generate the fetch rule.
|
---|
| 1700 | $(eval $(def_fetch_src_unpack_rule))
|
---|
| 1701 |
|
---|
| 1702 | _DIRS += $(inst) $(fetchdir)
|
---|
| 1703 |
|
---|
| 1704 | endef
|
---|
| 1705 |
|
---|
| 1706 |
|
---|
| 1707 | ##
|
---|
| 1708 | # Define the target level rules for a fetch.
|
---|
| 1709 | # @param target
|
---|
| 1710 | # @param out
|
---|
| 1711 | # @param inst
|
---|
[688] | 1712 | # @param _TARGET_$(target)_UNPACKED
|
---|
| 1713 | # @param _TARGET_$(target)_DIGEST
|
---|
[640] | 1714 | # @param bld_trg
|
---|
| 1715 | # @param bld_trg_arch
|
---|
| 1716 | define def_fetch_rules
|
---|
| 1717 |
|
---|
[689] | 1718 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
[1496] | 1719 | %$$(call MSG_FETCH_OK,$(target))
|
---|
[696] | 1720 | $$(QUIET)$$(RM) -f $$@ $$@.tmp
|
---|
[1311] | 1721 | $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
|
---|
[696] | 1722 | $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
| 1723 | $$(QUIET)$$(MV) -f $$@.tmp $$@
|
---|
[640] | 1724 |
|
---|
| 1725 | $(out)_unfetched:
|
---|
[1496] | 1726 | %$$(call MSG_UNFETCH,$(target))
|
---|
[696] | 1727 | $$(QUIET)$$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
---|
| 1728 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
|
---|
[689] | 1729 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
---|
[696] | 1730 | $$(QUIET)$$(RM) -f $(out).lst $(out)
|
---|
| 1731 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
|
---|
[640] | 1732 |
|
---|
[689] | 1733 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
---|
[696] | 1734 | $$(QUIET)$$(RM) -f $$@
|
---|
[1496] | 1735 | %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst)\
|
---|
[776] | 1736 | ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
|
---|
[696] | 1737 | $$(QUIET)$$(if $$(wildcard $(out).lst ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
|
---|
[701] | 1738 | $$(QUIET)$$(if $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@))
|
---|
[696] | 1739 | $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
|
---|
[760] | 1740 |
|
---|
[689] | 1741 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
---|
[688] | 1742 |
|
---|
[640] | 1743 | endef
|
---|
| 1744 |
|
---|
| 1745 |
|
---|
| 1746 | ##
|
---|
| 1747 | # Deal with one fetch target.
|
---|
| 1748 | # @param target
|
---|
| 1749 | # @param bld_trg
|
---|
| 1750 | # @param bld_trg_arch
|
---|
| 1751 | define def_fetch
|
---|
| 1752 | # common
|
---|
| 1753 | INSTARGET_$(target) := $($(target)_INST)
|
---|
| 1754 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
[679] | 1755 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
| 1756 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
[640] | 1757 | endif
|
---|
| 1758 | _TARGET_$(target)_FETCHED :=
|
---|
| 1759 | _TARGET_$(target)_UNPACKED :=
|
---|
| 1760 | _TARGET_$(target)_DIGEST :=
|
---|
| 1761 |
|
---|
| 1762 | # The 'sources'.
|
---|
| 1763 | #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)))
|
---|
| 1764 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
[1496] | 1765 | $(evalval def_fetch_src))
|
---|
[640] | 1766 |
|
---|
| 1767 | # The target.
|
---|
[1496] | 1768 | local inst := $(INSTARGET_$(target))
|
---|
| 1769 | local out := $(inst)_kBuild_fetch_$(target)
|
---|
[640] | 1770 |
|
---|
[689] | 1771 | $(eval includedep $(out))
|
---|
[690] | 1772 |
|
---|
[640] | 1773 | $(eval $(def_fetch_rules))
|
---|
| 1774 |
|
---|
[690] | 1775 | # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
|
---|
[749] | 1776 | $(target): $(out)
|
---|
| 1777 | $(target)_unfetch: $(out)_unfetched
|
---|
[690] | 1778 |
|
---|
[689] | 1779 | _FETCHES += $(out)
|
---|
[640] | 1780 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
| 1781 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
| 1782 | _UNFETCHES += $(out)_unfetched
|
---|
| 1783 | _DIRS += $(inst)
|
---|
| 1784 |
|
---|
| 1785 | endef
|
---|
| 1786 |
|
---|
| 1787 | # Walk the FETCH target lists.
|
---|
| 1788 | bld_trg := $(BUILD_TARGET)
|
---|
| 1789 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 1790 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1791 | $(evalval def_fetch))
|
---|
[640] | 1792 |
|
---|
| 1793 | # some aliases.
|
---|
| 1794 | download: $(_DOWNLOADS)
|
---|
[688] | 1795 | unpack: $(_UNPACKS)
|
---|
| 1796 | fetch: $(_FETCHES)
|
---|
| 1797 | unfetch: $(_UNFETCHES)
|
---|
[640] | 1798 |
|
---|
[988] | 1799 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1800 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 1801 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done fetching targets)
|
---|
[1441] | 1802 | $(info stat: $(make-stats ))
|
---|
[988] | 1803 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1804 | endif
|
---|
[640] | 1805 |
|
---|
| 1806 |
|
---|
[988] | 1807 |
|
---|
[640] | 1808 | ##
|
---|
| 1809 | ## Patching.
|
---|
| 1810 | ##
|
---|
| 1811 | ##
|
---|
[688] | 1812 | #define def_patch_src
|
---|
[640] | 1813 | #
|
---|
| 1814 | #endef
|
---|
| 1815 | #
|
---|
| 1816 | #
|
---|
| 1817 | ## Deal with one patch target.
|
---|
| 1818 | #define def_patch
|
---|
| 1819 | #
|
---|
| 1820 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
[1496] | 1821 | # $(evalval def_patch_src))
|
---|
[640] | 1822 | #
|
---|
[719] | 1823 | #_PATCHES +=
|
---|
[640] | 1824 | #endef
|
---|
| 1825 | #
|
---|
| 1826 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 1827 | # $(evalval def_patch))
|
---|
[640] | 1828 | #
|
---|
| 1829 |
|
---|
| 1830 |
|
---|
| 1831 | #
|
---|
[73] | 1832 | # Object processing.
|
---|
| 1833 | #
|
---|
[72] | 1834 |
|
---|
[380] | 1835 | ## wrapper the compile command dependency check.
|
---|
| 1836 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[1496] | 1837 | _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(source)_CMDS_PREV_),$$(commands $(obj)),FORCE)
|
---|
[380] | 1838 | else
|
---|
[730] | 1839 | _DEP_COMPILE_CMDS =
|
---|
[380] | 1840 | endif
|
---|
| 1841 |
|
---|
[749] | 1842 | ## Generates the rules for building a specific object, and the aliases
|
---|
[380] | 1843 | # for building a source file.
|
---|
[353] | 1844 | # @param $(obj) The object file.
|
---|
[380] | 1845 | define def_target_source_rule
|
---|
[1025] | 1846 |
|
---|
[1012] | 1847 | ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
|
---|
[1030] | 1848 | $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
[1007] | 1849 | $($(target)_$(source)_DEPEND_) \
|
---|
[1456] | 1850 | $(value _DEP_COMPILE_CMDS) \
|
---|
[1007] | 1851 | | \
|
---|
[1426] | 1852 | $($(target)_$(source)_DEPORD_) \
|
---|
| 1853 | $$($(target)_INTERMEDIATES)
|
---|
[1496] | 1854 | %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
[1007] | 1855 | else
|
---|
[1030] | 1856 | $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
[380] | 1857 | $($(target)_$(source)_DEPEND_) \
|
---|
[1456] | 1858 | $(value _DEP_COMPILE_CMDS) \
|
---|
[380] | 1859 | | \
|
---|
[1426] | 1860 | $($(target)_$(source)_DEPORD_) \
|
---|
| 1861 | $$($(target)_INTERMEDIATES)
|
---|
[1496] | 1862 | %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
[1012] | 1863 | ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
|
---|
[1030] | 1864 | $$(QUIET)$$(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
---|
[1007] | 1865 | endif
|
---|
[1012] | 1866 | endif
|
---|
[412] | 1867 |
|
---|
[380] | 1868 | $($(target)_$(source)_CMDS_)
|
---|
| 1869 |
|
---|
| 1870 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[1496] | 1871 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
| 1872 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(source)_CMDS_PREV_'
|
---|
| 1873 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)'
|
---|
| 1874 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
[770] | 1875 | endif
|
---|
[380] | 1876 |
|
---|
[749] | 1877 | $(basename $(notdir $(obj))).o: $(obj)
|
---|
| 1878 | $(basename $(notdir $(obj))).obj: $(obj)
|
---|
[1496] | 1879 |
|
---|
| 1880 | ## @todo make this 'local cmds' in 0.2.x or when a new kb-src-one is added.
|
---|
| 1881 | $(target)_$(source)_CMDS_ :=
|
---|
[353] | 1882 | endef
|
---|
[205] | 1883 |
|
---|
[353] | 1884 |
|
---|
[380] | 1885 | ## wrapper the link command dependency check.
|
---|
[1502] | 1886 | ifndef NO_LINK_CMDS_DEPS
|
---|
[1496] | 1887 | _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
[380] | 1888 | else
|
---|
[730] | 1889 | _DEP_LINK_CMDS =
|
---|
[380] | 1890 | endif
|
---|
| 1891 |
|
---|
| 1892 | ## Generate the link rule for a target.
|
---|
| 1893 | # @param $(target) The normalized target name.
|
---|
| 1894 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
| 1895 | # @param $(dep) The name of the dependency file.
|
---|
| 1896 | # @param $(out)
|
---|
| 1897 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
[1030] | 1898 | # @param $($(target)_OUTPUT_MAYBE_) Output files that the link may perhaps create.
|
---|
[1496] | 1899 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
[380] | 1900 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
[1496] | 1901 | # @param $(cmds) The link commands.
|
---|
[380] | 1902 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
| 1903 | define def_link_rule
|
---|
[1030] | 1904 | $(out) + $($(target)_OUTPUT_) +| $($(target)_OUTPUT_MAYBE_) : \
|
---|
[380] | 1905 | $($(target)_DEPEND_) \
|
---|
[1456] | 1906 | $(value _DEP_LINK_CMDS) \
|
---|
[380] | 1907 | | \
|
---|
| 1908 | $($(target)_DEPORD_)
|
---|
[1496] | 1909 | %$$(call MSG_LINK,$(target),$$@,$(tool_do))
|
---|
[1030] | 1910 | $$(QUIET)$$(RM) -f $(dep) $(out) $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
---|
[412] | 1911 |
|
---|
[1496] | 1912 | $(cmds)
|
---|
[380] | 1913 |
|
---|
[524] | 1914 | ifndef NO_LINK_CMDS_DEPS
|
---|
[1496] | 1915 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
|
---|
| 1916 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
| 1917 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
[770] | 1918 | endif
|
---|
[380] | 1919 |
|
---|
[749] | 1920 | $(basename $(notdir $(out))): $(out)
|
---|
[719] | 1921 |
|
---|
[380] | 1922 | endef
|
---|
| 1923 |
|
---|
| 1924 |
|
---|
| 1925 | ## Generate the link & lib install rule
|
---|
| 1926 | # @param $(target) Normalized target name.
|
---|
| 1927 | # @param $(out) The build target.
|
---|
| 1928 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
| 1929 | # @param $(mode) The file mode (optional)
|
---|
| 1930 | define def_link_install_rule
|
---|
| 1931 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
[1496] | 1932 | %$$(call MSG_INST_TRG,$(target),$(out),$$@)
|
---|
[696] | 1933 | $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
[719] | 1934 |
|
---|
| 1935 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
[749] | 1936 | $(basename $(notdir $(out))): $(INSTARGET_$(target))
|
---|
[719] | 1937 | endif
|
---|
[380] | 1938 | endef
|
---|
| 1939 |
|
---|
| 1940 |
|
---|
[1424] | 1941 | ## def_src_handler_*
|
---|
| 1942 | #
|
---|
| 1943 | # @{
|
---|
| 1944 | define def_src_handler_c
|
---|
[1496] | 1945 | local type := C
|
---|
[1424] | 1946 | $(kb-src-one )
|
---|
| 1947 | endef
|
---|
[73] | 1948 |
|
---|
[1424] | 1949 | define def_src_handler_cxx
|
---|
[1496] | 1950 | local type := CXX
|
---|
[1424] | 1951 | $(kb-src-one )
|
---|
| 1952 | endef
|
---|
[73] | 1953 |
|
---|
[1424] | 1954 | define def_src_handler_objc
|
---|
[1496] | 1955 | local type := OBJC
|
---|
[1424] | 1956 | $(kb-src-one )
|
---|
| 1957 | endef
|
---|
[1256] | 1958 |
|
---|
[1424] | 1959 | define def_src_handler_asm
|
---|
[1496] | 1960 | local type := AS
|
---|
[1424] | 1961 | $(kb-src-one )
|
---|
| 1962 | endef
|
---|
[353] | 1963 |
|
---|
[1424] | 1964 | define def_src_handler_rc
|
---|
[1496] | 1965 | local type := RC
|
---|
[1424] | 1966 | $(kb-src-one )
|
---|
| 1967 | endef
|
---|
[641] | 1968 |
|
---|
[1424] | 1969 | define def_src_handler_obj
|
---|
[1434] | 1970 | ifeq ($(defpath),)
|
---|
| 1971 | $(target)_OBJS_ += $(source)
|
---|
| 1972 | else
|
---|
| 1973 | $(target)_OBJS_ += $(abspathex $(source), $(defpath))
|
---|
| 1974 | endif
|
---|
[73] | 1975 | endef
|
---|
[1424] | 1976 | ## @}
|
---|
[73] | 1977 |
|
---|
[1424] | 1978 | ## Handle one source.
|
---|
| 1979 | # .
|
---|
| 1980 | define def_src_handler_one
|
---|
[1496] | 1981 | local suff := $(suffix $(source))
|
---|
| 1982 | local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
|
---|
| 1983 | local handler := $(patsubst $(suff):%,%,$(src_handler))
|
---|
[1424] | 1984 | ifneq ($(handler),)
|
---|
[1496] | 1985 | $(evalval $(handler))
|
---|
[1424] | 1986 | else
|
---|
[1434] | 1987 | othersrc += $(source)
|
---|
[1424] | 1988 | endif
|
---|
| 1989 | endef
|
---|
[73] | 1990 |
|
---|
[1424] | 1991 | ## Generic macro for processing all target sources.
|
---|
| 1992 | # @param $(target) Normalized target name.
|
---|
| 1993 | # @param $(defpath)
|
---|
| 1994 | # @param much-more...
|
---|
[1472] | 1995 | # @returns othersrc, $(target)_OBJS_, ++
|
---|
[1424] | 1996 | define def_target_sources
|
---|
[1496] | 1997 | local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
|
---|
[1424] | 1998 | $(foreach source,\
|
---|
[1429] | 1999 | $($(target)_SOURCES)\
|
---|
| 2000 | $($(target)_SOURCES.$(bld_trg))\
|
---|
| 2001 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2002 | $($(target)_SOURCES.$(bld_trg_arch))\
|
---|
| 2003 | $($(target)_SOURCES.$(bld_trg_cpu))\
|
---|
| 2004 | $($(target)_SOURCES.$(bld_type))\
|
---|
[1496] | 2005 | ,$(evalval def_src_handler_one) )
|
---|
[1424] | 2006 | endef
|
---|
| 2007 |
|
---|
| 2008 |
|
---|
| 2009 |
|
---|
[353] | 2010 | ## Generic macro for generating the install rule(s) for a target
|
---|
| 2011 | # and update the globals with default out.
|
---|
[219] | 2012 | #
|
---|
[353] | 2013 | # @param $(target) Normalized target name.
|
---|
| 2014 | # @param $(out) The output file.
|
---|
| 2015 | # @param $(definst) The default _INST value.
|
---|
| 2016 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[729] | 2017 | # @remark Only library uses this now.
|
---|
[353] | 2018 | define def_target_install_pluss
|
---|
| 2019 | ifndef $(target)_NOINST
|
---|
| 2020 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 2021 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
[219] | 2022 |
|
---|
[353] | 2023 | $(eval $(def_link_install_rule))
|
---|
[239] | 2024 |
|
---|
[827] | 2025 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[272] | 2026 |
|
---|
[353] | 2027 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
[579] | 2028 | $(typevar) += $(INSTARGET_$(target))
|
---|
[219] | 2029 | else
|
---|
[579] | 2030 | $(typevar) += $(out)
|
---|
[219] | 2031 | endif
|
---|
[353] | 2032 | else # _NOINST
|
---|
[579] | 2033 | $(typevar) += $(out)
|
---|
[353] | 2034 | endif
|
---|
| 2035 |
|
---|
[1030] | 2036 | _OUT_FILES += $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) $(out)
|
---|
[905] | 2037 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 2038 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[353] | 2039 | _OBJS += $($(target)_OBJS_)
|
---|
| 2040 |
|
---|
[219] | 2041 | endef
|
---|
| 2042 |
|
---|
| 2043 |
|
---|
| 2044 |
|
---|
| 2045 | #
|
---|
[72] | 2046 | # LIBRARIES
|
---|
[73] | 2047 | #
|
---|
[72] | 2048 |
|
---|
| 2049 | ## Library (one).
|
---|
[74] | 2050 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 2051 | define def_lib
|
---|
[145] | 2052 | # library basics
|
---|
[222] | 2053 | ## @todo prefix
|
---|
[1496] | 2054 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 2055 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 2056 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 2057 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 2058 | local tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[78] | 2059 | ifeq ($(tool),)
|
---|
[353] | 2060 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
[78] | 2061 | endif
|
---|
[1496] | 2062 | local name := $(firstword\
|
---|
[889] | 2063 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2064 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 2065 | $($(target)_NAME.$(bld_trg))\
|
---|
| 2066 | $($(target)_NAME.$(bld_type))\
|
---|
| 2067 | $($(target)_NAME)\
|
---|
| 2068 | $(target))
|
---|
[1496] | 2069 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[743] | 2070 | ifndef PATH_$(target)
|
---|
[1496] | 2071 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
[743] | 2072 | else
|
---|
| 2073 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 2074 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 2075 | endif
|
---|
| 2076 | endif
|
---|
[1496] | 2077 | local suff := $(firstword\
|
---|
[481] | 2078 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2079 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
[126] | 2080 | $($(target)_LIBSUFF)\
|
---|
[481] | 2081 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2082 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
[126] | 2083 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
[353] | 2084 | $(SUFF_LIB))
|
---|
[1496] | 2085 | local out := $(outbase)$(suff)
|
---|
| 2086 | local defpath := $($(target)_PATH)
|
---|
| 2087 | TARGET_$(target) := $(out)
|
---|
| 2088 | # no local here - must be writable across some foreachs.
|
---|
| 2089 | othersrc :=
|
---|
| 2090 | $(target)_OBJS_ :=
|
---|
[145] | 2091 |
|
---|
| 2092 | # source -> object
|
---|
[1496] | 2093 | $(evalval def_target_sources)
|
---|
[145] | 2094 |
|
---|
| 2095 | # library linking
|
---|
[1496] | 2096 | local tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
| 2097 | local name := $(firstword\
|
---|
[889] | 2098 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2099 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 2100 | $($(target)_NAME.$(bld_trg))\
|
---|
| 2101 | $($(target)_NAME.$(bld_type))\
|
---|
| 2102 | $($(target)_NAME)\
|
---|
| 2103 | $(target))
|
---|
[1496] | 2104 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
| 2105 | local flags :=\
|
---|
[74] | 2106 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
[221] | 2107 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
[74] | 2108 | $(ARFLAGS)\
|
---|
[221] | 2109 | $(ARFLAGS.$(bld_type))\
|
---|
[74] | 2110 | $($(target)_ARFLAGS)\
|
---|
[481] | 2111 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
| 2112 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
| 2113 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
| 2114 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2115 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
[1496] | 2116 | local dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
| 2117 | local deps := $($(target)_DEPS)
|
---|
| 2118 | local orderdeps := $($(target)_ORDERDEPS)
|
---|
[72] | 2119 |
|
---|
[725] | 2120 | # Adjust paths if we got a default path.
|
---|
| 2121 | ifneq ($(defpath),)
|
---|
[1496] | 2122 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
---|
| 2123 | local deps := $(abspathex $(deps),$(defpath))
|
---|
| 2124 | local orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
[1472] | 2125 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
[725] | 2126 | endif
|
---|
| 2127 |
|
---|
[859] | 2128 |
|
---|
| 2129 | # Custom pre-link actions.
|
---|
| 2130 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2131 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2132 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2133 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2134 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2135 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2136 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2137 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
[859] | 2138 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
[1496] | 2139 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
[859] | 2140 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
[1496] | 2141 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
[859] | 2142 | else ifdef $(target)_PRE_CMDS
|
---|
[1496] | 2143 | local pre_cmds := $($(target)_PRE_CMDS)
|
---|
[859] | 2144 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2145 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2146 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2147 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2148 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2149 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2150 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2151 | local pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
[859] | 2152 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
[1496] | 2153 | local pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
[859] | 2154 | else ifdef PRE_CMDS.$(bld_type)
|
---|
[1496] | 2155 | local pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
[859] | 2156 | else
|
---|
[1496] | 2157 | local pre_cmds := $(PRE_CMDS)
|
---|
[859] | 2158 | endif
|
---|
| 2159 |
|
---|
| 2160 | # Custom post-link actions.
|
---|
| 2161 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2162 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2163 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2164 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2165 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2166 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2167 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2168 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
[859] | 2169 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
[1496] | 2170 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
[859] | 2171 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
[1496] | 2172 | local post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
[859] | 2173 | else ifdef $(target)_POST_CMDS
|
---|
[1496] | 2174 | local post_cmds := $($(target)_POST_CMDS)
|
---|
[859] | 2175 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2176 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2177 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2178 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2179 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2180 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2181 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2182 | local post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
[859] | 2183 | else ifdef POST_CMDS.$(bld_trg)
|
---|
[1496] | 2184 | local post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
[859] | 2185 | else ifdef POST_CMDS.$(bld_type)
|
---|
[1496] | 2186 | local post_cmds := $(POST_CMDS.$(bld_type))
|
---|
[859] | 2187 | else
|
---|
[1496] | 2188 | local post_cmds := $(POST_CMDS)
|
---|
[859] | 2189 | endif
|
---|
| 2190 |
|
---|
[1424] | 2191 | # eliminate this guy?
|
---|
[1496] | 2192 | local objs = $($(target)_OBJS_)
|
---|
[1424] | 2193 |
|
---|
[380] | 2194 | # dependency file
|
---|
[1496] | 2195 | local dep := $(out)$(SUFF_DEP)
|
---|
[524] | 2196 | ifndef NO_LINK_CMDS_DEPS
|
---|
[893] | 2197 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 2198 | $(eval includedep $(dep))
|
---|
[380] | 2199 | endif
|
---|
[72] | 2200 |
|
---|
[380] | 2201 | # check that the tool is defined.
|
---|
| 2202 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
| 2203 | $(warning kBuild: tools: \
|
---|
[481] | 2204 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2205 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 2206 | 3 $($(target)_$(source)TOOL) \
|
---|
| 2207 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2208 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 2209 | 6 $($(target)_TOOL) \
|
---|
| 2210 | 7 $($(source)TOOL) \
|
---|
| 2211 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2212 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
| 2213 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2214 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 2215 | 12 $(TOOL) )
|
---|
[380] | 2216 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
| 2217 | endif
|
---|
| 2218 |
|
---|
| 2219 | # call the tool
|
---|
[1496] | 2220 | local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
[859] | 2221 | ifneq ($(pre_cmds),)
|
---|
[1496] | 2222 | local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
|
---|
[859] | 2223 | endif
|
---|
| 2224 | ifneq ($(post_cmds),)
|
---|
[1496] | 2225 | local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
|
---|
[859] | 2226 | endif
|
---|
[380] | 2227 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
[1030] | 2228 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
|
---|
[1424] | 2229 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_OBJS_)
|
---|
[827] | 2230 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
|
---|
[380] | 2231 |
|
---|
[412] | 2232 | # generate the link rule.
|
---|
[380] | 2233 | $(eval $(def_link_rule))
|
---|
| 2234 |
|
---|
[353] | 2235 | # installing and globals
|
---|
[1496] | 2236 | $(evalval def_target_install_pluss)
|
---|
[72] | 2237 | endef
|
---|
| 2238 |
|
---|
| 2239 | # Process libraries
|
---|
[859] | 2240 | definst := $(PATH_LIB)
|
---|
| 2241 | typevar := _LIBS
|
---|
[776] | 2242 | tool_do := LINK_LIBRARY
|
---|
[380] | 2243 | mode := 0644
|
---|
[1496] | 2244 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_lib))
|
---|
[72] | 2245 |
|
---|
[988] | 2246 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2247 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2248 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done library targets)
|
---|
[1441] | 2249 | $(info stat: $(make-stats ))
|
---|
[988] | 2250 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2251 | endif
|
---|
[72] | 2252 |
|
---|
[988] | 2253 |
|
---|
[72] | 2254 | #
|
---|
[353] | 2255 | # Link operations.
|
---|
[72] | 2256 | #
|
---|
| 2257 |
|
---|
[353] | 2258 | ##
|
---|
| 2259 | # Link prolog
|
---|
| 2260 | #
|
---|
| 2261 | # @param $(target) Normalized target name.
|
---|
| 2262 | # @param $(EXT) EXE,DLL,SYS.
|
---|
| 2263 | # @param $(definst) The default _INST value.
|
---|
| 2264 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[380] | 2265 | define def_link_common
|
---|
[353] | 2266 | # basics
|
---|
[1496] | 2267 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 2268 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 2269 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 2270 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[145] | 2271 |
|
---|
[1496] | 2272 | local tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 2273 | local name := $(firstword\
|
---|
[889] | 2274 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2275 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 2276 | $($(target)_NAME.$(bld_trg))\
|
---|
| 2277 | $($(target)_NAME.$(bld_type))\
|
---|
| 2278 | $($(target)_NAME)\
|
---|
| 2279 | $(target))
|
---|
[1496] | 2280 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[743] | 2281 | ifndef PATH_$(target)
|
---|
[1496] | 2282 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
[743] | 2283 | else
|
---|
| 2284 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 2285 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 2286 | endif
|
---|
| 2287 | endif
|
---|
[1496] | 2288 | local suff := $(firstword \
|
---|
[353] | 2289 | $($(target)_$(EXT)SUFF) \
|
---|
| 2290 | $($(target)_$(EXT)SUFF) \
|
---|
| 2291 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
| 2292 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
[1496] | 2293 | local out := $(outbase)$(suff)
|
---|
| 2294 | TARGET_$(target) := $(out)
|
---|
| 2295 | local defpath := $($(target)_PATH)
|
---|
| 2296 | # no local here - must be writable across some foreachs.
|
---|
| 2297 | othersrc :=
|
---|
| 2298 | $(target)_OBJS_ :=
|
---|
[353] | 2299 |
|
---|
[145] | 2300 | # source -> object
|
---|
[1496] | 2301 | $(evalval def_target_sources)
|
---|
[145] | 2302 |
|
---|
[744] | 2303 | # more link stuff.
|
---|
[1496] | 2304 | local tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 2305 | local name := $(firstword\
|
---|
[889] | 2306 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2307 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 2308 | $($(target)_NAME.$(bld_trg))\
|
---|
| 2309 | $($(target)_NAME.$(bld_type))\
|
---|
| 2310 | $($(target)_NAME)\
|
---|
| 2311 | $(target))
|
---|
[1496] | 2312 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
| 2313 | local flags :=\
|
---|
[74] | 2314 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
[221] | 2315 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
| 2316 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
| 2317 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 2318 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2319 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
[1242] | 2320 | $(foreach sdk, $(SDKS) \
|
---|
| 2321 | $(SDKS.$(bld_type)) \
|
---|
| 2322 | $(SDKS.$(bld_trg)) \
|
---|
| 2323 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 2324 | $(SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
| 2325 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
| 2326 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
| 2327 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
| 2328 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
| 2329 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2330 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
[74] | 2331 | $(LDFLAGS)\
|
---|
[221] | 2332 | $(LDFLAGS.$(bld_type))\
|
---|
| 2333 | $(LDFLAGS.$(bld_trg))\
|
---|
| 2334 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 2335 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2336 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
[1242] | 2337 | $(foreach sdk, $($(target)_SDKS) \
|
---|
| 2338 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 2339 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 2340 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 2341 | $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
| 2342 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
| 2343 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
| 2344 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
| 2345 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
| 2346 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
| 2347 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
[74] | 2348 | $($(target)_LDFLAGS)\
|
---|
[221] | 2349 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
| 2350 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
| 2351 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 2352 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 2353 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
[1496] | 2354 | local libs :=\
|
---|
[221] | 2355 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 2356 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2357 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
| 2358 | $($(target)_LIBS.$(bld_trg))\
|
---|
| 2359 | $($(target)_LIBS.$(bld_type))\
|
---|
[74] | 2360 | $($(target)_LIBS)\
|
---|
[592] | 2361 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2362 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 2363 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 2364 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 2365 | $($(target)_SDKS),\
|
---|
[353] | 2366 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 2367 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 2368 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 2369 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 2370 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 2371 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 2372 | $(LIBS.$(bld_trg_cpu))\
|
---|
[481] | 2373 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2374 | $(LIBS.$(bld_trg_arch))\
|
---|
| 2375 | $(LIBS.$(bld_trg))\
|
---|
| 2376 | $(LIBS.$(bld_type))\
|
---|
[74] | 2377 | $(LIBS)\
|
---|
[592] | 2378 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2379 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 2380 | $(SDKS.$(bld_trg)) \
|
---|
| 2381 | $(SDKS.$(bld_type)) \
|
---|
| 2382 | $(SDKS),\
|
---|
[353] | 2383 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 2384 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 2385 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 2386 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 2387 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 2388 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 2389 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 2390 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2391 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
| 2392 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
| 2393 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
[353] | 2394 | $(TOOL_$(tool)_LIBS)
|
---|
[1496] | 2395 | local libpath :=\
|
---|
[221] | 2396 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 2397 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2398 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
| 2399 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
| 2400 | $($(target)_LIBPATH.$(bld_type))\
|
---|
[74] | 2401 | $($(target)_LIBPATH)\
|
---|
[592] | 2402 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2403 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 2404 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 2405 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 2406 | $($(target)_SDKS),\
|
---|
[353] | 2407 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 2408 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 2409 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 2410 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 2411 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 2412 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 2413 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 2414 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2415 | $(LIBPATH.$(bld_trg_arch))\
|
---|
| 2416 | $(LIBPATH.$(bld_trg))\
|
---|
| 2417 | $(LIBPATH.$(bld_type))\
|
---|
[74] | 2418 | $(LIBPATH)\
|
---|
[592] | 2419 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2420 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 2421 | $(SDKS.$(bld_trg)) \
|
---|
| 2422 | $(SDKS.$(bld_type)) \
|
---|
| 2423 | $(SDKS),\
|
---|
[353] | 2424 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 2425 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 2426 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 2427 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 2428 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 2429 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 2430 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 2431 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 2432 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
| 2433 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
| 2434 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
[353] | 2435 | $(TOOL_$(tool)_LIBPATH)
|
---|
[1496] | 2436 | local dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
| 2437 | local deps := $($(target)_DEPS)
|
---|
| 2438 | local orderdeps := $($(target)_ORDERDEPS)
|
---|
[353] | 2439 |
|
---|
[725] | 2440 | # Adjust paths if we got a default path.
|
---|
| 2441 | ifneq ($(defpath),)
|
---|
[1496] | 2442 | local libpath := $(abspathex $(libpath),$(defpath))
|
---|
| 2443 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
---|
| 2444 | local deps := $(abspathex $(deps),$(defpath))
|
---|
| 2445 | local orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
[1472] | 2446 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
[725] | 2447 | # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
|
---|
| 2448 | endif
|
---|
| 2449 |
|
---|
[859] | 2450 | # Custom pre-link actions.
|
---|
| 2451 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2452 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2453 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2454 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2455 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2456 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2457 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2458 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
[859] | 2459 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
[1496] | 2460 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
[859] | 2461 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
[1496] | 2462 | local pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
[859] | 2463 | else ifdef $(target)_PRE_CMDS
|
---|
[1496] | 2464 | local pre_cmds := $($(target)_PRE_CMDS)
|
---|
[859] | 2465 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2466 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2467 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2468 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2469 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2470 | local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2471 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2472 | local pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
[859] | 2473 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
[1496] | 2474 | local pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
[859] | 2475 | else ifdef PRE_CMDS.$(bld_type)
|
---|
[1496] | 2476 | local pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
[859] | 2477 | else
|
---|
[1496] | 2478 | local pre_cmds := $(PRE_CMDS)
|
---|
[859] | 2479 | endif
|
---|
[72] | 2480 |
|
---|
[859] | 2481 | # Custom post-link actions.
|
---|
| 2482 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2483 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2484 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2485 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2486 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2487 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2488 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2489 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
[859] | 2490 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
[1496] | 2491 | local post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
[859] | 2492 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
[1496] | 2493 | local post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
[859] | 2494 | else ifdef $(target)_POST_CMDS
|
---|
[1496] | 2495 | local post_cmds := $($(target)_POST_CMDS)
|
---|
[859] | 2496 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
[1496] | 2497 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
[859] | 2498 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
[1496] | 2499 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
[859] | 2500 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
[1496] | 2501 | local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
[859] | 2502 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
[1496] | 2503 | local post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
[859] | 2504 | else ifdef POST_CMDS.$(bld_trg)
|
---|
[1496] | 2505 | local post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
[859] | 2506 | else ifdef POST_CMDS.$(bld_type)
|
---|
[1496] | 2507 | local post_cmds := $(POST_CMDS.$(bld_type))
|
---|
[859] | 2508 | else
|
---|
[1496] | 2509 | local post_cmds := $(POST_CMDS)
|
---|
[859] | 2510 | endif
|
---|
| 2511 |
|
---|
[1424] | 2512 | # eliminate this guy?
|
---|
[1496] | 2513 | local objs = $($(target)_OBJS_)
|
---|
[1424] | 2514 |
|
---|
[353] | 2515 | # installation targets
|
---|
| 2516 | ifndef $(target)_NOINST
|
---|
| 2517 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 2518 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 2519 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 2520 | $(typevar) += $(INSTARGET_$(target))
|
---|
| 2521 | else
|
---|
| 2522 | $(typevar) += $(out)
|
---|
| 2523 | endif
|
---|
| 2524 | # generate the install rule
|
---|
| 2525 | $(eval $(def_link_install_rule))
|
---|
| 2526 |
|
---|
| 2527 | else # NOINST
|
---|
| 2528 | INSTARGET_$(target) :=
|
---|
| 2529 | $(typevar) += $(out)
|
---|
| 2530 | endif # NOINST
|
---|
| 2531 |
|
---|
[380] | 2532 | # dependency file
|
---|
[1496] | 2533 | local dep := $(outbase)$(SUFF_DEP)
|
---|
[524] | 2534 | ifndef NO_LINK_CMDS_DEPS
|
---|
[893] | 2535 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 2536 | $(eval includedep $(dep))
|
---|
[380] | 2537 | endif
|
---|
[353] | 2538 |
|
---|
[380] | 2539 | # check that the tool is defined.
|
---|
| 2540 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
| 2541 | $(warning kBuild: tools: \
|
---|
[481] | 2542 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2543 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 2544 | 3 $($(target)_$(source)TOOL) \
|
---|
| 2545 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2546 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 2547 | 6 $($(target)_TOOL) \
|
---|
| 2548 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2549 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
| 2550 | 9 $($(source)TOOL) \
|
---|
| 2551 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2552 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 2553 | 12 $(TOOL) )
|
---|
[380] | 2554 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
| 2555 | endif
|
---|
[353] | 2556 |
|
---|
[380] | 2557 | # call the tool
|
---|
[1496] | 2558 | local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
[859] | 2559 | ifneq ($(pre_cmds),)
|
---|
[1496] | 2560 | local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
|
---|
[859] | 2561 | endif
|
---|
| 2562 | ifneq ($(post_cmds),)
|
---|
[1496] | 2563 | local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
|
---|
[859] | 2564 | endif
|
---|
[380] | 2565 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
[1030] | 2566 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
|
---|
[1424] | 2567 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_OBJS_)
|
---|
[827] | 2568 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
|
---|
[353] | 2569 |
|
---|
[412] | 2570 | # generate the link rule.
|
---|
[380] | 2571 | $(eval $(def_link_rule))
|
---|
| 2572 |
|
---|
[412] | 2573 |
|
---|
[380] | 2574 | # Update globals.
|
---|
[579] | 2575 | _OBJS += $($(target)_OBJS_)
|
---|
| 2576 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[905] | 2577 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 2578 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[827] | 2579 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[353] | 2580 |
|
---|
| 2581 | endef
|
---|
| 2582 |
|
---|
| 2583 |
|
---|
| 2584 | #
|
---|
| 2585 | # BLDPROGS
|
---|
| 2586 | #
|
---|
| 2587 |
|
---|
| 2588 | ## Build program (one).
|
---|
| 2589 | # @param $(target) Normalized target (program) name.
|
---|
| 2590 | define def_bldprog
|
---|
| 2591 |
|
---|
| 2592 | # set NOINST if not forced installation.
|
---|
| 2593 | ifndef $(target)_INST
|
---|
| 2594 | $(target)_NOINST := 1
|
---|
| 2595 | endif
|
---|
| 2596 |
|
---|
[380] | 2597 | # do the usual stuff.
|
---|
[1496] | 2598 | $(evalval def_link_common)
|
---|
[353] | 2599 |
|
---|
| 2600 | endef
|
---|
| 2601 |
|
---|
| 2602 | # Process build programs.
|
---|
| 2603 | EXT := EXE
|
---|
| 2604 | EXTPRE := HOST
|
---|
[380] | 2605 | tool_do := LINK_PROGRAM
|
---|
[353] | 2606 | definst := $(PATH_BIN)
|
---|
| 2607 | typevar := _BLDPROGS
|
---|
[380] | 2608 | mode := 0755
|
---|
[353] | 2609 | bld_trg_base_var := PLATFORM
|
---|
[1496] | 2610 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(evalval def_bldprog))
|
---|
[353] | 2611 |
|
---|
[988] | 2612 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2613 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2614 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done build program targets)
|
---|
[1441] | 2615 | $(info stat: $(make-stats ))
|
---|
[988] | 2616 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2617 | endif
|
---|
[353] | 2618 |
|
---|
| 2619 |
|
---|
| 2620 | #
|
---|
| 2621 | # DLLS
|
---|
| 2622 | #
|
---|
| 2623 |
|
---|
[189] | 2624 | # Process dlls
|
---|
[353] | 2625 | EXT := DLL
|
---|
| 2626 | EXTPRE :=
|
---|
[380] | 2627 | tool_do := LINK_DLL
|
---|
[353] | 2628 | definst := $(PATH_DLL)
|
---|
| 2629 | typevar := _DLLS
|
---|
[830] | 2630 | mode := 0644
|
---|
[353] | 2631 | bld_trg_base_var := TARGET
|
---|
[1496] | 2632 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_link_common))
|
---|
[74] | 2633 |
|
---|
[988] | 2634 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2635 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2636 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done dll targets)
|
---|
[1441] | 2637 | $(info stat: $(make-stats ))
|
---|
[988] | 2638 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2639 | endif
|
---|
[74] | 2640 |
|
---|
[988] | 2641 |
|
---|
[72] | 2642 | #
|
---|
[830] | 2643 | # IMPORT LIBRARIES
|
---|
[72] | 2644 | #
|
---|
[219] | 2645 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 2646 | # - On other platforms they are fake DLLs.
|
---|
[830] | 2647 | #
|
---|
| 2648 | EXTPRE :=
|
---|
| 2649 | typevar := _IMPORT_LIBS
|
---|
| 2650 | mode := 0644
|
---|
| 2651 | bld_trg_base_var := TARGET
|
---|
[481] | 2652 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
[830] | 2653 | EXT := LIB
|
---|
| 2654 | tool_do := LINK_LIBRARY
|
---|
| 2655 | definst := $(PATH_LIB)
|
---|
[1496] | 2656 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_lib))
|
---|
[189] | 2657 | else
|
---|
[830] | 2658 | EXT := DLL
|
---|
| 2659 | tool_do := LINK_DLL
|
---|
| 2660 | definst := $(PATH_DLL)
|
---|
[1496] | 2661 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_link_common))
|
---|
[189] | 2662 | endif
|
---|
[72] | 2663 |
|
---|
[988] | 2664 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2665 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2666 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done import library targets)
|
---|
[1441] | 2667 | $(info stat: $(make-stats ))
|
---|
[988] | 2668 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2669 | endif
|
---|
[189] | 2670 |
|
---|
[988] | 2671 |
|
---|
[189] | 2672 | #
|
---|
| 2673 | # PROGRAMS
|
---|
| 2674 | #
|
---|
| 2675 |
|
---|
[353] | 2676 | # Process programs
|
---|
| 2677 | EXT := EXE
|
---|
| 2678 | EXTPRE :=
|
---|
[380] | 2679 | tool_do := LINK_PROGRAM
|
---|
[353] | 2680 | definst := $(PATH_BIN)
|
---|
| 2681 | typevar := _PROGRAMS
|
---|
[380] | 2682 | mode := 0755
|
---|
[353] | 2683 | bld_trg_base_var := TARGET
|
---|
[1496] | 2684 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_link_common))
|
---|
[130] | 2685 |
|
---|
[988] | 2686 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2687 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2688 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done program targets)
|
---|
[1441] | 2689 | $(info stat: $(make-stats ))
|
---|
[988] | 2690 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2691 | endif
|
---|
[130] | 2692 |
|
---|
[189] | 2693 |
|
---|
[72] | 2694 | #
|
---|
[83] | 2695 | # SYSMODS
|
---|
[72] | 2696 | #
|
---|
| 2697 |
|
---|
[130] | 2698 | # Process sysmods
|
---|
[353] | 2699 | EXT := SYS
|
---|
| 2700 | EXTPRE :=
|
---|
[380] | 2701 | tool_do := LINK_SYSMOD
|
---|
[353] | 2702 | definst := $(PATH_SYS)
|
---|
| 2703 | typevar := _SYSMODS
|
---|
[380] | 2704 | mode := 0644
|
---|
[353] | 2705 | bld_trg_base_var := TARGET
|
---|
[1496] | 2706 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(evalval def_link_common))
|
---|
[83] | 2707 |
|
---|
[988] | 2708 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2709 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2710 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done sysmod targets)
|
---|
[1441] | 2711 | $(info stat: $(make-stats ))
|
---|
[988] | 2712 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2713 | endif
|
---|
[83] | 2714 |
|
---|
[988] | 2715 |
|
---|
[72] | 2716 | #
|
---|
| 2717 | # OTHERS
|
---|
| 2718 | #
|
---|
[481] | 2719 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[72] | 2720 |
|
---|
| 2721 |
|
---|
[353] | 2722 | #
|
---|
| 2723 | # INSTALLS
|
---|
| 2724 | #
|
---|
[72] | 2725 |
|
---|
[353] | 2726 | ## generate the install rule
|
---|
| 2727 | define def_install_src_rule
|
---|
| 2728 | # the install rule
|
---|
| 2729 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
[1496] | 2730 | %$$(call MSG_INST_FILE,$(srcsrc),$(insdst))
|
---|
[696] | 2731 | $$(QUIET)$(inscmd)
|
---|
[353] | 2732 | endef
|
---|
| 2733 |
|
---|
| 2734 | ## install one file
|
---|
| 2735 | define def_install_src
|
---|
| 2736 |
|
---|
| 2737 | # deal with '=>' in the source file name.
|
---|
[1496] | 2738 | local srcdst := $(subst =>, ,$(src))
|
---|
| 2739 | local srcsrc := $(firstword $(srcdst))
|
---|
| 2740 | local srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
| 2741 | local srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
[353] | 2742 |
|
---|
| 2743 | # _INSTFUN
|
---|
| 2744 | ifdef $(srcsrc)_INSTFUN
|
---|
[1496] | 2745 | local instfun := $(srcsrc)_INSTFUN
|
---|
[1347] | 2746 | else ifdef $(target)_INSTFUN
|
---|
[1496] | 2747 | local instfun := $(target)_INSTFUN
|
---|
[353] | 2748 | else
|
---|
[1496] | 2749 | local instfun := _INSTALL_FILE
|
---|
[353] | 2750 | endif
|
---|
| 2751 |
|
---|
| 2752 | # _INST
|
---|
| 2753 | ifdef $(srcsrc)_INST
|
---|
[1496] | 2754 | local inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
[1347] | 2755 | else ifdef $(target)_INST
|
---|
[1496] | 2756 | local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 2757 | else
|
---|
[1496] | 2758 | local inst := $(dir $(srcdstdir))
|
---|
[353] | 2759 | endif
|
---|
| 2760 |
|
---|
| 2761 | # calc target
|
---|
[1496] | 2762 | local insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
[424] | 2763 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
[353] | 2764 |
|
---|
[414] | 2765 | # mode, uid and gid
|
---|
[1496] | 2766 | local mode := $(firstword \
|
---|
[481] | 2767 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2768 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 2769 | $($(target)_$(srcsrc)_MODE) \
|
---|
[481] | 2770 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2771 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
| 2772 | $($(target)_$(srcdst)_MODE) \
|
---|
[481] | 2773 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2774 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 2775 | $($(srcsrc)_MODE) \
|
---|
[481] | 2776 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2777 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
| 2778 | $($(srcdst)_MODE) \
|
---|
[481] | 2779 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2780 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 2781 | $($(target)_MODE))
|
---|
[1496] | 2782 | local uid := $(firstword \
|
---|
[481] | 2783 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2784 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2785 | $($(target)_$(srcsrc)_UID) \
|
---|
[481] | 2786 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2787 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 2788 | $($(target)_$(srcdst)_UID) \
|
---|
[481] | 2789 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2790 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2791 | $($(srcsrc)_UID) \
|
---|
[481] | 2792 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2793 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 2794 | $($(srcdst)_UID) \
|
---|
[481] | 2795 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2796 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2797 | $($(target)_UID))
|
---|
[1496] | 2798 | local gid := $(firstword \
|
---|
[481] | 2799 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2800 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2801 | $($(target)_$(srcsrc)_GID) \
|
---|
[481] | 2802 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2803 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 2804 | $($(target)_$(srcdst)_GID) \
|
---|
[481] | 2805 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2806 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2807 | $($(srcsrc)_GID) \
|
---|
[481] | 2808 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2809 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 2810 | $($(srcdst)_GID) \
|
---|
[481] | 2811 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2812 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2813 | $($(target)_GID))
|
---|
[1496] | 2814 | local flags := \
|
---|
[830] | 2815 | $($(target)_IFFLAGS) \
|
---|
| 2816 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
| 2817 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2818 | $($(srcdst)_IFFLAGS) \
|
---|
| 2819 | $($(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
| 2820 | $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2821 | $($(srcsrc)_IFFLAGS) \
|
---|
| 2822 | $($(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
| 2823 | $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2824 | $($(target)_$(srcdst)_IFFLAGS) \
|
---|
| 2825 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
| 2826 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2827 | $($(target)_$(srcsrc)_IFFLAGS) \
|
---|
| 2828 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
| 2829 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[414] | 2830 |
|
---|
[725] | 2831 |
|
---|
| 2832 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
| 2833 | ifdef $(target)_PATH
|
---|
[1496] | 2834 | local srcsrc := $(abspathex $(srcsrc),$($(target)_PATH))
|
---|
[725] | 2835 | endif
|
---|
| 2836 |
|
---|
[353] | 2837 | # create the command
|
---|
| 2838 | ifdef $(srcsrc)_INSTALLER
|
---|
[1496] | 2839 | local inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
[830] | 2840 | else ifdef $(target)_INSTALLER
|
---|
[1496] | 2841 | local inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
[353] | 2842 | else
|
---|
[1496] | 2843 | local inscmd := $$(INSTALL)\
|
---|
[414] | 2844 | $(if $(uid),-o $(uid))\
|
---|
| 2845 | $(if $(gid),-g $(gid))\
|
---|
| 2846 | $(if $(mode),-m $(mode))\
|
---|
[830] | 2847 | $(flags)\
|
---|
[414] | 2848 | $(srcsrc) $(insdst)
|
---|
[353] | 2849 | endif
|
---|
| 2850 |
|
---|
| 2851 | # generate the rule (need double evaluation here)
|
---|
| 2852 | $(eval $(def_install_src_rule))
|
---|
| 2853 |
|
---|
| 2854 | INSTARGET_$(target) += $(insdst)
|
---|
| 2855 | endef
|
---|
| 2856 |
|
---|
| 2857 |
|
---|
| 2858 | ## generate the symlink rule
|
---|
| 2859 | define def_install_symlink_rule
|
---|
| 2860 | # the install rule
|
---|
| 2861 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
[1496] | 2862 | %$$(call MSG_INST_SYM,$(insdst),$(symdst))
|
---|
[696] | 2863 | $$(QUIET)$$(RM) -f $$@
|
---|
| 2864 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
[353] | 2865 | endef
|
---|
| 2866 |
|
---|
| 2867 | ## create one symlink
|
---|
| 2868 | define def_install_symlink
|
---|
| 2869 |
|
---|
| 2870 | # deal with '=>' in the source file name.
|
---|
[1496] | 2871 | local symdst := $(subst =>, ,$(src))
|
---|
| 2872 | local symlnk := $(firstword $(symdst))
|
---|
| 2873 | local symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[353] | 2874 |
|
---|
| 2875 | # _INSTFUN
|
---|
[380] | 2876 | ifdef $(symlnk)_INSTFUN
|
---|
[1496] | 2877 | local instfun := $(symlnk)_INSTFUN
|
---|
[827] | 2878 | else ifdef $(target)_INSTFUN
|
---|
[1496] | 2879 | local instfun := $(target)_INSTFUN
|
---|
[353] | 2880 | else
|
---|
[1496] | 2881 | local instfun := _INSTALL_FILE
|
---|
[353] | 2882 | endif
|
---|
| 2883 |
|
---|
| 2884 | # _INST
|
---|
[380] | 2885 | ifdef $(symlnk)_INST
|
---|
[1496] | 2886 | local inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
[827] | 2887 | else ifdef $(target)_INST
|
---|
[1496] | 2888 | local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
[353] | 2889 | else
|
---|
[1496] | 2890 | local inst := $(dir $(symlnk))
|
---|
[353] | 2891 | endif
|
---|
| 2892 |
|
---|
| 2893 | # calc target
|
---|
[1496] | 2894 | local insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
[380] | 2895 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
[353] | 2896 |
|
---|
| 2897 | # generate the rule (need double evaluation here)
|
---|
| 2898 | $(eval $(def_install_symlink_rule))
|
---|
| 2899 |
|
---|
| 2900 | INSTARGET_$(target) += $(insdst)
|
---|
| 2901 | endef
|
---|
| 2902 |
|
---|
[412] | 2903 |
|
---|
[380] | 2904 | ## generate the install rule
|
---|
| 2905 | define def_install_directory_rule
|
---|
| 2906 | # the install rule
|
---|
| 2907 | $(insdst):
|
---|
[1496] | 2908 | %$$(call MSG_INST_DIR,$(insdst))
|
---|
[696] | 2909 | $$(QUIET)$$(INSTALL) -d \
|
---|
[380] | 2910 | $(if $(uid),-o $(uid))\
|
---|
| 2911 | $(if $(gid),-g $(gid))\
|
---|
| 2912 | $(if $(mode),-m $(mode))\
|
---|
[830] | 2913 | $(flags)\
|
---|
[380] | 2914 | $(insdst)
|
---|
[412] | 2915 |
|
---|
| 2916 | .NOTPARALLEL: $(insdst)
|
---|
[380] | 2917 | endef
|
---|
| 2918 |
|
---|
[412] | 2919 |
|
---|
[380] | 2920 | ## create one directory
|
---|
| 2921 | define def_install_directory
|
---|
| 2922 |
|
---|
| 2923 | # _INST
|
---|
| 2924 | ifdef $(directory)_INST
|
---|
[1496] | 2925 | local inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
[827] | 2926 | else ifdef $(target)_INST
|
---|
[1496] | 2927 | local inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
[380] | 2928 | else
|
---|
[1496] | 2929 | local inst := $(PATH_INS)
|
---|
[380] | 2930 | endif
|
---|
| 2931 |
|
---|
[1496] | 2932 | local mode := $(firstword \
|
---|
[481] | 2933 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2934 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 2935 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 2936 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2937 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 2938 | $($(directory)_MODE) \
|
---|
[481] | 2939 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2940 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 2941 | $($(target)_MODE))
|
---|
[1496] | 2942 | local uid := $(firstword \
|
---|
[481] | 2943 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2944 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 2945 | $($(target)_$(directory)_UID) \
|
---|
[481] | 2946 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2947 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 2948 | $($(directory)_UID) \
|
---|
[481] | 2949 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2950 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2951 | $($(target)_UID))
|
---|
[1496] | 2952 | local gid := $(firstword \
|
---|
[481] | 2953 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2954 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 2955 | $($(target)_$(directory)_GID) \
|
---|
[481] | 2956 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2957 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 2958 | $($(directory)_GID) \
|
---|
[481] | 2959 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2960 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2961 | $($(target)_GID))
|
---|
[1496] | 2962 | local flags := \
|
---|
[830] | 2963 | $($(target)_IDFLAGS)\
|
---|
| 2964 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
| 2965 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2966 | $($(directory)_IDFLAGS) \
|
---|
| 2967 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 2968 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2969 | $($(target)_$(directory)_IDFLAGS) \
|
---|
| 2970 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 2971 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[380] | 2972 |
|
---|
[1496] | 2973 | local insdst := $(inst)/$(directory)/
|
---|
[380] | 2974 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
| 2975 |
|
---|
| 2976 | # generate the rule (need double evaluation here)
|
---|
| 2977 | $(eval $(def_install_directory_rule))
|
---|
| 2978 |
|
---|
| 2979 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
| 2980 | endef
|
---|
| 2981 |
|
---|
| 2982 |
|
---|
[353] | 2983 | ## process one install target.
|
---|
| 2984 | define def_install
|
---|
[744] | 2985 | # the basics.
|
---|
[1496] | 2986 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 2987 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 2988 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 2989 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
[353] | 2990 |
|
---|
[827] | 2991 | INSTARGET_$(target) := $($(target)_GOALS)
|
---|
[380] | 2992 | INSTARGET_DIRS_$(target) :=
|
---|
| 2993 |
|
---|
[481] | 2994 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
[1496] | 2995 | $(evalval def_install_directory))
|
---|
[380] | 2996 |
|
---|
[481] | 2997 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
[1496] | 2998 | $(evalval def_install_src))
|
---|
[353] | 2999 |
|
---|
[481] | 3000 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
[1496] | 3001 | $(evalval def_install_symlink))
|
---|
[353] | 3002 |
|
---|
[827] | 3003 | # the collection target
|
---|
| 3004 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
[838] | 3005 | $(TARGET_$(target)): $(INSTARGET_$(target)) | $(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET))
|
---|
[827] | 3006 | @$(QUIET2)$(APPEND) $@
|
---|
| 3007 |
|
---|
| 3008 | $(target): $(TARGET_$(target))
|
---|
| 3009 |
|
---|
| 3010 | _INSTALLS += $(TARGET_$(target))
|
---|
| 3011 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[380] | 3012 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
[905] | 3013 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 3014 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[353] | 3015 | endef
|
---|
| 3016 |
|
---|
| 3017 | ## process all install targets
|
---|
[481] | 3018 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[1496] | 3019 | $(evalval def_install))
|
---|
[353] | 3020 |
|
---|
[988] | 3021 | ifdef KBUILD_PROFILE_SELF
|
---|
| 3022 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 3023 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done install targets)
|
---|
[1441] | 3024 | $(info stat: $(make-stats ))
|
---|
[988] | 3025 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 3026 | endif
|
---|
[353] | 3027 |
|
---|
[988] | 3028 |
|
---|
[72] | 3029 | #
|
---|
[417] | 3030 | # PACKING
|
---|
| 3031 | #
|
---|
[481] | 3032 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[417] | 3033 |
|
---|
| 3034 |
|
---|
| 3035 | #
|
---|
[72] | 3036 | # DOCS
|
---|
| 3037 | #
|
---|
| 3038 |
|
---|
| 3039 |
|
---|
| 3040 | #
|
---|
[353] | 3041 | # DIRECTORIES
|
---|
| 3042 | #
|
---|
[827] | 3043 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
|
---|
[380] | 3044 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
[353] | 3045 |
|
---|
[380] | 3046 |
|
---|
[353] | 3047 | define def_mkdir_rule
|
---|
| 3048 | $(directory):
|
---|
[1496] | 3049 | %$$(call MSG_MKDIR,$$@)
|
---|
[696] | 3050 | $$(QUIET)$$(MKDIR) -p $$@
|
---|
[72] | 3051 | endef
|
---|
| 3052 |
|
---|
[353] | 3053 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
[72] | 3054 |
|
---|
[988] | 3055 | ifdef KBUILD_PROFILE_SELF
|
---|
| 3056 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 3057 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done directories)
|
---|
[1441] | 3058 | $(info stat: $(make-stats ))
|
---|
[988] | 3059 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 3060 | endif
|
---|
[183] | 3061 |
|
---|
[988] | 3062 |
|
---|
[72] | 3063 | #
|
---|
[353] | 3064 | # NOTHING
|
---|
[72] | 3065 | #
|
---|
[353] | 3066 | do-nothing:
|
---|
[988] | 3067 | ifdef KBUILD_PROFILE_SELF
|
---|
| 3068 | @$(ECHO) 'prof: $(int-sub $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
|
---|
[1456] | 3069 | @$(ECHO) 'stat: $(make-stats )'
|
---|
[988] | 3070 | endif
|
---|
[1496] | 3071 | %$(call MSG_NOTHING)
|
---|
[72] | 3072 |
|
---|
[183] | 3073 |
|
---|
[75] | 3074 | #
|
---|
[353] | 3075 | # CLEAN UP
|
---|
[75] | 3076 | #
|
---|
[353] | 3077 | do-clean:
|
---|
[1496] | 3078 | %$(call MSG_CLEAN)
|
---|
[701] | 3079 | $(QUIET)$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
[966] | 3080 | $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $(rsort $(dir $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)))
|
---|
[72] | 3081 |
|
---|
[98] | 3082 |
|
---|
[897] | 3083 |
|
---|
[353] | 3084 | #
|
---|
| 3085 | # PASSES (including directory and makefile walking)
|
---|
| 3086 | #
|
---|
[221] | 3087 |
|
---|
[75] | 3088 | ## Subdir
|
---|
| 3089 | # @param $(pass) Lowercase pass name.
|
---|
| 3090 | # @param $(PASS) Uppercase pass name.
|
---|
| 3091 | # @param $(subdir) Subdirectory
|
---|
| 3092 | # @param $(tag) tag to attach to the rule name.
|
---|
| 3093 | define def_pass_subdir
|
---|
[219] | 3094 | pass_$(pass)$(tag):: $(dep)
|
---|
[696] | 3095 | + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 3096 | endef
|
---|
[72] | 3097 |
|
---|
[75] | 3098 | ## Submakefile
|
---|
| 3099 | # @param $(pass) Lowercase pass name.
|
---|
| 3100 | # @param $(PASS) Uppercase pass name.
|
---|
| 3101 | # @param $(makefile) Makefile.
|
---|
| 3102 | # @param $(tag) tag to attach to the rule name.
|
---|
| 3103 | define def_pass_makefile
|
---|
[219] | 3104 | pass_$(pass)$(tag):: $(dep)
|
---|
[696] | 3105 | + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 3106 | endef
|
---|
[73] | 3107 |
|
---|
[75] | 3108 | ## Execute a pass.
|
---|
| 3109 | # @param $(pass) Lowercase pass name.
|
---|
| 3110 | # @param $(PASS) Uppercase pass name.
|
---|
[353] | 3111 | define def_pass_old
|
---|
[481] | 3112 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 3113 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 3114 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 3115 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[75] | 3116 |
|
---|
| 3117 | $(eval tag:=_before)
|
---|
[219] | 3118 | $(eval dep:=)
|
---|
[481] | 3119 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 3120 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 3121 |
|
---|
| 3122 | $(eval tag:=_after)
|
---|
[219] | 3123 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 3124 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 3125 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 3126 |
|
---|
| 3127 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 3128 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[353] | 3129 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
[272] | 3130 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[696] | 3131 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
[220] | 3132 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
[219] | 3133 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 3134 |
|
---|
[183] | 3135 | endef
|
---|
| 3136 |
|
---|
[353] | 3137 | define def_pass
|
---|
[481] | 3138 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
---|
| 3139 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 3140 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 3141 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[183] | 3142 |
|
---|
[353] | 3143 | $(eval tag:=_before)
|
---|
| 3144 | $(eval dep:=)
|
---|
[481] | 3145 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 3146 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 3147 |
|
---|
[353] | 3148 | $(eval tag:=_after)
|
---|
| 3149 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 3150 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 3151 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 3152 |
|
---|
[380] | 3153 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 3154 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
| 3155 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
| 3156 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
| 3157 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[696] | 3158 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
[353] | 3159 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
| 3160 | pass_$(pass): pass_$(pass)_after
|
---|
| 3161 | else
|
---|
[388] | 3162 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
[353] | 3163 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
| 3164 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
| 3165 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
| 3166 | pass_$(pass): \
|
---|
| 3167 | pass_$(pass)_before \
|
---|
| 3168 | pass_$(pass)_doit \
|
---|
[388] | 3169 | pass_$(pass)_after
|
---|
[353] | 3170 | endif
|
---|
[189] | 3171 |
|
---|
[353] | 3172 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
| 3173 | endef
|
---|
[75] | 3174 |
|
---|
[353] | 3175 | # Generate the defined passes.
|
---|
| 3176 | $(foreach PASS, $(PASSES), \
|
---|
| 3177 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 3178 | $(eval $(def_pass)))
|
---|
[75] | 3179 |
|
---|
[219] | 3180 | ## Pass order
|
---|
| 3181 | # @param $(pass) Current pass name.
|
---|
| 3182 | # @param $(prev_pass) The previous pass name.
|
---|
| 3183 | define def_pass_order
|
---|
[380] | 3184 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 3185 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 3186 | .PHONY: pass_$(pass)_order
|
---|
[219] | 3187 | pass_$(pass)_order: $(pass_prev)
|
---|
[1496] | 3188 | %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
[696] | 3189 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
[353] | 3190 | else
|
---|
| 3191 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
[388] | 3192 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
[353] | 3193 | pass_$(pass)_banner:
|
---|
[1496] | 3194 | %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
[353] | 3195 | pass_$(pass)_order: \
|
---|
| 3196 | $(pass_prev) \
|
---|
| 3197 | pass_$(pass)_banner \
|
---|
| 3198 | pass_$(pass)
|
---|
| 3199 | endif
|
---|
[219] | 3200 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 3201 | endef
|
---|
[183] | 3202 |
|
---|
[219] | 3203 | ## PASS: order
|
---|
| 3204 | # Use dependencies to ensure correct pass order.
|
---|
| 3205 | pass_prev :=
|
---|
[353] | 3206 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
| 3207 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 3208 | $(eval $(def_pass_order)))
|
---|
[219] | 3209 |
|
---|
[988] | 3210 | ifdef KBUILD_PROFILE_SELF
|
---|
| 3211 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 3212 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done passes)
|
---|
[1441] | 3213 | $(info stat: $(make-stats ))
|
---|
[988] | 3214 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 3215 | endif
|
---|
[272] | 3216 |
|
---|
[897] | 3217 |
|
---|
[75] | 3218 | #
|
---|
| 3219 | # THE MAIN RULES
|
---|
| 3220 | #
|
---|
[219] | 3221 | all_recursive: $(pass_prev)
|
---|
[75] | 3222 |
|
---|
[130] | 3223 | rebuild: clean
|
---|
[219] | 3224 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 3225 |
|
---|
[412] | 3226 | # @todo make this a non-default pass!
|
---|
[353] | 3227 | uninstall:
|
---|
[827] | 3228 | $(RM) -f $(_INSTALLS_FILES)
|
---|
[412] | 3229 |
|
---|
[380] | 3230 | install: pass_installs
|
---|
[78] | 3231 |
|
---|
[75] | 3232 | # misc shortcuts.
|
---|
[380] | 3233 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
[75] | 3234 | objects: $(_OBJS)
|
---|
[222] | 3235 | bldprogs: $(_BLDPROGS)
|
---|
[189] | 3236 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 3237 | dlls: $(_DLLS)
|
---|
[219] | 3238 | programs: $(_PROGRAMS)
|
---|
[205] | 3239 | sysmods: $(_SYSMODS)
|
---|
[353] | 3240 | others: $(_OTHERS)
|
---|
[854] | 3241 | installs: $(_INSTALLS) $(_INSTALLS_DIRS) $(_INSTALLS_FILES)
|
---|
[75] | 3242 |
|
---|
| 3243 |
|
---|
[897] | 3244 |
|
---|
[353] | 3245 | #
|
---|
| 3246 | # kBuild debugging stuff.
|
---|
| 3247 | #
|
---|
| 3248 | show_targets:
|
---|
[984] | 3249 | @$(foreach target, $(_ALL_TARGETS),\
|
---|
[353] | 3250 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
| 3251 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
| 3252 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
| 3253 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
[660] | 3254 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
---|
[353] | 3255 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 3256 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
| 3257 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
| 3258 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
| 3259 | )\
|
---|
| 3260 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
| 3261 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 3262 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
| 3263 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
| 3264 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
| 3265 | ))
|
---|
| 3266 |
|
---|
| 3267 |
|
---|
| 3268 |
|
---|
| 3269 | #
|
---|
| 3270 | # Include dependency files.
|
---|
| 3271 | #
|
---|
[893] | 3272 | ifneq ($(_DEPFILES),)
|
---|
| 3273 | includedep $(_DEPFILES)
|
---|
| 3274 | endif
|
---|
[353] | 3275 |
|
---|
| 3276 |
|
---|
[988] | 3277 | ifdef KBUILD_PROFILE_SELF
|
---|
| 3278 | _KBUILD_TS_FOOTER_END := $(nanots )
|
---|
| 3279 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_PREV)) - end of footer.kmk)
|
---|
| 3280 | $(info prof: footer.kmk: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_FOOTER_START)))
|
---|
[1441] | 3281 | $(info stat: $(make-stats ))
|
---|
[988] | 3282 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_END)
|
---|
| 3283 | endif
|
---|
| 3284 |
|
---|
[72] | 3285 | # end-of-file-content
|
---|
[106] | 3286 | __footer_kmk__ := target
|
---|
[72] | 3287 | endif # __footer_kmk__
|
---|
[438] | 3288 |
|
---|