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