[72] | 1 | # $Id: footer.kmk 111 2004-06-24 22:28:10Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[106] | 6 | # Copyright (c) source004 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
[72] | 7 | #
|
---|
| 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
[106] | 13 | # the Free Software Foundation; either version source of the License, or
|
---|
[72] | 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
[106] | 23 | # Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA 0sourcetargettargettarget-targettype07 USA
|
---|
[72] | 24 | #
|
---|
| 25 | #
|
---|
| 26 |
|
---|
| 27 | ifndef __footer_kmk__
|
---|
| 28 | # start-of-file-content
|
---|
| 29 |
|
---|
| 30 | #
|
---|
| 31 | # Variables.
|
---|
[73] | 32 | # (Some of these need initialization before including definitions using them.)
|
---|
[72] | 33 | #
|
---|
| 34 |
|
---|
| 35 | # all targets.
|
---|
[83] | 36 | ALL_TARGETS := $(LIBRARIES) $(PROGRAMS) $(DLLS) $(SYSMODS) $(OTHERS)
|
---|
[72] | 37 |
|
---|
[75] | 38 | # dependency files.
|
---|
| 39 | _DEPFILES :=
|
---|
| 40 |
|
---|
| 41 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 42 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 43 | # required dependency file must add those output files to this variable.
|
---|
| 44 | _OUT_FILES :=
|
---|
| 45 |
|
---|
[72] | 46 | # all of a type
|
---|
| 47 | _OBJS :=
|
---|
| 48 | _LIBS :=
|
---|
| 49 | _DLLS :=
|
---|
| 50 | _EXES :=
|
---|
[83] | 51 | _SYSMODS:=
|
---|
[72] | 52 | _DIRS :=
|
---|
| 53 |
|
---|
| 54 | # all objs of a specific target
|
---|
| 55 | define def_objs_var
|
---|
[106] | 56 | _OBJS_$target :=
|
---|
[72] | 57 | endef
|
---|
| 58 | $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
|
---|
| 59 |
|
---|
[73] | 60 |
|
---|
[72] | 61 | #
|
---|
[73] | 62 | # Basic macros
|
---|
| 63 | #
|
---|
| 64 |
|
---|
| 65 | ## Figure out the tool for a source
|
---|
[106] | 66 | # @param $target source file
|
---|
| 67 | # @param $source normalized main target
|
---|
| 68 | # @param $type tooltype
|
---|
[79] | 69 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
[106] | 70 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 71 | $($(target)_$(source)_$(type)TOOL) \
|
---|
| 72 | $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 73 | $($(target)_$(source)_TOOL) \
|
---|
| 74 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 75 | $($(target)_$(type)TOOL) \
|
---|
| 76 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 77 | $($(target)_TOOL) \
|
---|
| 78 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 79 | $($(source)_$(type)TOOL) \
|
---|
| 80 | $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 81 | $($(source)_TOOL) \
|
---|
| 82 | $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 83 | $($(type)TOOL) \
|
---|
| 84 | $(TOOL.$(BUILD_TARGET)) \
|
---|
| 85 | $(TOOL) ))
|
---|
[73] | 86 |
|
---|
[106] | 87 | _SOURCE_TOOL_OLD = $(strip $(firstword \
|
---|
| 88 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 89 | $($(target)_$(source)_$(type)TOOL) $($target_$source_TOOL) \
|
---|
| 90 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 91 | $($(target)_$(type)TOOL) $($target_TOOL) \
|
---|
| 92 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 93 | $($(source)_$(type)TOOL) $($(source)_TOOL) \
|
---|
| 94 | $($(type)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
|
---|
| 95 | $($(type)TOOL) $(TOOL) ))
|
---|
| 96 |
|
---|
[78] | 97 | ## Figure out the tool for a target.
|
---|
[106] | 98 | # @param $target normalized target.
|
---|
| 99 | # @param $source tooltype.
|
---|
[79] | 100 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[106] | 101 | $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 102 | $($(target)_$(source)TOOL) \
|
---|
| 103 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 104 | $($(target)_TOOL) \
|
---|
| 105 | $($(source)TOOL) \
|
---|
| 106 | $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 107 | $(TOOL.$(BUILD_TARGET)) \
|
---|
| 108 | $(TOOL) \
|
---|
[79] | 109 | ))
|
---|
[78] | 110 |
|
---|
[73] | 111 | ## Figure out where to put object files.
|
---|
[110] | 112 | # @param $1 source file
|
---|
| 113 | # @param $2 normalized main target
|
---|
| 114 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
|
---|
[73] | 115 |
|
---|
| 116 | ## Figure out where to put object files.
|
---|
[110] | 117 | # @param $1 real target name.
|
---|
| 118 | # @param $2 normalized main target
|
---|
| 119 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
|
---|
[73] | 120 |
|
---|
| 121 |
|
---|
| 122 | #
|
---|
[72] | 123 | # Include templates
|
---|
| 124 | #
|
---|
| 125 | _TEMPLATES := $(TEMPLATE)
|
---|
| 126 | define def_templates
|
---|
| 127 | ifdef $(target)_TEMPLATE
|
---|
| 128 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
| 129 | endif
|
---|
| 130 | endef
|
---|
| 131 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
| 132 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 133 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
| 134 |
|
---|
| 135 | define def_templates_include
|
---|
| 136 | ifndef TEMPLATE_$(template)
|
---|
| 137 | include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
|
---|
| 138 | endif
|
---|
| 139 | endef
|
---|
| 140 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 141 |
|
---|
[74] | 142 |
|
---|
[72] | 143 | #
|
---|
| 144 | # Common Inheritance
|
---|
| 145 | #
|
---|
| 146 |
|
---|
| 147 | ## Inherit defaults property
|
---|
| 148 | # @param $(prop) Property name
|
---|
| 149 | # @param $(target) Target name.
|
---|
| 150 | define def_inherit_defaults_one
|
---|
[74] | 151 | ifndef $(target)_$(prop)
|
---|
[109] | 152 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
[72] | 153 | ifdef $(prop)
|
---|
[105] | 154 | $$(eval $(target)_$(prop) := $($(prop)))
|
---|
[72] | 155 | endif
|
---|
[109] | 156 | ifdef $(prop).$(BUILD_TARGET)
|
---|
| 157 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
|
---|
[72] | 158 | endif
|
---|
[109] | 159 | endif
|
---|
| 160 | endif
|
---|
[72] | 161 | endef
|
---|
| 162 |
|
---|
| 163 | ## Inherit default properties for one target.
|
---|
| 164 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
| 165 | # is inherited from the default properties.
|
---|
| 166 | # @param $(target) Target name
|
---|
[78] | 167 | #
|
---|
[72] | 168 | define def_inherit_defaults
|
---|
| 169 | ifdef $(target)_TEMPLATE
|
---|
[107] | 170 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
|
---|
[109] | 171 | $$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 172 | endif
|
---|
[107] | 173 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
|
---|
[109] | 174 | $$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 175 | endif
|
---|
| 176 | else
|
---|
[109] | 177 | $$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 178 | endif
|
---|
| 179 | endef
|
---|
| 180 | # Inherit default properties.
|
---|
[109] | 181 | # !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
|
---|
[105] | 182 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
[72] | 183 |
|
---|
| 184 |
|
---|
[78] | 185 | ## Inherit one template property in a accumulative manner.
|
---|
[72] | 186 | # @param $(prop) Property name
|
---|
| 187 | # @param $(target) Target name
|
---|
[78] | 188 | # @todo fix the precedence order for some properties.
|
---|
[72] | 189 | define def_inherit_template_one
|
---|
[78] | 190 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 191 | ifndef $(target)_$(prop)
|
---|
[106] | 192 | #$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[105] | 193 | $$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
|
---|
[72] | 194 | endif
|
---|
| 195 | endif
|
---|
[79] | 196 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
| 197 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
[106] | 198 | #$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
[105] | 199 | $$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
|
---|
[79] | 200 | endif
|
---|
| 201 | endif
|
---|
[72] | 202 | endef
|
---|
| 203 |
|
---|
[78] | 204 | ## Inherit one template property.
|
---|
| 205 | # @param $(prop) Property name
|
---|
| 206 | # @param $(target) Target name
|
---|
| 207 | define def_inherit_template_one_accumulate
|
---|
| 208 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[106] | 209 | #$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[105] | 210 | $$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[106] | 211 | #$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[78] | 212 | endif
|
---|
[79] | 213 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
[105] | 214 | #$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
| 215 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
|
---|
[79] | 216 | endif
|
---|
| 217 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
|
---|
[105] | 218 | #$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
|
---|
| 219 | $$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
|
---|
[79] | 220 | endif
|
---|
| 221 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
|
---|
[105] | 222 | #$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
|
---|
| 223 | $$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
|
---|
[79] | 224 | endif
|
---|
[78] | 225 | endef
|
---|
| 226 |
|
---|
[106] | 227 |
|
---|
[72] | 228 | ## Inherit template properties for on target.
|
---|
| 229 | # @param $(target) Target name.
|
---|
| 230 | define def_inherit_template
|
---|
[105] | 231 | $$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
|
---|
| 232 | ,$$(eval $$(def_inherit_template_one)))
|
---|
| 233 | $$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
|
---|
| 234 | ,$$(eval $$(def_inherit_template_one_accumulate)))
|
---|
[72] | 235 | endef
|
---|
| 236 | # Inherit template properties
|
---|
[105] | 237 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
|
---|
[72] | 238 |
|
---|
| 239 |
|
---|
| 240 | #
|
---|
| 241 | # Include tools
|
---|
| 242 | #
|
---|
| 243 | _TOOLS := $(TOOL)
|
---|
| 244 | define def_tools_target_source
|
---|
[78] | 245 | $(foreach tool,\
|
---|
[79] | 246 | $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 247 | $($(source)_TOOL) $($(target)_$(source)_TOOL)\
|
---|
[79] | 248 | $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 249 | $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
|
---|
[79] | 250 | $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 251 | $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
|
---|
[79] | 252 | $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 253 | $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
|
---|
[79] | 254 | $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 255 | $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
|
---|
[79] | 256 | $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 257 | $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
|
---|
| 258 | ,$(eval _TOOLS += $(tool)))
|
---|
[72] | 259 | endef
|
---|
| 260 | define def_tools_target
|
---|
[78] | 261 | $(foreach tool,\
|
---|
[79] | 262 | $($(target)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 263 | $($(target)_TOOL)\
|
---|
[79] | 264 | $($(target)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 265 | $($(target)_CTOOL)\
|
---|
[79] | 266 | $($(target)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 267 | $($(target)_CXXTOOL)\
|
---|
[79] | 268 | $($(target)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 269 | $($(target)_ASTOOL)\
|
---|
[79] | 270 | $($(target)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 271 | $($(target)_ARTOOL)\
|
---|
[79] | 272 | $($(target)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 273 | $($(target)_LDTOOL)\
|
---|
[79] | 274 | ,$(eval _TOOLS += $(tool)))
|
---|
[72] | 275 | $(foreach source, $($(target)_SOURCES), $(eval $(def_tools_target_source)))
|
---|
| 276 | endef
|
---|
| 277 | $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
|
---|
| 278 | _TOOLS := $(sort $(_TOOLS))
|
---|
| 279 |
|
---|
| 280 | define def_tools_include
|
---|
| 281 | ifndef TOOL_$(tool)
|
---|
| 282 | include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
|
---|
| 283 | endif
|
---|
| 284 | endef
|
---|
| 285 | $(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
|
---|
| 286 |
|
---|
| 287 |
|
---|
| 288 | #
|
---|
| 289 | # Include SDKs
|
---|
[73] | 290 | #
|
---|
[72] | 291 | _SDKS := $(SDKS)
|
---|
| 292 | define def_sdks_target_source
|
---|
| 293 | $(foreach sdk, $($(source)_SDKS) $($(target)_$(source)_SDKS), \
|
---|
| 294 | $(eval _SDKS += $(sdk)))
|
---|
| 295 | endef
|
---|
| 296 | define def_sdks_target
|
---|
| 297 | $(foreach sdk, $($(target)_SDKS), $(eval _SDKS += $(sdk)))
|
---|
| 298 | $(foreach source, $($(target)_SOURCES), $(eval $(def_sdks_target_source)))
|
---|
| 299 | endef
|
---|
| 300 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
| 301 | _SDKS := $(sort $(_SDKS))
|
---|
| 302 |
|
---|
| 303 | define def_sdks_include
|
---|
| 304 | ifndef SDK_$(sdk)
|
---|
| 305 | include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
|
---|
| 306 | endif
|
---|
| 307 | endef
|
---|
| 308 | $(foreach sdk, $(_SDKS), $(eval $(def_sdk)))
|
---|
| 309 |
|
---|
[73] | 310 | #
|
---|
| 311 | # Object processing.
|
---|
| 312 | #
|
---|
[72] | 313 |
|
---|
[73] | 314 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 315 | # @param $(target) Normalized target name.
|
---|
| 316 | # @param $(source) Source file name.
|
---|
| 317 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[72] | 318 | #
|
---|
[73] | 319 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
[105] | 320 | # @remark I now have a clue. Have to use $$ if not.
|
---|
[73] | 321 | define def_target_source_c_cpp_asm
|
---|
[105] | 322 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 323 |
|
---|
[78] | 324 | $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
|
---|
[111] | 325 | $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
|
---|
| 326 | $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 327 | $(eval dirdep := $(dir $(outbase)).dir_created)
|
---|
[73] | 328 | $(eval defs :=\
|
---|
[78] | 329 | $(TOOL_$(tool)_DEFS)\
|
---|
| 330 | $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
|
---|
| 331 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
|
---|
| 332 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 333 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 334 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
| 335 | $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
[78] | 336 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 337 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 338 | $(SDKS),\
|
---|
| 339 | $(SDK_$(sdk)_DEFS)\
|
---|
| 340 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 341 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 342 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 343 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 344 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 345 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 346 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 347 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 348 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 349 | $(DEFS)\
|
---|
| 350 | $(DEFS.$(BUILD_TYPE))\
|
---|
[78] | 351 | $(DEFS.$(BUILD_TARGET))\
|
---|
| 352 | $(DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 353 | $(DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 354 | $($(type)DEFS)\
|
---|
| 355 | $($(type)DEFS.$(BUILD_TYPE))\
|
---|
| 356 | $($(type)DEFS.$(BUILD_TARGET))\
|
---|
| 357 | $($(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 358 | $($(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 359 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 360 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 361 | $($(target)_SDKS),\
|
---|
| 362 | $(SDK_$(sdk)_DEFS)\
|
---|
| 363 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 364 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 365 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 366 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 367 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 368 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 369 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 370 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 371 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 372 | $($(target)_DEFS)\
|
---|
| 373 | $($(target)_DEFS.$(BUILD_TYPE))\
|
---|
| 374 | $($(target)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 375 | $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 376 | $($(target)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 377 | $($(target)_$(type)DEFS)\
|
---|
| 378 | $($(target)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 379 | $($(target)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 380 | $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 381 | $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 382 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 383 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 384 | $($(source)_SDKS),\
|
---|
| 385 | $(SDK_$(sdk)_DEFS)\
|
---|
| 386 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 387 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 388 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 389 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 390 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 391 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 392 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 393 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 394 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 395 | $($(source)_DEFS)\
|
---|
| 396 | $($(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 397 | $($(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 398 | $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 399 | $($(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 400 | $($(source)_$(type)DEFS)\
|
---|
[74] | 401 | $($(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 402 | $($(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 403 | $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 404 | $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 405 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 406 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 407 | $($(target)_$(source)_SDKS),\
|
---|
| 408 | $(SDK_$(sdk)_DEFS)\
|
---|
| 409 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 410 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 411 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 412 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 413 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 414 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 415 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 416 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 417 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 418 | $($(target)_$(source)_DEFS)\
|
---|
| 419 | $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 420 | $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 421 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 422 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 423 | $($(target)_$(source)_$(type)DEFS)\
|
---|
| 424 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 425 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 426 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 427 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 428 | )
|
---|
| 429 | $(eval incs :=\
|
---|
[78] | 430 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 431 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 432 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 433 | $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 434 | $($(target)_$(source)_$(type)INCS)\
|
---|
[78] | 435 | $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 436 | $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 437 | $($(target)_$(source)_INCS.$(BUILD_TARGET))\
|
---|
| 438 | $($(target)_$(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 439 | $($(target)_$(source)_INCS)\
|
---|
[78] | 440 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 441 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 442 | $($(target)_$(source)_SDKS),
|
---|
| 443 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 444 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 445 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 446 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 447 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 448 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 449 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 450 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 451 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 452 | $(SDK_$(sdk)_INCS))\
|
---|
| 453 | $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 454 | $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 455 | $($(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 456 | $($(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 457 | $($(source)_$(type)INCS)\
|
---|
[78] | 458 | $($(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 459 | $($(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 460 | $($(source)_INCS.$(BUILD_TARGET))\
|
---|
| 461 | $($(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 462 | $($(source)_INCS)\
|
---|
[78] | 463 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 464 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 465 | $($(source)_SDKS),\
|
---|
| 466 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 467 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 468 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 469 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 470 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 471 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 472 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 473 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 474 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 475 | $(SDK_$(sdk)_INCS))\
|
---|
| 476 | $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 477 | $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 478 | $($(target)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 479 | $($(target)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 480 | $($(target)_$(type)INCS)\
|
---|
[78] | 481 | $($(target)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 482 | $($(target)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 483 | $($(target)_INCS.$(BUILD_TARGET))\
|
---|
| 484 | $($(target)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 485 | $($(target)_INCS)\
|
---|
[78] | 486 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 487 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 488 | $($(target)_SDKS),\
|
---|
| 489 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 490 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 491 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 492 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 493 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 494 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 495 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 496 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 497 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 498 | $(SDK_$(sdk)_INCS))\
|
---|
| 499 | $(INCS.$(BUILD_TARGET_CPU))\
|
---|
| 500 | $(INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 501 | $(INCS.$(BUILD_TARGET))\
|
---|
| 502 | $(INCS.$(BUILD_TYPE))\
|
---|
[73] | 503 | $(INCS)\
|
---|
[78] | 504 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 505 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 506 | $(SDKS),\
|
---|
| 507 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 508 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 509 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 510 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 511 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 512 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 513 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 514 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 515 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 516 | $(SDK_$(sdk)_INCS))\
|
---|
| 517 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 518 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 519 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 520 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 521 | $(TOOL_$(tool)_$(type)INCS)\
|
---|
| 522 | )
|
---|
| 523 | $(eval flags :=\
|
---|
| 524 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
| 525 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 526 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 527 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 528 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 529 | $($(type)FLAGS)\
|
---|
| 530 | $($(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 531 | $($(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 532 | $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 533 | $($(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 534 | $($(target)_$(type)FLAGS)\
|
---|
| 535 | $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 536 | $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 537 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 538 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 539 | $($(source)_$(type)FLAGS)\
|
---|
| 540 | $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 541 | $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 542 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 543 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 544 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
| 545 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 546 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 547 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 548 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 549 | )
|
---|
[74] | 550 | $(eval objsuff := $(firstword \
|
---|
| 551 | $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 552 | $($(target)_$(source)_OBJSUFF)\
|
---|
| 553 | $($(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 554 | $($(source)_OBJSUFF)\
|
---|
| 555 | $($(target)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 556 | $($(target)_OBJSUFF)\
|
---|
| 557 | $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
|
---|
| 558 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
| 559 | $(SUFF_OBJ)\
|
---|
| 560 | ))
|
---|
[73] | 561 | $(eval obj := $(outbase)$(objsuff))
|
---|
[74] | 562 | $(eval dep := $(outbase)$(SUFF_DEP))
|
---|
[73] | 563 |
|
---|
| 564 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
---|
[97] | 565 | ifndef TOOL_$(tool)_COMPILE_$(type)
|
---|
| 566 | $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
|
---|
| 567 | $$(warning kBuild: tools: \
|
---|
[106] | 568 | 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 569 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
| 570 | 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 571 | 4 $($(target)_$(source)_TOOL) \
|
---|
| 572 | 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 573 | 6 $($(target)_$(type)TOOL) \
|
---|
| 574 | 7 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 575 | 8 $($(target)_TOOL) \
|
---|
| 576 | 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 577 | 10 $($(source)_$(type)TOOL) \
|
---|
| 578 | 11 $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 579 | 12 $($(source)_TOOL) \
|
---|
| 580 | 13 $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 581 | 14 $($(type)TOOL) \
|
---|
| 582 | 15 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 583 | 16 $(TOOL) )
|
---|
[97] | 584 | endif
|
---|
[73] | 585 | $(eval $(TOOL_$(tool)_COMPILE_$(type)))
|
---|
| 586 |
|
---|
| 587 | $(eval _OBJS_$(target) += $(obj))
|
---|
| 588 | $(eval _DEPFILES += $(dep))
|
---|
| 589 |
|
---|
| 590 | endef
|
---|
| 591 |
|
---|
| 592 | ## Generic macro for processing all target sources.
|
---|
[74] | 593 | # @param $(target) Normalized target name.
|
---|
[73] | 594 | define def_target_sources
|
---|
| 595 | #$ (warning def_target_sources)
|
---|
| 596 | # C sources
|
---|
| 597 | $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES))\
|
---|
| 598 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 599 |
|
---|
| 600 | # C++ sources
|
---|
[95] | 601 | $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES))\
|
---|
[73] | 602 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 603 |
|
---|
| 604 | # ASM sources
|
---|
[95] | 605 | $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES))\
|
---|
[73] | 606 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 607 | endef
|
---|
| 608 |
|
---|
| 609 |
|
---|
| 610 | #
|
---|
[72] | 611 | # LIBRARIES
|
---|
[73] | 612 | #
|
---|
[72] | 613 |
|
---|
| 614 | ## Library (one).
|
---|
[74] | 615 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 616 | define def_lib
|
---|
[73] | 617 | # source -> object
|
---|
| 618 | $(eval $(def_target_sources))
|
---|
[72] | 619 |
|
---|
[73] | 620 | # library
|
---|
[78] | 621 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
| 622 | ifeq ($(tool),)
|
---|
| 623 | $$(error kBuild: Library target $(target) doesn't have a tool defined!)
|
---|
| 624 | endif
|
---|
[111] | 625 | ## @todo prefix
|
---|
| 626 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 627 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 628 | $(eval lib := $(outbase)$(libsuff))
|
---|
[74] | 629 | $(eval flags :=\
|
---|
| 630 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
| 631 | $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 632 | $(ARFLAGS)\
|
---|
| 633 | $(ARFLAGS.$(BUILD_TYPE))\
|
---|
| 634 | $($(target)_ARFLAGS)\
|
---|
| 635 | $($(target)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 636 | )
|
---|
| 637 | $(eval libsuff := $(firstword\
|
---|
| 638 | $($(target)_LIBSUFF.$(BUILD_TARGET))\
|
---|
| 639 | $($(target)_LIBSUFF)\
|
---|
| 640 | $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
|
---|
| 641 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
| 642 | $(SUFF_LIB)\
|
---|
| 643 | ))
|
---|
[73] | 644 | $(eval objs = $(_OBJS_$(target)))
|
---|
[91] | 645 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES)))
|
---|
[73] | 646 | $(eval dirdep := $(dir $(lib)).dir_created)
|
---|
[78] | 647 | ## @todo fix dependencies on makefiles an such
|
---|
[73] | 648 | $(eval deps := )
|
---|
[72] | 649 |
|
---|
[73] | 650 | $(eval $(TOOL_$(tool)_LINK_LIBRARY))
|
---|
[72] | 651 |
|
---|
[73] | 652 | _OBJS += $(_OBJS_$(target))
|
---|
| 653 | _LIBS += $(lib)
|
---|
[75] | 654 | _OUT_FILES += $(lib)
|
---|
[72] | 655 | endef
|
---|
| 656 |
|
---|
| 657 | # Process libraries
|
---|
| 658 | $(foreach target, $(LIBRARIES), $(eval $(def_lib)))
|
---|
| 659 |
|
---|
| 660 |
|
---|
| 661 |
|
---|
| 662 | #
|
---|
| 663 | # PROGRAMS
|
---|
| 664 | #
|
---|
| 665 |
|
---|
[74] | 666 | ## Program (one).
|
---|
| 667 | # @param $(target) Normalized target (program) name.
|
---|
| 668 | define def_program
|
---|
| 669 | # source -> object
|
---|
| 670 | $(eval $(def_target_sources))
|
---|
[72] | 671 |
|
---|
[74] | 672 | # library
|
---|
[78] | 673 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 674 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 675 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 676 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
|
---|
| 677 | $(eval exe := $(outbase)$(exesuff))
|
---|
| 678 | $(eval objs = $(_OBJS_$(target)))
|
---|
[74] | 679 | $(eval flags :=\
|
---|
| 680 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 681 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 682 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 683 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 684 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 685 | $(LDFLAGS)\
|
---|
| 686 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 687 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 688 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 689 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 690 | $($(target)_LDFLAGS)\
|
---|
| 691 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 692 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 693 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 694 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 695 | )
|
---|
| 696 | $(eval libs :=\
|
---|
[87] | 697 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 698 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 699 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[74] | 700 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 701 | $($(target)_LIBS)\
|
---|
[87] | 702 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 703 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 704 | $(LIBS.$(BUILD_TARGET))\
|
---|
[74] | 705 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 706 | $(LIBS)\
|
---|
| 707 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 708 | $(TOOL_$(tool)_LIBS)\
|
---|
| 709 | )
|
---|
| 710 | $(eval libpath :=\
|
---|
[87] | 711 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 712 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 713 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 714 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 715 | $($(target)_LIBPATH)\
|
---|
[87] | 716 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 717 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 718 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 719 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 720 | $(LIBPATH)\
|
---|
[87] | 721 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 722 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 723 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 724 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 725 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 726 | )
|
---|
| 727 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
| 728 | ## @todo fix dependencies
|
---|
| 729 | $(eval deps := )
|
---|
| 730 | #
|
---|
| 731 | $(eval deffile := $(strip $(firstword
|
---|
| 732 | $($(target)_DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 733 | $($(target)_DEFFILE.$(BUILD_TARGET))\
|
---|
| 734 | $($(target)_DEFFILE.$(BUILD_TYPE))\
|
---|
| 735 | $($(target)_DEFFILE)\
|
---|
| 736 | $(DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 737 | $(DEFFILE.$(BUILD_TARGET))\
|
---|
| 738 | $(DEFFILE.$(BUILD_TYPE))\
|
---|
| 739 | $(DEFFILE)\
|
---|
| 740 | )))
|
---|
| 741 | $(eval custom_pre := $(strip $(firstword
|
---|
| 742 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 743 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 744 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 745 | $($(target)_CUSTOM_PRE)\
|
---|
| 746 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 747 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 748 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 749 | $(CUSTOM_PRE)\
|
---|
| 750 | )))
|
---|
| 751 | $(eval custom_post := $(strip $(firstword
|
---|
| 752 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 753 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 754 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 755 | $($(target)_CUSTOM_POST)\
|
---|
| 756 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 757 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 758 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 759 | $(CUSTOM_POST)\
|
---|
| 760 | )))
|
---|
[91] | 761 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES)))
|
---|
[72] | 762 |
|
---|
[74] | 763 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
| 764 |
|
---|
| 765 | _OBJS += $(_OBJS_$(target))
|
---|
| 766 | _EXES += $(exe)
|
---|
[75] | 767 | _OUT_FILES += $(exe)
|
---|
[74] | 768 | endef
|
---|
| 769 |
|
---|
| 770 | # Process libraries
|
---|
| 771 | $(foreach target, $(PROGRAMS), $(eval $(def_program)))
|
---|
| 772 |
|
---|
| 773 |
|
---|
| 774 |
|
---|
[72] | 775 | #
|
---|
| 776 | # DLLS
|
---|
| 777 | #
|
---|
| 778 |
|
---|
| 779 |
|
---|
| 780 |
|
---|
| 781 | #
|
---|
[83] | 782 | # SYSMODS
|
---|
[72] | 783 | #
|
---|
| 784 |
|
---|
[83] | 785 | ## System moduler (one).
|
---|
| 786 | # @param $(target) Normalized target (program) name.
|
---|
| 787 | define def_sysmod
|
---|
| 788 | # source -> object
|
---|
| 789 | $(eval $(def_target_sources))
|
---|
[72] | 790 |
|
---|
[110] | 791 | # sysmod
|
---|
[83] | 792 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 793 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 794 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 795 | $(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
|
---|
| 796 | $(eval sys := $(outbase)$(syssuff))
|
---|
| 797 | $(eval objs = $(_OBJS_$(target)))
|
---|
[83] | 798 | $(eval flags :=\
|
---|
| 799 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 800 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 801 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 802 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 803 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 804 | $(LDFLAGS)\
|
---|
| 805 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 806 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 807 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 808 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 809 | $($(target)_LDFLAGS)\
|
---|
| 810 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 811 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 812 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 813 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 814 | )
|
---|
| 815 | $(eval libs :=\
|
---|
[87] | 816 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 817 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 818 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[83] | 819 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 820 | $($(target)_LIBS)\
|
---|
[87] | 821 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 822 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 823 | $(LIBS.$(BUILD_TARGET))\
|
---|
[83] | 824 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 825 | $(LIBS)\
|
---|
| 826 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 827 | $(TOOL_$(tool)_LIBS)\
|
---|
| 828 | )
|
---|
| 829 | $(eval libpath :=\
|
---|
[87] | 830 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 831 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 832 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 833 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 834 | $($(target)_LIBPATH)\
|
---|
[87] | 835 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 836 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 837 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 838 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 839 | $(LIBPATH)\
|
---|
[87] | 840 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 841 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 842 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 843 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 844 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 845 | )
|
---|
| 846 | $(eval dirdep := $(dir $(sys)).dir_created)
|
---|
| 847 | ## @todo fix dependencies
|
---|
| 848 | $(eval deps := )
|
---|
| 849 | #
|
---|
| 850 | $(eval deffile := $(strip $(firstword
|
---|
| 851 | $($(target)_DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 852 | $($(target)_DEFFILE.$(BUILD_TARGET))\
|
---|
| 853 | $($(target)_DEFFILE.$(BUILD_TYPE))\
|
---|
| 854 | $($(target)_DEFFILE)\
|
---|
| 855 | $(DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 856 | $(DEFFILE.$(BUILD_TARGET))\
|
---|
| 857 | $(DEFFILE.$(BUILD_TYPE))\
|
---|
| 858 | $(DEFFILE)\
|
---|
| 859 | )))
|
---|
| 860 | $(eval custom_pre := $(strip $(firstword
|
---|
| 861 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 862 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 863 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 864 | $($(target)_CUSTOM_PRE)\
|
---|
| 865 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 866 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 867 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 868 | $(CUSTOM_PRE)\
|
---|
| 869 | )))
|
---|
| 870 | $(eval custom_post := $(strip $(firstword
|
---|
| 871 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 872 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 873 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 874 | $($(target)_CUSTOM_POST)\
|
---|
| 875 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 876 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 877 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 878 | $(CUSTOM_POST)\
|
---|
| 879 | )))
|
---|
[91] | 880 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES)))
|
---|
[72] | 881 |
|
---|
[106] | 882 | ifndef TOOL_$(tool)_LINK_SYSMOD
|
---|
| 883 | $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
|
---|
| 884 | $$(warning kBuild: tools: \
|
---|
| 885 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 886 | 2 $($(target)_$(source)TOOL) \
|
---|
| 887 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 888 | 4 $($(target)_TOOL) \
|
---|
| 889 | 5 $($(source)TOOL) \
|
---|
| 890 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 891 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 892 | 8 $(TOOL) )
|
---|
| 893 | endif
|
---|
| 894 |
|
---|
[83] | 895 | $(eval $(TOOL_$(tool)_LINK_SYSMOD))
|
---|
| 896 |
|
---|
| 897 | _OBJS += $(_OBJS_$(target))
|
---|
| 898 | _SYSMODS += $(sys)
|
---|
| 899 | _OUT_FILES += $(sys)
|
---|
| 900 | endef
|
---|
| 901 |
|
---|
| 902 | # Process libraries
|
---|
| 903 | $(foreach target, $(SYSMODS), $(eval $(def_sysmod)))
|
---|
| 904 |
|
---|
| 905 |
|
---|
| 906 |
|
---|
[72] | 907 | #
|
---|
| 908 | # OTHERS
|
---|
| 909 | #
|
---|
| 910 |
|
---|
| 911 |
|
---|
| 912 |
|
---|
| 913 | #
|
---|
| 914 | # DOCS
|
---|
| 915 | #
|
---|
| 916 |
|
---|
| 917 |
|
---|
| 918 | #
|
---|
| 919 | # Directories.
|
---|
| 920 | #
|
---|
[83] | 921 | _OUTPUT_FILES := $(_OBJS) $(_LIBS) $(_EXES) $(_DLLS) $(_SYSMODS)
|
---|
[75] | 922 | _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(dir $(_OUTPUT_FILES))))
|
---|
[72] | 923 |
|
---|
| 924 | define def_createdir
|
---|
| 925 | $(dirfile):
|
---|
[106] | 926 | $(call MSG_Ltarget,Creating directory $$(@D))
|
---|
[72] | 927 | $(MKDIR) -p $$(@D)
|
---|
[73] | 928 | @echo dir_created > $$@
|
---|
[72] | 929 | endef
|
---|
| 930 |
|
---|
| 931 | $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
|
---|
| 932 |
|
---|
[75] | 933 |
|
---|
[72] | 934 | #
|
---|
[75] | 935 | # Include dependency files.
|
---|
[72] | 936 | #
|
---|
[75] | 937 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
[72] | 938 |
|
---|
[75] | 939 |
|
---|
| 940 | #
|
---|
| 941 | # PASSES (including directory and makefile walking)
|
---|
| 942 | #
|
---|
| 943 | # Do all the default passes if it's unspecified.
|
---|
[72] | 944 |
|
---|
[98] | 945 | #PASSES ?= needed libraries binaries others publish
|
---|
| 946 | PASSES ?= libraries binaries
|
---|
| 947 |
|
---|
[75] | 948 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 949 | # The user can overload this list.
|
---|
| 950 | DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
|
---|
[72] | 951 |
|
---|
[75] | 952 | ## Subdir
|
---|
| 953 | # @param $(pass) Lowercase pass name.
|
---|
| 954 | # @param $(PASS) Uppercase pass name.
|
---|
| 955 | # @param $(subdir) Subdirectory
|
---|
| 956 | # @param $(tag) tag to attach to the rule name.
|
---|
| 957 | define def_pass_subdir
|
---|
| 958 | pass_$(pass)$(tag)::
|
---|
| 959 | $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
| 960 | endef
|
---|
[72] | 961 |
|
---|
[75] | 962 | ## Submakefile
|
---|
| 963 | # @param $(pass) Lowercase pass name.
|
---|
| 964 | # @param $(PASS) Uppercase pass name.
|
---|
| 965 | # @param $(makefile) Makefile.
|
---|
| 966 | # @param $(tag) tag to attach to the rule name.
|
---|
| 967 | define def_pass_makefile
|
---|
| 968 | pass_$(pass)$(tag)::
|
---|
| 969 | $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
| 970 | endef
|
---|
[73] | 971 |
|
---|
[74] | 972 |
|
---|
[75] | 973 | ## Execute a pass.
|
---|
| 974 | # @param $(pass) Lowercase pass name.
|
---|
| 975 | # @param $(PASS) Uppercase pass name.
|
---|
| 976 | define def_pass
|
---|
| 977 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS))
|
---|
| 978 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER))
|
---|
| 979 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
|
---|
| 980 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER))
|
---|
| 981 |
|
---|
| 982 | $(eval tag:=_before)
|
---|
| 983 | $(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
| 984 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
| 985 |
|
---|
| 986 | $(eval tag:=_after)
|
---|
| 987 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
| 988 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
| 989 |
|
---|
| 990 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 991 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
| 992 | pass_$(pass): \
|
---|
| 993 | pass_$(pass)_before \
|
---|
| 994 | pass_$(pass)_doit \
|
---|
| 995 | pass_$(pass)_after
|
---|
| 996 |
|
---|
| 997 | endef
|
---|
| 998 |
|
---|
[76] | 999 |
|
---|
[75] | 1000 | ## PASS: needed
|
---|
| 1001 | # This pass builds targets which are required for building the rest.
|
---|
| 1002 | pass_needed_doit: $(_NEEDEDS)
|
---|
| 1003 | pass := needed
|
---|
| 1004 | PASS := NEEDED
|
---|
| 1005 | $(eval $(def_pass))
|
---|
| 1006 |
|
---|
| 1007 | ## PASS: libraries
|
---|
| 1008 | # This pass builds library targets.
|
---|
| 1009 | pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
| 1010 | pass := libraries
|
---|
| 1011 | PASS := LIBRARIES
|
---|
| 1012 | $(eval $(def_pass))
|
---|
| 1013 |
|
---|
| 1014 | ## PASS: binaries
|
---|
[83] | 1015 | # This pass builds binary targets, i.e. programs, dlls, system modules and stuff.
|
---|
| 1016 | pass_binaries_doit: $(_DLLS) $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
|
---|
[75] | 1017 | pass := binaries
|
---|
| 1018 | PASS := BINARIES
|
---|
| 1019 | $(eval $(def_pass))
|
---|
| 1020 |
|
---|
| 1021 | ## PASS: others
|
---|
[83] | 1022 | # This pass builds other targets.
|
---|
[75] | 1023 | pass_others_doit: $(_OTHERS)
|
---|
| 1024 | pass := others
|
---|
| 1025 | PASS := OTHERS
|
---|
| 1026 | $(eval $(def_pass))
|
---|
| 1027 |
|
---|
| 1028 | ## PASS: publish
|
---|
| 1029 | # This pass installs the built entities to a sandbox area.
|
---|
| 1030 | pass_publish_doit: publish
|
---|
| 1031 | publish::
|
---|
| 1032 | pass := publish
|
---|
| 1033 | PASS := PUBLISH
|
---|
[76] | 1034 | # $(sort).. not nice.
|
---|
[75] | 1035 | SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
|
---|
| 1036 | SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
|
---|
| 1037 | MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
|
---|
| 1038 | MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
|
---|
| 1039 | $(eval $(def_pass))
|
---|
| 1040 |
|
---|
| 1041 | ## PASS: packing
|
---|
| 1042 | # This pass processes custom packing rules.
|
---|
| 1043 | pass_packing_doit: packing
|
---|
| 1044 | packing::
|
---|
| 1045 | pass := packing
|
---|
| 1046 | PASS := PACKING
|
---|
| 1047 | $(eval $(def_pass))
|
---|
| 1048 |
|
---|
| 1049 | ## PASS: clean
|
---|
| 1050 | # This pass removes all generated files.
|
---|
| 1051 | pass_clean_doit:
|
---|
| 1052 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES)
|
---|
| 1053 | pass := clean
|
---|
| 1054 | PASS := CLEAN
|
---|
| 1055 | $(eval $(def_pass))
|
---|
| 1056 | clean: pass_clean
|
---|
| 1057 |
|
---|
| 1058 | ## PASS: nothing
|
---|
| 1059 | # This pass just walks the tree.
|
---|
| 1060 | pass_nothing_doit:
|
---|
[106] | 1061 | $(call MSG_Ltarget,Did nothing in $(CURDIR))
|
---|
[75] | 1062 | pass := nothing
|
---|
| 1063 | PASS := NOTHING
|
---|
| 1064 | $(eval $(def_pass))
|
---|
| 1065 | nothing: pass_nothing
|
---|
| 1066 |
|
---|
[78] | 1067 |
|
---|
| 1068 |
|
---|
[75] | 1069 | #
|
---|
| 1070 | # THE MAIN RULES
|
---|
| 1071 | #
|
---|
| 1072 | all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
|
---|
| 1073 |
|
---|
[78] | 1074 | rebuild: clean all_recursive
|
---|
| 1075 |
|
---|
| 1076 |
|
---|
[75] | 1077 | # misc shortcuts.
|
---|
| 1078 | target: needed libraries binaries others
|
---|
| 1079 | objects: $(_OBJS)
|
---|
| 1080 | programs: $(_EXES)
|
---|
| 1081 | dlls: $(_DLLS)
|
---|
[83] | 1082 | sysmods: $(_SYSMODS)
|
---|
[75] | 1083 |
|
---|
| 1084 |
|
---|
[72] | 1085 | # end-of-file-content
|
---|
[106] | 1086 | __footer_kmk__ := target
|
---|
[72] | 1087 | endif # __footer_kmk__
|
---|