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