[72] | 1 | # $Id: footer.kmk 190 2004-12-14 18:53:05Z 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
|
---|
| 53 | _OBJS :=
|
---|
| 54 | _LIBS :=
|
---|
| 55 | _DLLS :=
|
---|
| 56 | _EXES :=
|
---|
[83] | 57 | _SYSMODS:=
|
---|
[72] | 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 |
|
---|
[73] | 346 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 347 | # @param $(target) Normalized target name.
|
---|
| 348 | # @param $(source) Source file name.
|
---|
| 349 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[72] | 350 | #
|
---|
[73] | 351 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
[105] | 352 | # @remark I now have a clue. Have to use $$ if not.
|
---|
[73] | 353 | define def_target_source_c_cpp_asm
|
---|
[105] | 354 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 355 |
|
---|
[78] | 356 | $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
|
---|
[111] | 357 | $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
|
---|
| 358 | $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 359 | $(eval dirdep := $(dir $(outbase)).dir_created)
|
---|
[73] | 360 | $(eval defs :=\
|
---|
[78] | 361 | $(TOOL_$(tool)_DEFS)\
|
---|
| 362 | $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
|
---|
| 363 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
|
---|
| 364 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 365 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 366 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
| 367 | $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
[78] | 368 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 369 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 370 | $(SDKS),\
|
---|
| 371 | $(SDK_$(sdk)_DEFS)\
|
---|
| 372 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 373 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 374 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 375 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 376 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 377 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 378 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 379 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 380 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 381 | $(DEFS)\
|
---|
| 382 | $(DEFS.$(BUILD_TYPE))\
|
---|
[78] | 383 | $(DEFS.$(BUILD_TARGET))\
|
---|
| 384 | $(DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 385 | $(DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 386 | $($(type)DEFS)\
|
---|
| 387 | $($(type)DEFS.$(BUILD_TYPE))\
|
---|
| 388 | $($(type)DEFS.$(BUILD_TARGET))\
|
---|
| 389 | $($(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 390 | $($(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 391 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 392 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 393 | $($(target)_SDKS),\
|
---|
| 394 | $(SDK_$(sdk)_DEFS)\
|
---|
| 395 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 396 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 397 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 398 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 399 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 400 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 401 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 402 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 403 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 404 | $($(target)_DEFS)\
|
---|
| 405 | $($(target)_DEFS.$(BUILD_TYPE))\
|
---|
| 406 | $($(target)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 407 | $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 408 | $($(target)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 409 | $($(target)_$(type)DEFS)\
|
---|
| 410 | $($(target)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 411 | $($(target)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 412 | $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 413 | $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 414 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 415 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 416 | $($(source)_SDKS),\
|
---|
| 417 | $(SDK_$(sdk)_DEFS)\
|
---|
| 418 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 419 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 420 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 421 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 422 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 423 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 424 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 425 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 426 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 427 | $($(source)_DEFS)\
|
---|
| 428 | $($(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 429 | $($(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 430 | $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 431 | $($(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 432 | $($(source)_$(type)DEFS)\
|
---|
[74] | 433 | $($(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 434 | $($(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 435 | $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 436 | $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 437 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 438 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 439 | $($(target)_$(source)_SDKS),\
|
---|
| 440 | $(SDK_$(sdk)_DEFS)\
|
---|
| 441 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 442 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 443 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
[133] | 444 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[78] | 445 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 446 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 447 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 448 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 449 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 450 | $($(target)_$(source)_DEFS)\
|
---|
| 451 | $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 452 | $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 453 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 454 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 455 | $($(target)_$(source)_$(type)DEFS)\
|
---|
| 456 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 457 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 458 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 459 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 460 | )
|
---|
| 461 | $(eval incs :=\
|
---|
[78] | 462 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 463 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 464 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 465 | $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 466 | $($(target)_$(source)_$(type)INCS)\
|
---|
[78] | 467 | $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 468 | $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 469 | $($(target)_$(source)_INCS.$(BUILD_TARGET))\
|
---|
| 470 | $($(target)_$(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 471 | $($(target)_$(source)_INCS)\
|
---|
[78] | 472 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 473 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
[133] | 474 | $($(target)_$(source)_SDKS),\
|
---|
[78] | 475 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 476 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 477 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 478 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 479 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 480 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 481 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 482 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 483 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 484 | $(SDK_$(sdk)_INCS))\
|
---|
| 485 | $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 486 | $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 487 | $($(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 488 | $($(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 489 | $($(source)_$(type)INCS)\
|
---|
[78] | 490 | $($(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 491 | $($(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 492 | $($(source)_INCS.$(BUILD_TARGET))\
|
---|
| 493 | $($(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 494 | $($(source)_INCS)\
|
---|
[78] | 495 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 496 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 497 | $($(source)_SDKS),\
|
---|
| 498 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 499 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 500 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 501 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 502 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 503 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 504 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 505 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 506 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 507 | $(SDK_$(sdk)_INCS))\
|
---|
| 508 | $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 509 | $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 510 | $($(target)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 511 | $($(target)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 512 | $($(target)_$(type)INCS)\
|
---|
[78] | 513 | $($(target)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 514 | $($(target)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 515 | $($(target)_INCS.$(BUILD_TARGET))\
|
---|
| 516 | $($(target)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 517 | $($(target)_INCS)\
|
---|
[78] | 518 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 519 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 520 | $($(target)_SDKS),\
|
---|
| 521 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 522 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 523 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 524 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 525 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 526 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 527 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 528 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 529 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 530 | $(SDK_$(sdk)_INCS))\
|
---|
| 531 | $(INCS.$(BUILD_TARGET_CPU))\
|
---|
| 532 | $(INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 533 | $(INCS.$(BUILD_TARGET))\
|
---|
| 534 | $(INCS.$(BUILD_TYPE))\
|
---|
[73] | 535 | $(INCS)\
|
---|
[78] | 536 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 537 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 538 | $(SDKS),\
|
---|
| 539 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 540 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 541 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 542 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 543 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 544 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 545 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 546 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 547 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 548 | $(SDK_$(sdk)_INCS))\
|
---|
| 549 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 550 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 551 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 552 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 553 | $(TOOL_$(tool)_$(type)INCS)\
|
---|
| 554 | )
|
---|
| 555 | $(eval flags :=\
|
---|
| 556 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
| 557 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 558 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 559 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 560 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 561 | $($(type)FLAGS)\
|
---|
| 562 | $($(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 563 | $($(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 564 | $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 565 | $($(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 566 | $($(target)_$(type)FLAGS)\
|
---|
| 567 | $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 568 | $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 569 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 570 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 571 | $($(source)_$(type)FLAGS)\
|
---|
| 572 | $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 573 | $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 574 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 575 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 576 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
| 577 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 578 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 579 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 580 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 581 | )
|
---|
[74] | 582 | $(eval objsuff := $(firstword \
|
---|
| 583 | $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 584 | $($(target)_$(source)_OBJSUFF)\
|
---|
| 585 | $($(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 586 | $($(source)_OBJSUFF)\
|
---|
| 587 | $($(target)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 588 | $($(target)_OBJSUFF)\
|
---|
| 589 | $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
|
---|
| 590 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
| 591 | $(SUFF_OBJ)\
|
---|
| 592 | ))
|
---|
[73] | 593 | $(eval obj := $(outbase)$(objsuff))
|
---|
[74] | 594 | $(eval dep := $(outbase)$(SUFF_DEP))
|
---|
[184] | 595 | $(eval deps := \
|
---|
| 596 | $($(target)_$(source)_DEPS)\
|
---|
| 597 | $($(target)_$(source)_DEPS.$(BUILD_TYPE))\
|
---|
| 598 | $($(target)_$(source)_DEPS.$(BUILD_TARGET))\
|
---|
| 599 | $($(target)_$(source)_DEPS.$(BUILD_TARGET_ARCH))\
|
---|
| 600 | $($(target)_$(source)_DEPS.$(BUILD_TARGET_CPU))\
|
---|
| 601 | $($(source)_DEPS)\
|
---|
| 602 | $($(source)_DEPS.$(BUILD_TYPE))\
|
---|
| 603 | $($(source)_DEPS.$(BUILD_TARGET))\
|
---|
| 604 | $($(target)_DEPS)\
|
---|
| 605 | $($(target)_DEPS.$(BUILD_TARGET_ARCH))\
|
---|
| 606 | $($(target)_DEPS.$(BUILD_TARGET_CPU)))
|
---|
[73] | 607 |
|
---|
[184] | 608 |
|
---|
| 609 | #$ (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] | 610 | ifndef TOOL_$(tool)_COMPILE_$(type)
|
---|
| 611 | $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
|
---|
| 612 | $$(warning kBuild: tools: \
|
---|
[106] | 613 | 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 614 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
| 615 | 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 616 | 4 $($(target)_$(source)_TOOL) \
|
---|
| 617 | 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 618 | 6 $($(target)_$(type)TOOL) \
|
---|
| 619 | 7 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 620 | 8 $($(target)_TOOL) \
|
---|
| 621 | 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 622 | 10 $($(source)_$(type)TOOL) \
|
---|
| 623 | 11 $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
| 624 | 12 $($(source)_TOOL) \
|
---|
| 625 | 13 $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
| 626 | 14 $($(type)TOOL) \
|
---|
| 627 | 15 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 628 | 16 $(TOOL) )
|
---|
[97] | 629 | endif
|
---|
[73] | 630 | $(eval $(TOOL_$(tool)_COMPILE_$(type)))
|
---|
| 631 |
|
---|
| 632 | $(eval _OBJS_$(target) += $(obj))
|
---|
| 633 | $(eval _DEPFILES += $(dep))
|
---|
| 634 |
|
---|
| 635 | endef
|
---|
| 636 |
|
---|
| 637 | ## Generic macro for processing all target sources.
|
---|
[74] | 638 | # @param $(target) Normalized target name.
|
---|
[73] | 639 | define def_target_sources
|
---|
| 640 | #$ (warning def_target_sources)
|
---|
| 641 | # C sources
|
---|
[120] | 642 | $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 643 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 644 |
|
---|
| 645 | # C++ sources
|
---|
[120] | 646 | $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 647 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 648 |
|
---|
| 649 | # ASM sources
|
---|
[120] | 650 | $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
[73] | 651 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 652 | endef
|
---|
| 653 |
|
---|
| 654 |
|
---|
| 655 | #
|
---|
[72] | 656 | # LIBRARIES
|
---|
[73] | 657 | #
|
---|
[72] | 658 |
|
---|
| 659 | ## Library (one).
|
---|
[74] | 660 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 661 | define def_lib
|
---|
[145] | 662 | # library basics
|
---|
[78] | 663 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
| 664 | ifeq ($(tool),)
|
---|
| 665 | $$(error kBuild: Library target $(target) doesn't have a tool defined!)
|
---|
| 666 | endif
|
---|
[111] | 667 | ## @todo prefix
|
---|
| 668 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 669 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[126] | 670 | $(eval libsuff := $(firstword\
|
---|
| 671 | $($(target)_LIBSUFF.$(BUILD_TARGET))\
|
---|
| 672 | $($(target)_LIBSUFF)\
|
---|
| 673 | $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
|
---|
| 674 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
| 675 | $(SUFF_LIB)\
|
---|
| 676 | ))
|
---|
[111] | 677 | $(eval lib := $(outbase)$(libsuff))
|
---|
[183] | 678 | $(eval TARGET_$(target) := $(lib))
|
---|
[145] | 679 |
|
---|
| 680 | # source -> object
|
---|
| 681 | $(eval $(def_target_sources))
|
---|
| 682 |
|
---|
| 683 | # library linking
|
---|
| 684 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
[146] | 685 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[74] | 686 | $(eval flags :=\
|
---|
| 687 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
| 688 | $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 689 | $(ARFLAGS)\
|
---|
| 690 | $(ARFLAGS.$(BUILD_TYPE))\
|
---|
| 691 | $($(target)_ARFLAGS)\
|
---|
| 692 | $($(target)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 693 | )
|
---|
[73] | 694 | $(eval objs = $(_OBJS_$(target)))
|
---|
[120] | 695 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[73] | 696 | $(eval dirdep := $(dir $(lib)).dir_created)
|
---|
[78] | 697 | ## @todo fix dependencies on makefiles an such
|
---|
[184] | 698 | $(eval deps := $($(target)_DEPS))
|
---|
[72] | 699 |
|
---|
[73] | 700 | $(eval $(TOOL_$(tool)_LINK_LIBRARY))
|
---|
[72] | 701 |
|
---|
[126] | 702 | # publish rule (still need work)
|
---|
[131] | 703 | ifndef $(target)_NOINST
|
---|
[126] | 704 | $(eval publib := $(PATH_LIB)/$(notdir $(lib)))
|
---|
| 705 | $(publib) : $(lib) $(dir $(publib)).dir_created
|
---|
[130] | 706 | $(CP) $(lib) $(publib)
|
---|
[183] | 707 |
|
---|
[126] | 708 | _LIBS += $(publib)
|
---|
| 709 | _OUT_FILES += $(lib) $(publib)
|
---|
| 710 | else
|
---|
[73] | 711 | _LIBS += $(lib)
|
---|
[75] | 712 | _OUT_FILES += $(lib)
|
---|
[126] | 713 | endif
|
---|
| 714 | _OBJS += $(_OBJS_$(target))
|
---|
[72] | 715 | endef
|
---|
| 716 |
|
---|
| 717 | # Process libraries
|
---|
[138] | 718 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
|
---|
[72] | 719 |
|
---|
| 720 |
|
---|
| 721 |
|
---|
| 722 | #
|
---|
[189] | 723 | # DLLS
|
---|
[72] | 724 | #
|
---|
| 725 |
|
---|
[189] | 726 | ## DLL (one).
|
---|
[74] | 727 | # @param $(target) Normalized target (program) name.
|
---|
[189] | 728 | define def_dll
|
---|
| 729 | # dllmod basics
|
---|
[78] | 730 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 731 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 732 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[189] | 733 | $(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
|
---|
| 734 | $(eval dll := $(outbase)$(dllsuff))
|
---|
| 735 | $(eval TARGET_$(target) := $(dll))
|
---|
[145] | 736 |
|
---|
| 737 | # source -> object
|
---|
| 738 | $(eval $(def_target_sources))
|
---|
| 739 |
|
---|
[189] | 740 | # dllmod linking.
|
---|
[145] | 741 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 742 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[111] | 743 | $(eval objs = $(_OBJS_$(target)))
|
---|
[74] | 744 | $(eval flags :=\
|
---|
| 745 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 746 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 747 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 748 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 749 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 750 | $(LDFLAGS)\
|
---|
| 751 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 752 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 753 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 754 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 755 | $($(target)_LDFLAGS)\
|
---|
| 756 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 757 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 758 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 759 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 760 | )
|
---|
| 761 | $(eval libs :=\
|
---|
[87] | 762 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 763 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 764 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[74] | 765 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 766 | $($(target)_LIBS)\
|
---|
[122] | 767 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 768 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 769 | $($(target)_SDKS),\
|
---|
| 770 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 771 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 772 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 773 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 774 | $(SDK_$(sdk)_LIBS))\
|
---|
[87] | 775 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 776 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 777 | $(LIBS.$(BUILD_TARGET))\
|
---|
[74] | 778 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 779 | $(LIBS)\
|
---|
[122] | 780 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 781 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 782 | $(SDKS),\
|
---|
| 783 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 784 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 785 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 786 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 787 | $(SDK_$(sdk)_LIBS))\
|
---|
| 788 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 789 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 790 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
[74] | 791 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 792 | $(TOOL_$(tool)_LIBS)\
|
---|
| 793 | )
|
---|
| 794 | $(eval libpath :=\
|
---|
[87] | 795 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 796 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 797 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 798 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 799 | $($(target)_LIBPATH)\
|
---|
[122] | 800 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 801 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 802 | $($(target)_SDKS),\
|
---|
| 803 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 804 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 805 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 806 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 807 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 808 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 809 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 810 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 811 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 812 | $(LIBPATH)\
|
---|
[122] | 813 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 814 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 815 | $(SDKS),\
|
---|
| 816 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 817 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 818 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 819 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 820 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 821 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 822 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 823 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[74] | 824 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 825 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 826 | )
|
---|
[189] | 827 | $(eval dirdep := $(dir $(dll)).dir_created)
|
---|
[74] | 828 | ## @todo fix dependencies
|
---|
[184] | 829 | $(eval deps := $($(target)_DEPS))
|
---|
[74] | 830 | #
|
---|
| 831 | $(eval custom_pre := $(strip $(firstword
|
---|
| 832 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 833 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 834 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 835 | $($(target)_CUSTOM_PRE)\
|
---|
| 836 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 837 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 838 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 839 | $(CUSTOM_PRE)\
|
---|
| 840 | )))
|
---|
| 841 | $(eval custom_post := $(strip $(firstword
|
---|
| 842 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 843 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 844 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 845 | $($(target)_CUSTOM_POST)\
|
---|
| 846 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 847 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 848 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 849 | $(CUSTOM_POST)\
|
---|
| 850 | )))
|
---|
[120] | 851 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 852 |
|
---|
[189] | 853 | ifndef TOOL_$(tool)_LINK_DLL
|
---|
| 854 | $$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
|
---|
| 855 | $$(warning kBuild: tools: \
|
---|
| 856 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 857 | 2 $($(target)_$(source)TOOL) \
|
---|
| 858 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 859 | 4 $($(target)_TOOL) \
|
---|
| 860 | 5 $($(source)TOOL) \
|
---|
| 861 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 862 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 863 | 8 $(TOOL) )
|
---|
| 864 | endif
|
---|
| 865 |
|
---|
| 866 | $(eval $(TOOL_$(tool)_LINK_DLL))
|
---|
| 867 |
|
---|
| 868 |
|
---|
[130] | 869 | # publish rule (still need work)
|
---|
[131] | 870 | ifndef $(target)_NOINST
|
---|
[189] | 871 | $(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
|
---|
| 872 | $(pubdll) : $(dll) $(dir $(pubdll)).dir_created
|
---|
| 873 | $(CP) $(dll) $(pubdll)
|
---|
[183] | 874 |
|
---|
[189] | 875 | $(eval TARGET_PUB_$(target) := $(pubdll))
|
---|
| 876 | _DLLS += $(pubdll)
|
---|
| 877 | _OUT_FILES += $(dll) $(pubdll)
|
---|
[130] | 878 | else
|
---|
[189] | 879 | _DLLS += $(dll)
|
---|
| 880 | _OUT_FILES += $(dll)
|
---|
[130] | 881 | endif
|
---|
[74] | 882 | _OBJS += $(_OBJS_$(target))
|
---|
| 883 | endef
|
---|
| 884 |
|
---|
[189] | 885 | # Process dlls
|
---|
| 886 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
|
---|
[74] | 887 |
|
---|
| 888 |
|
---|
| 889 |
|
---|
[72] | 890 | #
|
---|
[189] | 891 | # Process import libraries.
|
---|
[72] | 892 | #
|
---|
[189] | 893 | # - On OS/2 and windows these are libraries.
|
---|
| 894 | # - On other platforms they are fake DLLs.
|
---|
| 895 | ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
|
---|
| 896 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_lib)))
|
---|
| 897 | else
|
---|
| 898 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_dll)))
|
---|
| 899 | endif
|
---|
| 900 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval _IMPORT_LIBS += $(firstword $(TARGET_PUB_$(target)) $(TARGET_$(target)))))
|
---|
[72] | 901 |
|
---|
[189] | 902 |
|
---|
| 903 | #
|
---|
| 904 | # PROGRAMS
|
---|
| 905 | #
|
---|
| 906 |
|
---|
| 907 | ## Program (one).
|
---|
[130] | 908 | # @param $(target) Normalized target (program) name.
|
---|
[189] | 909 | define def_program
|
---|
| 910 | # basics
|
---|
[130] | 911 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
| 912 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 913 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
[189] | 914 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
|
---|
| 915 | $(eval exe := $(outbase)$(exesuff))
|
---|
| 916 | $(eval TARGET_$(target) := $(exe))
|
---|
[145] | 917 |
|
---|
| 918 | # source -> object
|
---|
| 919 | $(eval $(def_target_sources))
|
---|
| 920 |
|
---|
[189] | 921 | # more library stuff.
|
---|
[145] | 922 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 923 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[130] | 924 | $(eval objs = $(_OBJS_$(target)))
|
---|
| 925 | $(eval flags :=\
|
---|
| 926 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 927 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 928 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 929 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 930 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 931 | $(LDFLAGS)\
|
---|
| 932 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
| 933 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 934 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 935 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 936 | $($(target)_LDFLAGS)\
|
---|
| 937 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 938 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 939 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 940 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
| 941 | )
|
---|
| 942 | $(eval libs :=\
|
---|
| 943 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 944 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 945 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
| 946 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 947 | $($(target)_LIBS)\
|
---|
| 948 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 949 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 950 | $($(target)_SDKS),\
|
---|
| 951 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 952 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 953 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 954 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 955 | $(SDK_$(sdk)_LIBS))\
|
---|
| 956 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 957 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 958 | $(LIBS.$(BUILD_TARGET))\
|
---|
| 959 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 960 | $(LIBS)\
|
---|
| 961 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 962 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 963 | $(SDKS),\
|
---|
| 964 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 965 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 966 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 967 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 968 | $(SDK_$(sdk)_LIBS))\
|
---|
| 969 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 970 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 971 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
| 972 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 973 | $(TOOL_$(tool)_LIBS)\
|
---|
| 974 | )
|
---|
| 975 | $(eval libpath :=\
|
---|
| 976 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 977 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 978 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 979 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 980 | $($(target)_LIBPATH)\
|
---|
| 981 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 982 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 983 | $($(target)_SDKS),\
|
---|
| 984 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 985 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 986 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 987 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 988 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 989 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 990 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 991 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
| 992 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 993 | $(LIBPATH)\
|
---|
| 994 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 995 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 996 | $(SDKS),\
|
---|
| 997 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 998 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 999 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1000 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1001 | $(SDK_$(sdk)_LIBPATH))\
|
---|
| 1002 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1003 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1004 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1005 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1006 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 1007 | )
|
---|
[189] | 1008 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
[130] | 1009 | ## @todo fix dependencies
|
---|
[184] | 1010 | $(eval deps := $($(target)_DEPS))
|
---|
[130] | 1011 | #
|
---|
| 1012 | $(eval custom_pre := $(strip $(firstword
|
---|
| 1013 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1014 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1015 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1016 | $($(target)_CUSTOM_PRE)\
|
---|
| 1017 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1018 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1019 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1020 | $(CUSTOM_PRE)\
|
---|
| 1021 | )))
|
---|
| 1022 | $(eval custom_post := $(strip $(firstword
|
---|
| 1023 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1024 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1025 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1026 | $($(target)_CUSTOM_POST)\
|
---|
| 1027 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1028 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1029 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1030 | $(CUSTOM_POST)\
|
---|
| 1031 | )))
|
---|
| 1032 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 1033 |
|
---|
[189] | 1034 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
[130] | 1035 | # publish rule (still need work)
|
---|
[131] | 1036 | ifndef $(target)_NOINST
|
---|
[189] | 1037 | $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
|
---|
| 1038 | $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
|
---|
| 1039 | $(CP) $(exe) $(pubexe)
|
---|
[183] | 1040 |
|
---|
[189] | 1041 | _DLLS += $(pubexe)
|
---|
| 1042 | _OUT_FILES += $(exe) $(pubexe)
|
---|
[130] | 1043 | else
|
---|
[189] | 1044 | _DLLS += $(exe)
|
---|
| 1045 | _OUT_FILES += $(exe)
|
---|
[130] | 1046 | endif
|
---|
| 1047 | _OBJS += $(_OBJS_$(target))
|
---|
| 1048 | endef
|
---|
| 1049 |
|
---|
[189] | 1050 | # Process libraries
|
---|
| 1051 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
|
---|
[130] | 1052 |
|
---|
| 1053 |
|
---|
[189] | 1054 |
|
---|
[72] | 1055 | #
|
---|
[83] | 1056 | # SYSMODS
|
---|
[72] | 1057 | #
|
---|
| 1058 |
|
---|
[130] | 1059 | ## System module (one).
|
---|
[83] | 1060 | # @param $(target) Normalized target (program) name.
|
---|
| 1061 | define def_sysmod
|
---|
[145] | 1062 | # sysmod basics
|
---|
[83] | 1063 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[111] | 1064 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 1065 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1066 | $(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
|
---|
| 1067 | $(eval sys := $(outbase)$(syssuff))
|
---|
[183] | 1068 | $(eval TARGET_$(target) := $(sys))
|
---|
[145] | 1069 |
|
---|
| 1070 | # source -> object
|
---|
| 1071 | $(eval $(def_target_sources))
|
---|
| 1072 |
|
---|
| 1073 | # sysmod linking
|
---|
| 1074 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[146] | 1075 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
[111] | 1076 | $(eval objs = $(_OBJS_$(target)))
|
---|
[83] | 1077 | $(eval flags :=\
|
---|
| 1078 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 1079 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1080 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1081 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1082 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1083 | $(LDFLAGS)\
|
---|
| 1084 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1085 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1086 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1087 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1088 | $($(target)_LDFLAGS)\
|
---|
| 1089 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
[89] | 1090 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
| 1091 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 1092 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
[83] | 1093 | )
|
---|
| 1094 | $(eval libs :=\
|
---|
[87] | 1095 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1096 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1097 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1098 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 1099 | $($(target)_LIBS)\
|
---|
[122] | 1100 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1101 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1102 | $($(target)_SDKS),\
|
---|
| 1103 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1104 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1105 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1106 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1107 | $(SDK_$(sdk)_LIBS))\
|
---|
[87] | 1108 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1109 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1110 | $(LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1111 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 1112 | $(LIBS)\
|
---|
[122] | 1113 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1114 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1115 | $(SDKS),\
|
---|
| 1116 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1117 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1118 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
| 1119 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
| 1120 | $(SDK_$(sdk)_LIBS))\
|
---|
| 1121 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
| 1122 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
| 1123 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
[83] | 1124 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 1125 | $(TOOL_$(tool)_LIBS)\
|
---|
| 1126 | )
|
---|
| 1127 | $(eval libpath :=\
|
---|
[87] | 1128 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1129 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1130 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1131 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1132 | $($(target)_LIBPATH)\
|
---|
[122] | 1133 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 1134 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 1135 | $($(target)_SDKS),\
|
---|
| 1136 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1137 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1138 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1139 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1140 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 1141 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1142 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1143 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1144 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 1145 | $(LIBPATH)\
|
---|
[122] | 1146 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 1147 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 1148 | $(SDKS),\
|
---|
| 1149 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1150 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1151 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
| 1152 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1153 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[87] | 1154 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
| 1155 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
| 1156 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
[83] | 1157 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 1158 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 1159 | )
|
---|
| 1160 | $(eval dirdep := $(dir $(sys)).dir_created)
|
---|
| 1161 | ## @todo fix dependencies
|
---|
[184] | 1162 | $(eval deps := $($(target)_DEPS))
|
---|
[83] | 1163 | #
|
---|
| 1164 | $(eval custom_pre := $(strip $(firstword
|
---|
| 1165 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1166 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1167 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1168 | $($(target)_CUSTOM_PRE)\
|
---|
| 1169 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1170 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 1171 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 1172 | $(CUSTOM_PRE)\
|
---|
| 1173 | )))
|
---|
| 1174 | $(eval custom_post := $(strip $(firstword
|
---|
| 1175 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1176 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1177 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1178 | $($(target)_CUSTOM_POST)\
|
---|
| 1179 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 1180 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 1181 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 1182 | $(CUSTOM_POST)\
|
---|
| 1183 | )))
|
---|
[120] | 1184 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
[72] | 1185 |
|
---|
[106] | 1186 | ifndef TOOL_$(tool)_LINK_SYSMOD
|
---|
| 1187 | $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
|
---|
| 1188 | $$(warning kBuild: tools: \
|
---|
| 1189 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1190 | 2 $($(target)_$(source)TOOL) \
|
---|
| 1191 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
| 1192 | 4 $($(target)_TOOL) \
|
---|
| 1193 | 5 $($(source)TOOL) \
|
---|
| 1194 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
| 1195 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
| 1196 | 8 $(TOOL) )
|
---|
[183] | 1197 | endif
|
---|
[106] | 1198 |
|
---|
[83] | 1199 | $(eval $(TOOL_$(tool)_LINK_SYSMOD))
|
---|
| 1200 |
|
---|
[130] | 1201 | # publish rule (still need work)
|
---|
[131] | 1202 | ifndef $(target)_NOINST
|
---|
| 1203 | $(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
|
---|
| 1204 | $(pubsys): $(sys) $(dir $(pubsys)).dir_created
|
---|
[130] | 1205 | $(CP) $(sys) $(pubsys)
|
---|
[183] | 1206 |
|
---|
[131] | 1207 | $(eval _SYSMODS += $(pubsys))
|
---|
| 1208 | $(eval _OUT_FILES += $(sys) $(pubsys))
|
---|
[130] | 1209 | else
|
---|
[131] | 1210 | $(eval _SYSMODS += $(sys))
|
---|
| 1211 | $(eval _OUT_FILES += $(sys))
|
---|
[130] | 1212 | endif
|
---|
| 1213 | _OBJS += $(_OBJS_$(target))
|
---|
[83] | 1214 | endef
|
---|
| 1215 |
|
---|
[130] | 1216 | # Process sysmods
|
---|
[138] | 1217 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
|
---|
[83] | 1218 |
|
---|
| 1219 |
|
---|
| 1220 |
|
---|
[72] | 1221 | #
|
---|
| 1222 | # OTHERS
|
---|
| 1223 | #
|
---|
[190] | 1224 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 1225 |
|
---|
| 1226 |
|
---|
| 1227 |
|
---|
| 1228 | #
|
---|
| 1229 | # DOCS
|
---|
| 1230 | #
|
---|
| 1231 |
|
---|
| 1232 |
|
---|
| 1233 | #
|
---|
| 1234 | # Directories.
|
---|
| 1235 | #
|
---|
[130] | 1236 | _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
|
---|
[72] | 1237 |
|
---|
| 1238 | define def_createdir
|
---|
| 1239 | $(dirfile):
|
---|
[106] | 1240 | $(call MSG_Ltarget,Creating directory $$(@D))
|
---|
[72] | 1241 | $(MKDIR) -p $$(@D)
|
---|
[73] | 1242 | @echo dir_created > $$@
|
---|
[72] | 1243 | endef
|
---|
| 1244 |
|
---|
| 1245 | $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
|
---|
| 1246 |
|
---|
[183] | 1247 |
|
---|
[72] | 1248 | #
|
---|
[75] | 1249 | # Include dependency files.
|
---|
[72] | 1250 | #
|
---|
[75] | 1251 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
[72] | 1252 |
|
---|
[183] | 1253 |
|
---|
[75] | 1254 | #
|
---|
| 1255 | # PASSES (including directory and makefile walking)
|
---|
| 1256 | #
|
---|
| 1257 | # Do all the default passes if it's unspecified.
|
---|
[72] | 1258 |
|
---|
[98] | 1259 | #PASSES ?= needed libraries binaries others publish
|
---|
[189] | 1260 | PASSES ?= libraries dlls binaries others
|
---|
[98] | 1261 |
|
---|
[75] | 1262 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 1263 | # The user can overload this list.
|
---|
| 1264 | DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
|
---|
[72] | 1265 |
|
---|
[75] | 1266 | ## Subdir
|
---|
| 1267 | # @param $(pass) Lowercase pass name.
|
---|
| 1268 | # @param $(PASS) Uppercase pass name.
|
---|
| 1269 | # @param $(subdir) Subdirectory
|
---|
| 1270 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1271 | define def_pass_subdir
|
---|
| 1272 | pass_$(pass)$(tag)::
|
---|
| 1273 | $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
| 1274 | endef
|
---|
[72] | 1275 |
|
---|
[75] | 1276 | ## Submakefile
|
---|
| 1277 | # @param $(pass) Lowercase pass name.
|
---|
| 1278 | # @param $(PASS) Uppercase pass name.
|
---|
| 1279 | # @param $(makefile) Makefile.
|
---|
| 1280 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1281 | define def_pass_makefile
|
---|
| 1282 | pass_$(pass)$(tag)::
|
---|
| 1283 | $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
| 1284 | endef
|
---|
[73] | 1285 |
|
---|
[74] | 1286 |
|
---|
[75] | 1287 | ## Execute a pass.
|
---|
| 1288 | # @param $(pass) Lowercase pass name.
|
---|
| 1289 | # @param $(PASS) Uppercase pass name.
|
---|
| 1290 | define def_pass
|
---|
[183] | 1291 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1292 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1293 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1294 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[75] | 1295 |
|
---|
| 1296 | $(eval tag:=_before)
|
---|
[183] | 1297 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1298 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1299 |
|
---|
| 1300 | $(eval tag:=_after)
|
---|
[183] | 1301 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1302 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1303 |
|
---|
| 1304 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 1305 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
| 1306 | pass_$(pass): \
|
---|
| 1307 | pass_$(pass)_before \
|
---|
| 1308 | pass_$(pass)_doit \
|
---|
| 1309 | pass_$(pass)_after
|
---|
| 1310 |
|
---|
[183] | 1311 | endef
|
---|
| 1312 |
|
---|
| 1313 |
|
---|
[75] | 1314 | ## PASS: needed
|
---|
| 1315 | # This pass builds targets which are required for building the rest.
|
---|
| 1316 | pass_needed_doit: $(_NEEDEDS)
|
---|
| 1317 | pass := needed
|
---|
| 1318 | PASS := NEEDED
|
---|
| 1319 | $(eval $(def_pass))
|
---|
| 1320 |
|
---|
| 1321 | ## PASS: libraries
|
---|
| 1322 | # This pass builds library targets.
|
---|
| 1323 | pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
| 1324 | pass := libraries
|
---|
| 1325 | PASS := LIBRARIES
|
---|
| 1326 | $(eval $(def_pass))
|
---|
| 1327 |
|
---|
| 1328 | ## PASS: binaries
|
---|
[189] | 1329 | # This pass builds dll targets.
|
---|
| 1330 | pass_dlls_doit: $(_DLLS) $(_OTHER_DLLS)
|
---|
| 1331 | pass := dlls
|
---|
| 1332 | PASS := DLLS
|
---|
| 1333 | $(eval $(def_pass))
|
---|
| 1334 |
|
---|
| 1335 | ## PASS: binaries
|
---|
| 1336 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
| 1337 | pass_binaries_doit: $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
|
---|
[75] | 1338 | pass := binaries
|
---|
| 1339 | PASS := BINARIES
|
---|
| 1340 | $(eval $(def_pass))
|
---|
| 1341 |
|
---|
| 1342 | ## PASS: others
|
---|
[83] | 1343 | # This pass builds other targets.
|
---|
[75] | 1344 | pass_others_doit: $(_OTHERS)
|
---|
| 1345 | pass := others
|
---|
| 1346 | PASS := OTHERS
|
---|
| 1347 | $(eval $(def_pass))
|
---|
| 1348 |
|
---|
| 1349 | ## PASS: publish
|
---|
| 1350 | # This pass installs the built entities to a sandbox area.
|
---|
| 1351 | pass_publish_doit: publish
|
---|
| 1352 | publish::
|
---|
| 1353 | pass := publish
|
---|
| 1354 | PASS := PUBLISH
|
---|
[76] | 1355 | # $(sort).. not nice.
|
---|
[183] | 1356 | 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)))
|
---|
| 1357 | 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)))
|
---|
| 1358 | 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)))
|
---|
| 1359 | 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] | 1360 | $(eval $(def_pass))
|
---|
| 1361 |
|
---|
| 1362 | ## PASS: packing
|
---|
| 1363 | # This pass processes custom packing rules.
|
---|
| 1364 | pass_packing_doit: packing
|
---|
| 1365 | packing::
|
---|
| 1366 | pass := packing
|
---|
| 1367 | PASS := PACKING
|
---|
| 1368 | $(eval $(def_pass))
|
---|
| 1369 |
|
---|
| 1370 | ## PASS: clean
|
---|
| 1371 | # This pass removes all generated files.
|
---|
| 1372 | pass_clean_doit:
|
---|
[136] | 1373 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
|
---|
[75] | 1374 | pass := clean
|
---|
| 1375 | PASS := CLEAN
|
---|
| 1376 | $(eval $(def_pass))
|
---|
| 1377 | clean: pass_clean
|
---|
[183] | 1378 |
|
---|
[75] | 1379 | ## PASS: nothing
|
---|
| 1380 | # This pass just walks the tree.
|
---|
| 1381 | pass_nothing_doit:
|
---|
[106] | 1382 | $(call MSG_Ltarget,Did nothing in $(CURDIR))
|
---|
[75] | 1383 | pass := nothing
|
---|
| 1384 | PASS := NOTHING
|
---|
| 1385 | $(eval $(def_pass))
|
---|
| 1386 | nothing: pass_nothing
|
---|
| 1387 |
|
---|
[78] | 1388 |
|
---|
[183] | 1389 |
|
---|
[75] | 1390 | #
|
---|
| 1391 | # THE MAIN RULES
|
---|
| 1392 | #
|
---|
| 1393 | all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
|
---|
| 1394 |
|
---|
[130] | 1395 | rebuild: clean
|
---|
[120] | 1396 | $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 1397 |
|
---|
| 1398 |
|
---|
[75] | 1399 | # misc shortcuts.
|
---|
| 1400 | target: needed libraries binaries others
|
---|
| 1401 | objects: $(_OBJS)
|
---|
[189] | 1402 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
| 1403 | dlls: $(_DLLS)
|
---|
| 1404 | programs: $(_EXES)
|
---|
| 1405 | sysmods: $(_SYSMODS)
|
---|
[75] | 1406 |
|
---|
| 1407 |
|
---|
[72] | 1408 | # end-of-file-content
|
---|
[106] | 1409 | __footer_kmk__ := target
|
---|
[72] | 1410 | endif # __footer_kmk__
|
---|