[72] | 1 | # $Id: footer.kmk 219 2005-02-08 13:50:34Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[189] | 6 | # Copyright (c) 2004 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.
|
---|
[138] | 36 | ALL_TARGETS := \
|
---|
[189] | 37 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
| 38 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
| 39 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
| 40 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
| 41 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
| 42 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 43 |
|
---|
[75] | 44 | # dependency files.
|
---|
| 45 | _DEPFILES :=
|
---|
| 46 |
|
---|
| 47 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 48 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 49 | # required dependency file must add those output files to this variable.
|
---|
| 50 | _OUT_FILES :=
|
---|
| 51 |
|
---|
[72] | 52 | # all of a type
|
---|
[219] | 53 | _OBJS :=
|
---|
| 54 | _LIBS :=
|
---|
| 55 | _DLLS :=
|
---|
| 56 | _PROGRAMS :=
|
---|
| 57 | _SYSMODS :=
|
---|
| 58 | _DIRS :=
|
---|
[189] | 59 | _IMPORT_LIBS :=
|
---|
[72] | 60 |
|
---|
| 61 | # all objs of a specific target
|
---|
| 62 | define def_objs_var
|
---|
[106] | 63 | _OBJS_$target :=
|
---|
[72] | 64 | endef
|
---|
| 65 | $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
|
---|
| 66 |
|
---|
| 67 | #
|
---|
[73] | 68 | # Basic macros
|
---|
| 69 | #
|
---|
| 70 |
|
---|
| 71 | ## Figure out the tool for a source
|
---|
[106] | 72 | # @param $target source file
|
---|
| 73 | # @param $source normalized main target
|
---|
| 74 | # @param $type tooltype
|
---|
[79] | 75 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
[106] | 76 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 77 | $($(target)_$(source)_$(type)TOOL) \
|
---|
| 78 | $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 79 | $($(target)_$(source)_TOOL) \
|
---|
| 80 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 81 | $($(target)_$(type)TOOL) \
|
---|
| 82 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 83 | $($(target)_TOOL) \
|
---|
| 84 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 85 | $($(source)_$(type)TOOL) \
|
---|
| 86 | $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 87 | $($(source)_TOOL) \
|
---|
| 88 | $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 89 | $($(type)TOOL) \
|
---|
| 90 | $(TOOL.$(BUILD_TARGET)) \
|
---|
| 91 | $(TOOL) ))
|
---|
[73] | 92 |
|
---|
[106] | 93 | _SOURCE_TOOL_OLD = $(strip $(firstword \
|
---|
| 94 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 95 | $($(target)_$(source)_$(type)TOOL) $($target_$source_TOOL) \
|
---|
| 96 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 97 | $($(target)_$(type)TOOL) $($target_TOOL) \
|
---|
| 98 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 99 | $($(source)_$(type)TOOL) $($(source)_TOOL) \
|
---|
| 100 | $($(type)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
|
---|
| 101 | $($(type)TOOL) $(TOOL) ))
|
---|
[183] | 102 |
|
---|
[78] | 103 | ## Figure out the tool for a target.
|
---|
[106] | 104 | # @param $target normalized target.
|
---|
| 105 | # @param $source tooltype.
|
---|
[79] | 106 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[106] | 107 | $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 108 | $($(target)_$(source)TOOL) \
|
---|
| 109 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 110 | $($(target)_TOOL) \
|
---|
| 111 | $($(source)TOOL) \
|
---|
| 112 | $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 113 | $(TOOL.$(BUILD_TARGET)) \
|
---|
| 114 | $(TOOL) \
|
---|
[79] | 115 | ))
|
---|
[183] | 116 |
|
---|
[148] | 117 | ## Removes the drive letter from a path (if it has one)
|
---|
| 118 | # @param $1 the path
|
---|
| 119 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
[78] | 120 |
|
---|
[148] | 121 | ## Removes the root slash from a path (if it has one)
|
---|
| 122 | # @param $1 the path
|
---|
| 123 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
| 124 |
|
---|
[73] | 125 | ## Figure out where to put object files.
|
---|
[110] | 126 | # @param $1 source file
|
---|
| 127 | # @param $2 normalized main target
|
---|
[148] | 128 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))
|
---|
[73] | 129 |
|
---|
| 130 | ## Figure out where to put object files.
|
---|
[110] | 131 | # @param $1 real target name.
|
---|
| 132 | # @param $2 normalized main target
|
---|
[148] | 133 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
[73] | 134 |
|
---|
| 135 |
|
---|
| 136 | #
|
---|
[185] | 137 | # Check syntax which leads to weird syntax errors.
|
---|
| 138 | #
|
---|
| 139 |
|
---|
| 140 | ## Check
|
---|
| 141 | # @param $(target) Target name.
|
---|
| 142 | define def_check_target
|
---|
| 143 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
| 144 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
| 145 | endif
|
---|
| 146 | endef
|
---|
| 147 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | #
|
---|
[72] | 151 | # Include templates
|
---|
| 152 | #
|
---|
| 153 | _TEMPLATES := $(TEMPLATE)
|
---|
| 154 | define def_templates
|
---|
| 155 | ifdef $(target)_TEMPLATE
|
---|
| 156 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
| 157 | endif
|
---|
| 158 | endef
|
---|
| 159 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
| 160 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 161 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
| 162 |
|
---|
| 163 | define def_templates_include
|
---|
| 164 | ifndef TEMPLATE_$(template)
|
---|
| 165 | include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
|
---|
| 166 | endif
|
---|
| 167 | endef
|
---|
| 168 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 169 |
|
---|
[74] | 170 |
|
---|
[72] | 171 | #
|
---|
| 172 | # Common Inheritance
|
---|
| 173 | #
|
---|
| 174 |
|
---|
| 175 | ## Inherit defaults property
|
---|
| 176 | # @param $(prop) Property name
|
---|
| 177 | # @param $(target) Target name.
|
---|
| 178 | define def_inherit_defaults_one
|
---|
[74] | 179 | ifndef $(target)_$(prop)
|
---|
[109] | 180 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
[72] | 181 | ifdef $(prop)
|
---|
[105] | 182 | $$(eval $(target)_$(prop) := $($(prop)))
|
---|
[72] | 183 | endif
|
---|
[109] | 184 | ifdef $(prop).$(BUILD_TARGET)
|
---|
| 185 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
|
---|
[72] | 186 | endif
|
---|
[109] | 187 | endif
|
---|
| 188 | endif
|
---|
[72] | 189 | endef
|
---|
| 190 |
|
---|
| 191 | ## Inherit default properties for one target.
|
---|
| 192 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
| 193 | # is inherited from the default properties.
|
---|
| 194 | # @param $(target) Target name
|
---|
[78] | 195 | #
|
---|
[72] | 196 | define def_inherit_defaults
|
---|
| 197 | ifdef $(target)_TEMPLATE
|
---|
[107] | 198 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
|
---|
[109] | 199 | $$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 200 | endif
|
---|
[107] | 201 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
|
---|
[109] | 202 | $$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 203 | endif
|
---|
| 204 | else
|
---|
[109] | 205 | $$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 206 | endif
|
---|
| 207 | endef
|
---|
| 208 | # Inherit default properties.
|
---|
[109] | 209 | # !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
|
---|
[105] | 210 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
[72] | 211 |
|
---|
| 212 |
|
---|
[78] | 213 | ## Inherit one template property in a accumulative manner.
|
---|
[72] | 214 | # @param $(prop) Property name
|
---|
| 215 | # @param $(target) Target name
|
---|
[78] | 216 | # @todo fix the precedence order for some properties.
|
---|
[72] | 217 | define def_inherit_template_one
|
---|
[78] | 218 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 219 | ifndef $(target)_$(prop)
|
---|
[106] | 220 | #$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[105] | 221 | $$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
|
---|
[72] | 222 | endif
|
---|
| 223 | endif
|
---|
[79] | 224 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
| 225 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
[106] | 226 | #$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
[105] | 227 | $$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
|
---|
[79] | 228 | endif
|
---|
| 229 | endif
|
---|
[72] | 230 | endef
|
---|
| 231 |
|
---|
[183] | 232 | ## Inherit one template property.
|
---|
[78] | 233 | # @param $(prop) Property name
|
---|
| 234 | # @param $(target) Target name
|
---|
| 235 | define def_inherit_template_one_accumulate
|
---|
| 236 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[106] | 237 | #$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[105] | 238 | $$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[106] | 239 | #$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[78] | 240 | endif
|
---|
[79] | 241 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
[105] | 242 | #$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
| 243 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
|
---|
[79] | 244 | endif
|
---|
| 245 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
|
---|
[105] | 246 | #$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
|
---|
| 247 | $$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
|
---|
[79] | 248 | endif
|
---|
| 249 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
|
---|
[105] | 250 | #$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
|
---|
| 251 | $$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
|
---|
[79] | 252 | endif
|
---|
[78] | 253 | endef
|
---|
| 254 |
|
---|
[106] | 255 |
|
---|
[72] | 256 | ## Inherit template properties for on target.
|
---|
| 257 | # @param $(target) Target name.
|
---|
| 258 | define def_inherit_template
|
---|
[105] | 259 | $$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
|
---|
| 260 | ,$$(eval $$(def_inherit_template_one)))
|
---|
| 261 | $$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
|
---|
| 262 | ,$$(eval $$(def_inherit_template_one_accumulate)))
|
---|
[72] | 263 | endef
|
---|
| 264 | # Inherit template properties
|
---|
[105] | 265 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
|
---|
[72] | 266 |
|
---|
| 267 |
|
---|
| 268 | #
|
---|
| 269 | # Include tools
|
---|
[183] | 270 | #
|
---|
[72] | 271 | _TOOLS := $(TOOL)
|
---|
| 272 | define def_tools_target_source
|
---|
[78] | 273 | $(foreach tool,\
|
---|
[79] | 274 | $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 275 | $($(source)_TOOL) $($(target)_$(source)_TOOL)\
|
---|
[79] | 276 | $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 277 | $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
|
---|
[79] | 278 | $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 279 | $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
|
---|
[79] | 280 | $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 281 | $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
|
---|
[79] | 282 | $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 283 | $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
|
---|
[79] | 284 | $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 285 | $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
|
---|
| 286 | ,$(eval _TOOLS += $(tool)))
|
---|
[72] | 287 | endef
|
---|
| 288 | define def_tools_target
|
---|
[78] | 289 | $(foreach tool,\
|
---|
[79] | 290 | $($(target)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 291 | $($(target)_TOOL)\
|
---|
[79] | 292 | $($(target)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 293 | $($(target)_CTOOL)\
|
---|
[79] | 294 | $($(target)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 295 | $($(target)_CXXTOOL)\
|
---|
[79] | 296 | $($(target)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 297 | $($(target)_ASTOOL)\
|
---|
[79] | 298 | $($(target)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 299 | $($(target)_ARTOOL)\
|
---|
[79] | 300 | $($(target)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 301 | $($(target)_LDTOOL)\
|
---|
[79] | 302 | ,$(eval _TOOLS += $(tool)))
|
---|
[120] | 303 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)) \
|
---|
| 304 | , $(eval $(def_tools_target_source)))
|
---|
[72] | 305 | endef
|
---|
| 306 | $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
|
---|
| 307 | _TOOLS := $(sort $(_TOOLS))
|
---|
| 308 |
|
---|
| 309 | define def_tools_include
|
---|
| 310 | ifndef TOOL_$(tool)
|
---|
| 311 | include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
|
---|
| 312 | endif
|
---|
| 313 | endef
|
---|
| 314 | $(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
|
---|
| 315 |
|
---|
| 316 |
|
---|
| 317 | #
|
---|
| 318 | # Include SDKs
|
---|
[73] | 319 | #
|
---|
[72] | 320 | _SDKS := $(SDKS)
|
---|
| 321 | define def_sdks_target_source
|
---|
[122] | 322 | $(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_MODE)) \
|
---|
| 323 | $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_MODE)), \
|
---|
[72] | 324 | $(eval _SDKS += $(sdk)))
|
---|
| 325 | endef
|
---|
| 326 | define def_sdks_target
|
---|
[122] | 327 | $(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_MODE))\
|
---|
| 328 | , $(eval _SDKS += $(sdk)))
|
---|
[120] | 329 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))\
|
---|
| 330 | , $(eval $(def_sdks_target_source)))
|
---|
[72] | 331 | endef
|
---|
| 332 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
| 333 | _SDKS := $(sort $(_SDKS))
|
---|
| 334 |
|
---|
[122] | 335 | define def_sdks_include_one
|
---|
[72] | 336 | ifndef SDK_$(sdk)
|
---|
| 337 | include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
|
---|
| 338 | endif
|
---|
| 339 | endef
|
---|
[122] | 340 | $(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one)))
|
---|
[72] | 341 |
|
---|
[73] | 342 | #
|
---|
| 343 | # Object processing.
|
---|
| 344 | #
|
---|
[72] | 345 |
|
---|
[205] | 346 |
|
---|
[73] | 347 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 348 | # @param $(target) Normalized target name.
|
---|
| 349 | # @param $(source) Source file name.
|
---|
| 350 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[72] | 351 | #
|
---|
[73] | 352 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
[105] | 353 | # @remark I now have a clue. Have to use $$ if not.
|
---|
[73] | 354 | define def_target_source_c_cpp_asm
|
---|
[105] | 355 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 356 |
|
---|
[78] | 357 | $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
|
---|
[111] | 358 | $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
|
---|
| 359 | $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 360 | $(eval dirdep := $(dir $(outbase)).dir_created)
|
---|
[73] | 361 | $(eval defs :=\
|
---|
[78] | 362 | $(TOOL_$(tool)_DEFS)\
|
---|
| 363 | $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
|
---|
| 364 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
|
---|
| 365 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 366 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 367 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
| 368 | $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
[78] | 369 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 370 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 371 | $(SDKS),\
|
---|
| 372 | $(SDK_$(sdk)_DEFS)\
|
---|
| 373 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 374 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 375 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 376 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 377 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 378 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 379 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 380 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 381 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 382 | $(DEFS)\
|
---|
| 383 | $(DEFS.$(BUILD_TYPE))\
|
---|
[78] | 384 | $(DEFS.$(BUILD_TARGET))\
|
---|
| 385 | $(DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 386 | $(DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 387 | $($(type)DEFS)\
|
---|
| 388 | $($(type)DEFS.$(BUILD_TYPE))\
|
---|
| 389 | $($(type)DEFS.$(BUILD_TARGET))\
|
---|
| 390 | $($(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 391 | $($(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 392 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 393 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 394 | $($(target)_SDKS),\
|
---|
| 395 | $(SDK_$(sdk)_DEFS)\
|
---|
| 396 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 397 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 398 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 399 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 400 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 401 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 402 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 403 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 404 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 405 | $($(target)_DEFS)\
|
---|
| 406 | $($(target)_DEFS.$(BUILD_TYPE))\
|
---|
| 407 | $($(target)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 408 | $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 409 | $($(target)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 410 | $($(target)_$(type)DEFS)\
|
---|
| 411 | $($(target)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 412 | $($(target)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 413 | $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 414 | $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 415 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 416 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 417 | $($(source)_SDKS),\
|
---|
| 418 | $(SDK_$(sdk)_DEFS)\
|
---|
| 419 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 420 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 421 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 422 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 423 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 424 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 425 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 426 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 427 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 428 | $($(source)_DEFS)\
|
---|
| 429 | $($(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 430 | $($(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 431 | $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 432 | $($(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 433 | $($(source)_$(type)DEFS)\
|
---|
[74] | 434 | $($(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 435 | $($(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 436 | $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 437 | $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 438 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 439 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 440 | $($(target)_$(source)_SDKS),\
|
---|
| 441 | $(SDK_$(sdk)_DEFS)\
|
---|
| 442 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 443 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 444 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 445 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 446 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 447 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 448 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 449 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 450 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 451 | $($(target)_$(source)_DEFS)\
|
---|
| 452 | $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 453 | $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 454 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 455 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 456 | $($(target)_$(source)_$(type)DEFS)\
|
---|
| 457 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 458 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 459 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 460 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 461 | )
|
---|
| 462 | $(eval incs :=\
|
---|
[78] | 463 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 464 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 465 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 466 | $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 467 | $($(target)_$(source)_$(type)INCS)\
|
---|
[78] | 468 | $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 469 | $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 470 | $($(target)_$(source)_INCS.$(BUILD_TARGET))\
|
---|
| 471 | $($(target)_$(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 472 | $($(target)_$(source)_INCS)\
|
---|
[78] | 473 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 474 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
[133] | 475 | $($(target)_$(source)_SDKS),\
|
---|
[78] | 476 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 477 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 478 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 479 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 480 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 481 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 482 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 483 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 484 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 485 | $(SDK_$(sdk)_INCS))\
|
---|
| 486 | $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 487 | $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 488 | $($(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 489 | $($(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 490 | $($(source)_$(type)INCS)\
|
---|
[78] | 491 | $($(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 492 | $($(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 493 | $($(source)_INCS.$(BUILD_TARGET))\
|
---|
| 494 | $($(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 495 | $($(source)_INCS)\
|
---|
[78] | 496 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 497 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 498 | $($(source)_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 | $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 510 | $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 511 | $($(target)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 512 | $($(target)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 513 | $($(target)_$(type)INCS)\
|
---|
[78] | 514 | $($(target)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 515 | $($(target)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 516 | $($(target)_INCS.$(BUILD_TARGET))\
|
---|
| 517 | $($(target)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 518 | $($(target)_INCS)\
|
---|
[78] | 519 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 520 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 521 | $($(target)_SDKS),\
|
---|
| 522 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 523 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 524 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 525 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 526 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 527 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 528 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 529 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 530 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 531 | $(SDK_$(sdk)_INCS))\
|
---|
| 532 | $(INCS.$(BUILD_TARGET_CPU))\
|
---|
| 533 | $(INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 534 | $(INCS.$(BUILD_TARGET))\
|
---|
| 535 | $(INCS.$(BUILD_TYPE))\
|
---|
[73] | 536 | $(INCS)\
|
---|
[78] | 537 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 538 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 539 | $(SDKS),\
|
---|
| 540 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 541 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 542 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 543 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 544 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 545 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 546 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 547 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 548 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 549 | $(SDK_$(sdk)_INCS))\
|
---|
| 550 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 551 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 552 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 553 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 554 | $(TOOL_$(tool)_$(type)INCS)\
|
---|
| 555 | )
|
---|
| 556 | $(eval flags :=\
|
---|
| 557 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
| 558 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 559 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 560 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 561 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 562 | $($(type)FLAGS)\
|
---|
| 563 | $($(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 564 | $($(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 565 | $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 566 | $($(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 567 | $($(target)_$(type)FLAGS)\
|
---|
| 568 | $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 569 | $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 570 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 571 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 572 | $($(source)_$(type)FLAGS)\
|
---|
| 573 | $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 574 | $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 575 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 576 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 577 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
| 578 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 579 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 580 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 581 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 582 | )
|
---|
[74] | 583 | $(eval objsuff := $(firstword \
|
---|
| 584 | $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 585 | $($(target)_$(source)_OBJSUFF)\
|
---|
| 586 | $($(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 587 | $($(source)_OBJSUFF)\
|
---|
| 588 | $($(target)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 589 | $($(target)_OBJSUFF)\
|
---|
| 590 | $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
|
---|
| 591 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
| 592 | $(SUFF_OBJ)\
|
---|
| 593 | ))
|
---|
[73] | 594 | $(eval obj := $(outbase)$(objsuff))
|
---|
[74] | 595 | $(eval dep := $(outbase)$(SUFF_DEP))
|
---|
[184] | 596 | $(eval deps := \
|
---|
| 597 | $($(target)_$(source)_DEPS)\
|
---|
| 598 | $($(target)_$(source)_DEPS.$(BUILD_TYPE))\
|
---|
| 599 | $($(target)_$(source)_DEPS.$(BUILD_TARGET))\
|
---|
| 600 | $($(target)_$(source)_DEPS.$(BUILD_TARGET_ARCH))\
|
---|
| 601 | $($(target)_$(source)_DEPS.$(BUILD_TARGET_CPU))\
|
---|
| 602 | $($(source)_DEPS)\
|
---|
| 603 | $($(source)_DEPS.$(BUILD_TYPE))\
|
---|
| 604 | $($(source)_DEPS.$(BUILD_TARGET))\
|
---|
| 605 | $($(target)_DEPS)\
|
---|
| 606 | $($(target)_DEPS.$(BUILD_TARGET_ARCH))\
|
---|
| 607 | $($(target)_DEPS.$(BUILD_TARGET_CPU)))
|
---|
[73] | 608 |
|
---|
[184] | 609 |
|
---|
| 610 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
[97] | 611 | ifndef TOOL_$(tool)_COMPILE_$(type)
|
---|
| 612 | $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
|
---|
| 613 | $$(warning kBuild: tools: \
|
---|
[106] | 614 | 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 615 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
| 616 | 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 617 | 4 $($(target)_$(source)_TOOL) \
|
---|
| 618 | 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 619 | 6 $($(target)_$(type)TOOL) \
|
---|
| 620 | 7 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 621 | 8 $($(target)_TOOL) \
|
---|
| 622 | 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 623 | 10 $($(source)_$(type)TOOL) \
|
---|
| 624 | 11 $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 625 | 12 $($(source)_TOOL) \
|
---|
| 626 | 13 $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 627 | 14 $($(type)TOOL) \
|
---|
| 628 | 15 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 629 | 16 $(TOOL) )
|
---|
[97] | 630 | endif
|
---|
[73] | 631 | $(eval $(TOOL_$(tool)_COMPILE_$(type)))
|
---|
| 632 |
|
---|
[207] | 633 | $$(basename $$(notdir $$(obj))).o::
|
---|
[219] | 634 | + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
|
---|
[207] | 635 | $$(basename $$(notdir $$(obj))).obj::
|
---|
[219] | 636 | + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
|
---|
[205] | 637 |
|
---|
[73] | 638 | $(eval _OBJS_$(target) += $(obj))
|
---|
| 639 | $(eval _DEPFILES += $(dep))
|
---|
| 640 |
|
---|
| 641 | endef
|
---|
| 642 |
|
---|
| 643 | ## Generic macro for processing all target sources.
|
---|
[74] | 644 | # @param $(target) Normalized target name.
|
---|
[73] | 645 | define def_target_sources
|
---|
| 646 | #$ (warning def_target_sources)
|
---|
| 647 | # C sources
|
---|
[120] | 648 | $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 649 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 650 |
|
---|
| 651 | # C++ sources
|
---|
[120] | 652 | $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 653 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 654 |
|
---|
| 655 | # ASM sources
|
---|
[120] | 656 | $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 657 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 658 | endef
|
---|
| 659 |
|
---|
| 660 |
|
---|
| 661 | #
|
---|
[219] | 662 | # NEEDED
|
---|
| 663 | #
|
---|
| 664 |
|
---|
| 665 | ## Needed (one).
|
---|
| 666 | # @param $(target) Normalized target (program) name.
|
---|
| 667 | define def_needed
|
---|
| 668 | # basics
|
---|
| 669 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
| 670 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 671 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 672 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(HOSTSUFF_EXE)))
|
---|
| 673 | $(eval exe := $(outbase)$(exesuff))
|
---|
| 674 | $(eval TARGET_$(target) := $(exe))
|
---|
| 675 |
|
---|
| 676 | # source -> object
|
---|
| 677 | $(eval $(def_target_sources))
|
---|
| 678 |
|
---|
| 679 | # more library stuff.
|
---|
| 680 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
| 681 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 682 | $(eval objs = $(_OBJS_$(target)))
|
---|
| 683 | $(eval flags :=\
|
---|
| 684 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 685 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 686 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 687 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 688 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 689 | $(LDFLAGS)\
|
---|
| 690 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
| 691 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 692 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 693 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 694 | $($(target)_LDFLAGS)\
|
---|
| 695 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 696 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 697 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 698 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 699 | )
|
---|
| 700 | $(eval libs :=\
|
---|
| 701 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 702 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 703 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
| 704 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 705 | $($(target)_LIBS)\
|
---|
| 706 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 707 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 708 | $($(target)_SDKS),\
|
---|
| 709 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 710 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 711 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 712 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 713 | $(SDK_$(sdk)_LIBS))\
|
---|
| 714 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 715 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 716 | $(LIBS.$(BUILD_TARGET))\
|
---|
| 717 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 718 | $(LIBS)\
|
---|
| 719 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 720 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 721 | $(SDKS),\
|
---|
| 722 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 723 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 724 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 725 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 726 | $(SDK_$(sdk)_LIBS))\
|
---|
| 727 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 728 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 729 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
| 730 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 731 | $(TOOL_$(tool)_LIBS)\
|
---|
| 732 | )
|
---|
| 733 | $(eval libpath :=\
|
---|
| 734 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 735 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 736 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 737 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 738 | $($(target)_LIBPATH)\
|
---|
| 739 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 740 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 741 | $($(target)_SDKS),\
|
---|
| 742 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 743 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 744 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 745 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 746 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 747 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 748 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 749 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
| 750 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 751 | $(LIBPATH)\
|
---|
| 752 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 753 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 754 | $(SDKS),\
|
---|
| 755 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 756 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 757 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 758 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 759 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 760 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 761 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 762 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 763 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 764 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 765 | )
|
---|
| 766 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
| 767 | ## @todo fix dependencies
|
---|
| 768 | $(eval deps := $($(target)_DEPS))
|
---|
| 769 | #
|
---|
| 770 | $(eval custom_pre := $(strip $(firstword
|
---|
| 771 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 772 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 773 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 774 | $($(target)_CUSTOM_PRE)\
|
---|
| 775 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 776 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 777 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 778 | $(CUSTOM_PRE)\
|
---|
| 779 | )))
|
---|
| 780 | $(eval custom_post := $(strip $(firstword
|
---|
| 781 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 782 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 783 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 784 | $($(target)_CUSTOM_POST)\
|
---|
| 785 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 786 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 787 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 788 | $(CUSTOM_POST)\
|
---|
| 789 | )))
|
---|
| 790 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
| 791 |
|
---|
| 792 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
| 793 | # publish rule (still need work)
|
---|
| 794 | ifndef $(target)_INST
|
---|
| 795 | $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
|
---|
| 796 | $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
|
---|
| 797 | $(CP) $(exe) $(pubexe)
|
---|
| 798 |
|
---|
| 799 | _NEEDED += $(pubexe)
|
---|
| 800 | _OUT_FILES += $(exe) $(pubexe)
|
---|
| 801 | else
|
---|
| 802 | _NEEDED += $(exe)
|
---|
| 803 | _OUT_FILES += $(exe)
|
---|
| 804 | endif
|
---|
| 805 | _OBJS += $(_OBJS_$(target))
|
---|
| 806 | endef
|
---|
| 807 |
|
---|
| 808 | # Process needed.
|
---|
| 809 | $(foreach target, $(NEEDED) $(NEEDED.$(BUILD_TARGET)), $(eval $(def_needed)))
|
---|
| 810 |
|
---|
| 811 |
|
---|
| 812 |
|
---|
| 813 | #
|
---|
[72] | 814 | # LIBRARIES
|
---|
[73] | 815 | #
|
---|
[72] | 816 |
|
---|
| 817 | ## Library (one).
|
---|
[74] | 818 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 819 | define def_lib
|
---|
[145] | 820 | # library basics
|
---|
[78] | 821 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
| 822 | ifeq ($(tool),)
|
---|
| 823 | $$(error kBuild: Library target $(target) doesn't have a tool defined!)
|
---|
| 824 | endif
|
---|
[111] | 825 | ## @todo prefix
|
---|
| 826 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 827 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[126] | 828 | $(eval libsuff := $(firstword\
|
---|
| 829 | $($(target)_LIBSUFF.$(BUILD_TARGET))\
|
---|
| 830 | $($(target)_LIBSUFF)\
|
---|
| 831 | $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
|
---|
| 832 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
| 833 | $(SUFF_LIB)\
|
---|
| 834 | ))
|
---|
[111] | 835 | $(eval lib := $(outbase)$(libsuff))
|
---|
[183] | 836 | $(eval TARGET_$(target) := $(lib))
|
---|
[145] | 837 |
|
---|
| 838 | # source -> object
|
---|
| 839 | $(eval $(def_target_sources))
|
---|
| 840 |
|
---|
| 841 | # library linking
|
---|
| 842 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
[146] | 843 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[74] | 844 | $(eval flags :=\
|
---|
| 845 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
| 846 | $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 847 | $(ARFLAGS)\
|
---|
| 848 | $(ARFLAGS.$(BUILD_TYPE))\
|
---|
| 849 | $($(target)_ARFLAGS)\
|
---|
| 850 | $($(target)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 851 | )
|
---|
[73] | 852 | $(eval objs = $(_OBJS_$(target)))
|
---|
[120] | 853 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[73] | 854 | $(eval dirdep := $(dir $(lib)).dir_created)
|
---|
[78] | 855 | ## @todo fix dependencies on makefiles an such
|
---|
[184] | 856 | $(eval deps := $($(target)_DEPS))
|
---|
[72] | 857 |
|
---|
[73] | 858 | $(eval $(TOOL_$(tool)_LINK_LIBRARY))
|
---|
[72] | 859 |
|
---|
[126] | 860 | # publish rule (still need work)
|
---|
[131] | 861 | ifndef $(target)_NOINST
|
---|
[126] | 862 | $(eval publib := $(PATH_LIB)/$(notdir $(lib)))
|
---|
| 863 | $(publib) : $(lib) $(dir $(publib)).dir_created
|
---|
[130] | 864 | $(CP) $(lib) $(publib)
|
---|
[183] | 865 |
|
---|
[126] | 866 | _LIBS += $(publib)
|
---|
| 867 | _OUT_FILES += $(lib) $(publib)
|
---|
| 868 | else
|
---|
[73] | 869 | _LIBS += $(lib)
|
---|
[75] | 870 | _OUT_FILES += $(lib)
|
---|
[126] | 871 | endif
|
---|
| 872 | _OBJS += $(_OBJS_$(target))
|
---|
[72] | 873 | endef
|
---|
| 874 |
|
---|
| 875 | # Process libraries
|
---|
[138] | 876 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
|
---|
[72] | 877 |
|
---|
| 878 |
|
---|
| 879 |
|
---|
| 880 | #
|
---|
[189] | 881 | # DLLS
|
---|
[72] | 882 | #
|
---|
| 883 |
|
---|
[189] | 884 | ## DLL (one).
|
---|
[74] | 885 | # @param $(target) Normalized target (program) name.
|
---|
[189] | 886 | define def_dll
|
---|
| 887 | # dllmod basics
|
---|
[78] | 888 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 889 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 890 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[189] | 891 | $(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
|
---|
| 892 | $(eval dll := $(outbase)$(dllsuff))
|
---|
| 893 | $(eval TARGET_$(target) := $(dll))
|
---|
[145] | 894 |
|
---|
| 895 | # source -> object
|
---|
| 896 | $(eval $(def_target_sources))
|
---|
| 897 |
|
---|
[189] | 898 | # dllmod linking.
|
---|
[145] | 899 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 900 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[111] | 901 | $(eval objs = $(_OBJS_$(target)))
|
---|
[74] | 902 | $(eval flags :=\
|
---|
| 903 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 904 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 905 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 906 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 907 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 908 | $(LDFLAGS)\
|
---|
| 909 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 910 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 911 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 912 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 913 | $($(target)_LDFLAGS)\
|
---|
| 914 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 915 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 916 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 917 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 918 | )
|
---|
| 919 | $(eval libs :=\
|
---|
[87] | 920 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 921 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 922 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[74] | 923 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 924 | $($(target)_LIBS)\
|
---|
[122] | 925 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 926 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 927 | $($(target)_SDKS),\
|
---|
| 928 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 929 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 930 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 931 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 932 | $(SDK_$(sdk)_LIBS))\
|
---|
[87] | 933 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 934 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 935 | $(LIBS.$(BUILD_TARGET))\
|
---|
[74] | 936 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 937 | $(LIBS)\
|
---|
[122] | 938 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 939 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 940 | $(SDKS),\
|
---|
| 941 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 942 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 943 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 944 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 945 | $(SDK_$(sdk)_LIBS))\
|
---|
| 946 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 947 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 948 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
[74] | 949 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 950 | $(TOOL_$(tool)_LIBS)\
|
---|
| 951 | )
|
---|
| 952 | $(eval libpath :=\
|
---|
[87] | 953 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 954 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 955 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 956 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 957 | $($(target)_LIBPATH)\
|
---|
[122] | 958 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 959 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 960 | $($(target)_SDKS),\
|
---|
| 961 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 962 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 963 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 964 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 965 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 966 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 967 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 968 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 969 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 970 | $(LIBPATH)\
|
---|
[122] | 971 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 972 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 973 | $(SDKS),\
|
---|
| 974 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 975 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 976 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 977 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 978 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 979 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 980 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 981 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 982 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 983 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 984 | )
|
---|
[189] | 985 | $(eval dirdep := $(dir $(dll)).dir_created)
|
---|
[74] | 986 | ## @todo fix dependencies
|
---|
[184] | 987 | $(eval deps := $($(target)_DEPS))
|
---|
[74] | 988 | #
|
---|
| 989 | $(eval custom_pre := $(strip $(firstword
|
---|
| 990 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 991 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 992 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 993 | $($(target)_CUSTOM_PRE)\
|
---|
| 994 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 995 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 996 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 997 | $(CUSTOM_PRE)\
|
---|
| 998 | )))
|
---|
| 999 | $(eval custom_post := $(strip $(firstword
|
---|
| 1000 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1001 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1002 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1003 | $($(target)_CUSTOM_POST)\
|
---|
| 1004 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1005 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1006 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1007 | $(CUSTOM_POST)\
|
---|
| 1008 | )))
|
---|
[120] | 1009 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 1010 |
|
---|
[189] | 1011 | ifndef TOOL_$(tool)_LINK_DLL
|
---|
| 1012 | $$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
|
---|
| 1013 | $$(warning kBuild: tools: \
|
---|
| 1014 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1015 | 2 $($(target)_$(source)TOOL) \
|
---|
| 1016 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 1017 | 4 $($(target)_TOOL) \
|
---|
| 1018 | 5 $($(source)TOOL) \
|
---|
| 1019 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1020 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 1021 | 8 $(TOOL) )
|
---|
| 1022 | endif
|
---|
| 1023 |
|
---|
| 1024 | $(eval $(TOOL_$(tool)_LINK_DLL))
|
---|
| 1025 |
|
---|
| 1026 |
|
---|
[130] | 1027 | # publish rule (still need work)
|
---|
[131] | 1028 | ifndef $(target)_NOINST
|
---|
[189] | 1029 | $(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
|
---|
| 1030 | $(pubdll) : $(dll) $(dir $(pubdll)).dir_created
|
---|
| 1031 | $(CP) $(dll) $(pubdll)
|
---|
[183] | 1032 |
|
---|
[189] | 1033 | $(eval TARGET_PUB_$(target) := $(pubdll))
|
---|
| 1034 | _DLLS += $(pubdll)
|
---|
| 1035 | _OUT_FILES += $(dll) $(pubdll)
|
---|
[130] | 1036 | else
|
---|
[189] | 1037 | _DLLS += $(dll)
|
---|
| 1038 | _OUT_FILES += $(dll)
|
---|
[130] | 1039 | endif
|
---|
[74] | 1040 | _OBJS += $(_OBJS_$(target))
|
---|
| 1041 | endef
|
---|
| 1042 |
|
---|
[189] | 1043 | # Process dlls
|
---|
| 1044 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
|
---|
[74] | 1045 |
|
---|
| 1046 |
|
---|
| 1047 |
|
---|
[72] | 1048 | #
|
---|
[189] | 1049 | # Process import libraries.
|
---|
[72] | 1050 | #
|
---|
[219] | 1051 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 1052 | # - On other platforms they are fake DLLs.
|
---|
| 1053 | ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
|
---|
| 1054 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_lib)))
|
---|
| 1055 | else
|
---|
| 1056 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_dll)))
|
---|
| 1057 | endif
|
---|
| 1058 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval _IMPORT_LIBS += $(firstword $(TARGET_PUB_$(target)) $(TARGET_$(target)))))
|
---|
[72] | 1059 |
|
---|
[219] | 1060 |
|
---|
[189] | 1061 |
|
---|
| 1062 | #
|
---|
| 1063 | # PROGRAMS
|
---|
| 1064 | #
|
---|
| 1065 |
|
---|
| 1066 | ## Program (one).
|
---|
[130] | 1067 | # @param $(target) Normalized target (program) name.
|
---|
[189] | 1068 | define def_program
|
---|
| 1069 | # basics
|
---|
[130] | 1070 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
| 1071 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 1072 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[189] | 1073 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
|
---|
| 1074 | $(eval exe := $(outbase)$(exesuff))
|
---|
| 1075 | $(eval TARGET_$(target) := $(exe))
|
---|
[145] | 1076 |
|
---|
| 1077 | # source -> object
|
---|
| 1078 | $(eval $(def_target_sources))
|
---|
| 1079 |
|
---|
[189] | 1080 | # more library stuff.
|
---|
[145] | 1081 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 1082 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[130] | 1083 | $(eval objs = $(_OBJS_$(target)))
|
---|
| 1084 | $(eval flags :=\
|
---|
| 1085 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 1086 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 1087 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1088 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1089 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 1090 | $(LDFLAGS)\
|
---|
| 1091 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
| 1092 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1093 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1094 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 1095 | $($(target)_LDFLAGS)\
|
---|
| 1096 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 1097 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1098 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1099 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 1100 | )
|
---|
| 1101 | $(eval libs :=\
|
---|
| 1102 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1103 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1104 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
| 1105 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 1106 | $($(target)_LIBS)\
|
---|
| 1107 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1108 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1109 | $($(target)_SDKS),\
|
---|
| 1110 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1111 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1112 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1113 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1114 | $(SDK_$(sdk)_LIBS))\
|
---|
| 1115 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1116 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1117 | $(LIBS.$(BUILD_TARGET))\
|
---|
| 1118 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 1119 | $(LIBS)\
|
---|
| 1120 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1121 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1122 | $(SDKS),\
|
---|
| 1123 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1124 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1125 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1126 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1127 | $(SDK_$(sdk)_LIBS))\
|
---|
| 1128 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1129 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1130 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
| 1131 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 1132 | $(TOOL_$(tool)_LIBS)\
|
---|
| 1133 | )
|
---|
| 1134 | $(eval libpath :=\
|
---|
| 1135 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1136 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1137 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1138 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1139 | $($(target)_LIBPATH)\
|
---|
| 1140 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1141 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1142 | $($(target)_SDKS),\
|
---|
| 1143 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1144 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1145 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1146 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1147 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 1148 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1149 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1150 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
| 1151 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 1152 | $(LIBPATH)\
|
---|
| 1153 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1154 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1155 | $(SDKS),\
|
---|
| 1156 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1157 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1158 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1159 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1160 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 1161 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1162 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1163 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1164 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1165 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 1166 | )
|
---|
[189] | 1167 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
[130] | 1168 | ## @todo fix dependencies
|
---|
[184] | 1169 | $(eval deps := $($(target)_DEPS))
|
---|
[130] | 1170 | #
|
---|
| 1171 | $(eval custom_pre := $(strip $(firstword
|
---|
| 1172 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1173 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1174 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1175 | $($(target)_CUSTOM_PRE)\
|
---|
| 1176 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1177 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1178 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1179 | $(CUSTOM_PRE)\
|
---|
| 1180 | )))
|
---|
| 1181 | $(eval custom_post := $(strip $(firstword
|
---|
| 1182 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1183 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1184 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1185 | $($(target)_CUSTOM_POST)\
|
---|
| 1186 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1187 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1188 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1189 | $(CUSTOM_POST)\
|
---|
| 1190 | )))
|
---|
| 1191 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 1192 |
|
---|
[189] | 1193 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
[130] | 1194 | # publish rule (still need work)
|
---|
[131] | 1195 | ifndef $(target)_NOINST
|
---|
[189] | 1196 | $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
|
---|
| 1197 | $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
|
---|
| 1198 | $(CP) $(exe) $(pubexe)
|
---|
[183] | 1199 |
|
---|
[219] | 1200 | _PROGRAMS += $(pubexe)
|
---|
[189] | 1201 | _OUT_FILES += $(exe) $(pubexe)
|
---|
[130] | 1202 | else
|
---|
[219] | 1203 | _PROGRAMS += $(exe)
|
---|
[189] | 1204 | _OUT_FILES += $(exe)
|
---|
[130] | 1205 | endif
|
---|
| 1206 | _OBJS += $(_OBJS_$(target))
|
---|
| 1207 | endef
|
---|
| 1208 |
|
---|
[189] | 1209 | # Process libraries
|
---|
| 1210 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
|
---|
[130] | 1211 |
|
---|
| 1212 |
|
---|
[189] | 1213 |
|
---|
[72] | 1214 | #
|
---|
[83] | 1215 | # SYSMODS
|
---|
[72] | 1216 | #
|
---|
| 1217 |
|
---|
[130] | 1218 | ## System module (one).
|
---|
[83] | 1219 | # @param $(target) Normalized target (program) name.
|
---|
| 1220 | define def_sysmod
|
---|
[145] | 1221 | # sysmod basics
|
---|
[83] | 1222 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 1223 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 1224 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1225 | $(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
|
---|
| 1226 | $(eval sys := $(outbase)$(syssuff))
|
---|
[183] | 1227 | $(eval TARGET_$(target) := $(sys))
|
---|
[145] | 1228 |
|
---|
| 1229 | # source -> object
|
---|
| 1230 | $(eval $(def_target_sources))
|
---|
| 1231 |
|
---|
| 1232 | # sysmod linking
|
---|
| 1233 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 1234 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[111] | 1235 | $(eval objs = $(_OBJS_$(target)))
|
---|
[83] | 1236 | $(eval flags :=\
|
---|
| 1237 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 1238 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1239 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1240 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1241 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1242 | $(LDFLAGS)\
|
---|
| 1243 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1244 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1245 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1246 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1247 | $($(target)_LDFLAGS)\
|
---|
| 1248 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1249 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1250 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1251 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1252 | )
|
---|
| 1253 | $(eval libs :=\
|
---|
[87] | 1254 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1255 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1256 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1257 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 1258 | $($(target)_LIBS)\
|
---|
[122] | 1259 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1260 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1261 | $($(target)_SDKS),\
|
---|
| 1262 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1263 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1264 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1265 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1266 | $(SDK_$(sdk)_LIBS))\
|
---|
[87] | 1267 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1268 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1269 | $(LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1270 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 1271 | $(LIBS)\
|
---|
[122] | 1272 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1273 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1274 | $(SDKS),\
|
---|
| 1275 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1276 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1277 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1278 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1279 | $(SDK_$(sdk)_LIBS))\
|
---|
| 1280 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1281 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1282 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1283 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 1284 | $(TOOL_$(tool)_LIBS)\
|
---|
| 1285 | )
|
---|
| 1286 | $(eval libpath :=\
|
---|
[87] | 1287 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1288 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1289 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1290 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1291 | $($(target)_LIBPATH)\
|
---|
[122] | 1292 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1293 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1294 | $($(target)_SDKS),\
|
---|
| 1295 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1296 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1297 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1298 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1299 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 1300 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1301 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1302 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1303 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 1304 | $(LIBPATH)\
|
---|
[122] | 1305 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1306 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1307 | $(SDKS),\
|
---|
| 1308 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1309 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1310 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1311 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1312 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 1313 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1314 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1315 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1316 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1317 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 1318 | )
|
---|
| 1319 | $(eval dirdep := $(dir $(sys)).dir_created)
|
---|
| 1320 | ## @todo fix dependencies
|
---|
[184] | 1321 | $(eval deps := $($(target)_DEPS))
|
---|
[83] | 1322 | #
|
---|
| 1323 | $(eval custom_pre := $(strip $(firstword
|
---|
| 1324 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1325 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1326 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1327 | $($(target)_CUSTOM_PRE)\
|
---|
| 1328 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1329 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1330 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1331 | $(CUSTOM_PRE)\
|
---|
| 1332 | )))
|
---|
| 1333 | $(eval custom_post := $(strip $(firstword
|
---|
| 1334 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1335 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1336 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1337 | $($(target)_CUSTOM_POST)\
|
---|
| 1338 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1339 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1340 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1341 | $(CUSTOM_POST)\
|
---|
| 1342 | )))
|
---|
[120] | 1343 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 1344 |
|
---|
[106] | 1345 | ifndef TOOL_$(tool)_LINK_SYSMOD
|
---|
| 1346 | $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
|
---|
| 1347 | $$(warning kBuild: tools: \
|
---|
| 1348 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1349 | 2 $($(target)_$(source)TOOL) \
|
---|
| 1350 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 1351 | 4 $($(target)_TOOL) \
|
---|
| 1352 | 5 $($(source)TOOL) \
|
---|
| 1353 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1354 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 1355 | 8 $(TOOL) )
|
---|
[183] | 1356 | endif
|
---|
[106] | 1357 |
|
---|
[83] | 1358 | $(eval $(TOOL_$(tool)_LINK_SYSMOD))
|
---|
| 1359 |
|
---|
[130] | 1360 | # publish rule (still need work)
|
---|
[131] | 1361 | ifndef $(target)_NOINST
|
---|
| 1362 | $(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
|
---|
| 1363 | $(pubsys): $(sys) $(dir $(pubsys)).dir_created
|
---|
[130] | 1364 | $(CP) $(sys) $(pubsys)
|
---|
[183] | 1365 |
|
---|
[131] | 1366 | $(eval _SYSMODS += $(pubsys))
|
---|
| 1367 | $(eval _OUT_FILES += $(sys) $(pubsys))
|
---|
[130] | 1368 | else
|
---|
[131] | 1369 | $(eval _SYSMODS += $(sys))
|
---|
| 1370 | $(eval _OUT_FILES += $(sys))
|
---|
[130] | 1371 | endif
|
---|
| 1372 | _OBJS += $(_OBJS_$(target))
|
---|
[83] | 1373 | endef
|
---|
| 1374 |
|
---|
[130] | 1375 | # Process sysmods
|
---|
[138] | 1376 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
|
---|
[83] | 1377 |
|
---|
| 1378 |
|
---|
| 1379 |
|
---|
[72] | 1380 | #
|
---|
| 1381 | # OTHERS
|
---|
| 1382 | #
|
---|
[190] | 1383 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 1384 |
|
---|
| 1385 |
|
---|
| 1386 |
|
---|
| 1387 | #
|
---|
| 1388 | # DOCS
|
---|
| 1389 | #
|
---|
| 1390 |
|
---|
| 1391 |
|
---|
| 1392 | #
|
---|
| 1393 | # Directories.
|
---|
| 1394 | #
|
---|
[130] | 1395 | _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
|
---|
[72] | 1396 |
|
---|
| 1397 | define def_createdir
|
---|
| 1398 | $(dirfile):
|
---|
[219] | 1399 | $(call MSG_L1,Creating directory $$(@D))
|
---|
[72] | 1400 | $(MKDIR) -p $$(@D)
|
---|
[73] | 1401 | @echo dir_created > $$@
|
---|
[72] | 1402 | endef
|
---|
| 1403 |
|
---|
| 1404 | $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
|
---|
| 1405 |
|
---|
[183] | 1406 |
|
---|
[72] | 1407 | #
|
---|
[75] | 1408 | # Include dependency files.
|
---|
[72] | 1409 | #
|
---|
[75] | 1410 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
[72] | 1411 |
|
---|
[183] | 1412 |
|
---|
[75] | 1413 | #
|
---|
| 1414 | # PASSES (including directory and makefile walking)
|
---|
| 1415 | #
|
---|
| 1416 | # Do all the default passes if it's unspecified.
|
---|
[72] | 1417 |
|
---|
[98] | 1418 | #PASSES ?= needed libraries binaries others publish
|
---|
[189] | 1419 | PASSES ?= libraries dlls binaries others
|
---|
[98] | 1420 |
|
---|
[75] | 1421 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 1422 | # The user can overload this list.
|
---|
| 1423 | DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
|
---|
[72] | 1424 |
|
---|
[75] | 1425 | ## Subdir
|
---|
| 1426 | # @param $(pass) Lowercase pass name.
|
---|
| 1427 | # @param $(PASS) Uppercase pass name.
|
---|
| 1428 | # @param $(subdir) Subdirectory
|
---|
| 1429 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1430 | define def_pass_subdir
|
---|
[219] | 1431 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1432 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 1433 | endef
|
---|
[72] | 1434 |
|
---|
[75] | 1435 | ## Submakefile
|
---|
| 1436 | # @param $(pass) Lowercase pass name.
|
---|
| 1437 | # @param $(PASS) Uppercase pass name.
|
---|
| 1438 | # @param $(makefile) Makefile.
|
---|
| 1439 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1440 | define def_pass_makefile
|
---|
[219] | 1441 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1442 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 1443 | endef
|
---|
[73] | 1444 |
|
---|
[74] | 1445 |
|
---|
[75] | 1446 | ## Execute a pass.
|
---|
| 1447 | # @param $(pass) Lowercase pass name.
|
---|
| 1448 | # @param $(PASS) Uppercase pass name.
|
---|
| 1449 | define def_pass
|
---|
[183] | 1450 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1451 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1452 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1453 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[75] | 1454 |
|
---|
| 1455 | $(eval tag:=_before)
|
---|
[219] | 1456 | $(eval dep:=)
|
---|
[183] | 1457 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1458 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1459 |
|
---|
| 1460 | $(eval tag:=_after)
|
---|
[219] | 1461 | $(eval dep:=pass_$(pass)_doit)
|
---|
[183] | 1462 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1463 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1464 |
|
---|
| 1465 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 1466 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[219] | 1467 | pass_$(pass)_doit: pass_$(pass)_before
|
---|
| 1468 | pass_$(pass)_after:: pass_$(pass)_doit
|
---|
| 1469 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 1470 |
|
---|
[183] | 1471 | endef
|
---|
| 1472 |
|
---|
| 1473 |
|
---|
[75] | 1474 | ## PASS: needed
|
---|
| 1475 | # This pass builds targets which are required for building the rest.
|
---|
| 1476 | pass_needed_doit: $(_NEEDEDS)
|
---|
| 1477 | pass := needed
|
---|
| 1478 | PASS := NEEDED
|
---|
| 1479 | $(eval $(def_pass))
|
---|
| 1480 |
|
---|
| 1481 | ## PASS: libraries
|
---|
| 1482 | # This pass builds library targets.
|
---|
| 1483 | pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
| 1484 | pass := libraries
|
---|
| 1485 | PASS := LIBRARIES
|
---|
| 1486 | $(eval $(def_pass))
|
---|
| 1487 |
|
---|
| 1488 | ## PASS: binaries
|
---|
[189] | 1489 | # This pass builds dll targets.
|
---|
| 1490 | pass_dlls_doit: $(_DLLS) $(_OTHER_DLLS)
|
---|
| 1491 | pass := dlls
|
---|
| 1492 | PASS := DLLS
|
---|
| 1493 | $(eval $(def_pass))
|
---|
| 1494 |
|
---|
| 1495 | ## PASS: binaries
|
---|
| 1496 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
[219] | 1497 | pass_binaries_doit: $(_PROGRAMS) $(_SYSMODS) $(_OTHER_BINARIES)
|
---|
[75] | 1498 | pass := binaries
|
---|
| 1499 | PASS := BINARIES
|
---|
| 1500 | $(eval $(def_pass))
|
---|
| 1501 |
|
---|
| 1502 | ## PASS: others
|
---|
[83] | 1503 | # This pass builds other targets.
|
---|
[75] | 1504 | pass_others_doit: $(_OTHERS)
|
---|
| 1505 | pass := others
|
---|
| 1506 | PASS := OTHERS
|
---|
| 1507 | $(eval $(def_pass))
|
---|
| 1508 |
|
---|
| 1509 | ## PASS: publish
|
---|
| 1510 | # This pass installs the built entities to a sandbox area.
|
---|
| 1511 | pass_publish_doit: publish
|
---|
| 1512 | publish::
|
---|
| 1513 | pass := publish
|
---|
| 1514 | PASS := PUBLISH
|
---|
[76] | 1515 | # $(sort).. not nice.
|
---|
[183] | 1516 | SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS_LIBRARIES) $(SUBDIRS_LIBRARIES.$(BUILD_TARGET)) $(SUBDIRS_BINARIES) $(SUBDIRS_BINARIES.$(BUILD_TARGET)) $(SUBDIRS_OTHERS) $(SUBDIRS_OTHERS.$(BUILD_TARGET)))
|
---|
| 1517 | SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_LIBRARIES.$(BUILD_TARGET)) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_BINARIES.$(BUILD_TARGET)) $(SUBDIRS_AFTER_OTHERS) $(SUBDIRS_AFTER_OTHERS.$(BUILD_TARGET)))
|
---|
| 1518 | MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_OTHERS) $(MAKEFILES_BEFORE_OTHERS.$(BUILD_TARGET)))
|
---|
| 1519 | MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_AFTER_OTHERS) $(MAKEFILES_AFTER_OTHERS.$(BUILD_TARGET)))
|
---|
[75] | 1520 | $(eval $(def_pass))
|
---|
| 1521 |
|
---|
| 1522 | ## PASS: packing
|
---|
| 1523 | # This pass processes custom packing rules.
|
---|
| 1524 | pass_packing_doit: packing
|
---|
| 1525 | packing::
|
---|
| 1526 | pass := packing
|
---|
| 1527 | PASS := PACKING
|
---|
| 1528 | $(eval $(def_pass))
|
---|
| 1529 |
|
---|
| 1530 | ## PASS: clean
|
---|
| 1531 | # This pass removes all generated files.
|
---|
| 1532 | pass_clean_doit:
|
---|
[136] | 1533 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
|
---|
[75] | 1534 | pass := clean
|
---|
| 1535 | PASS := CLEAN
|
---|
| 1536 | $(eval $(def_pass))
|
---|
| 1537 | clean: pass_clean
|
---|
[183] | 1538 |
|
---|
[75] | 1539 | ## PASS: nothing
|
---|
| 1540 | # This pass just walks the tree.
|
---|
| 1541 | pass_nothing_doit:
|
---|
[219] | 1542 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
[75] | 1543 | pass := nothing
|
---|
| 1544 | PASS := NOTHING
|
---|
| 1545 | $(eval $(def_pass))
|
---|
| 1546 | nothing: pass_nothing
|
---|
| 1547 |
|
---|
[78] | 1548 |
|
---|
[219] | 1549 | ## Pass order
|
---|
| 1550 | # @param $(pass) Current pass name.
|
---|
| 1551 | # @param $(prev_pass) The previous pass name.
|
---|
| 1552 | define def_pass_order
|
---|
| 1553 | pass_$(pass)_order: $(pass_prev)
|
---|
| 1554 | $(call MSG_L1,Pass $(pass))
|
---|
| 1555 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
| 1556 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 1557 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 1558 | endef
|
---|
[183] | 1559 |
|
---|
[219] | 1560 | ## PASS: order
|
---|
| 1561 | # Use dependencies to ensure correct pass order.
|
---|
| 1562 | pass_prev :=
|
---|
| 1563 | $(foreach pass,$(PASSES),$(eval $(def_pass_order)))
|
---|
| 1564 |
|
---|
| 1565 |
|
---|
[75] | 1566 | #
|
---|
| 1567 | # THE MAIN RULES
|
---|
| 1568 | #
|
---|
[219] | 1569 | all_recursive: $(pass_prev)
|
---|
[75] | 1570 |
|
---|
[130] | 1571 | rebuild: clean
|
---|
[219] | 1572 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 1573 |
|
---|
| 1574 |
|
---|
[75] | 1575 | # misc shortcuts.
|
---|
| 1576 | target: needed libraries binaries others
|
---|
| 1577 | objects: $(_OBJS)
|
---|
[189] | 1578 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 1579 | dlls: $(_DLLS)
|
---|
[219] | 1580 | programs: $(_PROGRAMS)
|
---|
[205] | 1581 | sysmods: $(_SYSMODS)
|
---|
[75] | 1582 |
|
---|
| 1583 |
|
---|
[72] | 1584 | # end-of-file-content
|
---|
[106] | 1585 | __footer_kmk__ := target
|
---|
[72] | 1586 | endif # __footer_kmk__
|
---|