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