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