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