[72] | 1 | # $Id: footer.kmk 81 2004-06-01 01:42:52Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
| 6 | # Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
| 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
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 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
|
---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 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.
|
---|
| 36 | ALL_TARGETS := $(LIBRARIES) $(PROGRAMS) $(DLLS) $(DRIVERS) $(OTHERS)
|
---|
| 37 |
|
---|
[75] | 38 | # dependency files.
|
---|
| 39 | _DEPFILES :=
|
---|
| 40 |
|
---|
| 41 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 42 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 43 | # required dependency file must add those output files to this variable.
|
---|
| 44 | _OUT_FILES :=
|
---|
| 45 |
|
---|
[72] | 46 | # all of a type
|
---|
| 47 | _OBJS :=
|
---|
| 48 | _LIBS :=
|
---|
| 49 | _DLLS :=
|
---|
| 50 | _EXES :=
|
---|
| 51 | _DIRS :=
|
---|
| 52 |
|
---|
| 53 | # all objs of a specific target
|
---|
| 54 | define def_objs_var
|
---|
| 55 | _OBJS_$1 :=
|
---|
| 56 | endef
|
---|
| 57 | $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
|
---|
| 58 |
|
---|
[73] | 59 |
|
---|
[72] | 60 | #
|
---|
[73] | 61 | # Basic macros
|
---|
| 62 | #
|
---|
| 63 |
|
---|
| 64 | ## Figure out the tool for a source
|
---|
| 65 | # @param $1 source file
|
---|
| 66 | # @param $2 normalized main target
|
---|
[78] | 67 | # @param $3 tooltype
|
---|
[79] | 68 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
| 69 | $($1_$2_$(3)TOOL.$(BUILD_TARGET)) $($1_$2_TOOL.$(BUILD_TARGET)) \
|
---|
| 70 | $($1_$2_$(3)TOOL) $($1_$2_TOOL) \
|
---|
| 71 | $($1_$(3)TOOL.$(BUILD_TARGET)) $($1_TOOL.$(BUILD_TARGET)) \
|
---|
| 72 | $($1_$(3)TOOL) $($1_TOOL) \
|
---|
| 73 | $($2_$(3)TOOL.$(BUILD_TARGET)) $($2_TOOL.$(BUILD_TARGET)) \
|
---|
| 74 | $($2_$(3)TOOL) $($2_TOOL) \
|
---|
| 75 | $($(3)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
|
---|
| 76 | $($(3)TOOL) $(TOOL) ))
|
---|
[73] | 77 |
|
---|
[78] | 78 | ## Figure out the tool for a target.
|
---|
| 79 | # @param $1 normalized target.
|
---|
| 80 | # @param $2 tooltype.
|
---|
[79] | 81 | _TARGET_TOOL = $(strip $(firstword \
|
---|
| 82 | $($(1)_$(2)TOOL.$(BUILD_TARGET)) $($(1)_$(2)TOOL) \
|
---|
| 83 | $($(1)_TOOL.$(BUILD_TARGET)) $($(1)_TOOL) \
|
---|
| 84 | $($(2)TOOL) $($(2)TOOL.$(BUILD_TARGET)) \
|
---|
| 85 | $(TOOL.$(BUILD_TARGET)) $(TOOL) \
|
---|
| 86 | ))
|
---|
[78] | 87 |
|
---|
[73] | 88 | ## Figure out where to put object files.
|
---|
| 89 | # @param $1 source file
|
---|
| 90 | # @param $2 normalized main target
|
---|
| 91 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
|
---|
| 92 |
|
---|
| 93 | ## Figure out where to put object files.
|
---|
| 94 | # @param $1 real target name.
|
---|
| 95 | # @param $2 normalized main target
|
---|
| 96 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | #
|
---|
[72] | 100 | # Include templates
|
---|
| 101 | #
|
---|
| 102 | _TEMPLATES := $(TEMPLATE)
|
---|
| 103 | define def_templates
|
---|
| 104 | ifdef $(target)_TEMPLATE
|
---|
| 105 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
| 106 | endif
|
---|
| 107 | endef
|
---|
| 108 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
| 109 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 110 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
| 111 |
|
---|
| 112 | define def_templates_include
|
---|
| 113 | ifndef TEMPLATE_$(template)
|
---|
| 114 | include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
|
---|
| 115 | endif
|
---|
| 116 | endef
|
---|
| 117 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 118 |
|
---|
[74] | 119 |
|
---|
[72] | 120 | #
|
---|
| 121 | # Common Inheritance
|
---|
| 122 | #
|
---|
| 123 |
|
---|
| 124 | ## Inherit defaults property
|
---|
| 125 | # @param $(prop) Property name
|
---|
| 126 | # @param $(target) Target name.
|
---|
| 127 | define def_inherit_defaults_one
|
---|
[74] | 128 | ifndef $(target)_$(prop)
|
---|
[72] | 129 | ifdef $(prop)
|
---|
[74] | 130 | $(target)_$(prop) := $($(prop))
|
---|
[72] | 131 | endif
|
---|
| 132 | endif
|
---|
| 133 | endef
|
---|
| 134 |
|
---|
| 135 | ## Inherit default properties for one target.
|
---|
| 136 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
| 137 | # is inherited from the default properties.
|
---|
| 138 | # @param $(target) Target name
|
---|
[78] | 139 | #
|
---|
[72] | 140 | define def_inherit_defaults
|
---|
| 141 | ifdef $(target)_TEMPLATE
|
---|
| 142 | ifndef TEMPLATE_$($(target)_TEMPLATE)_TOOL
|
---|
[78] | 143 | $(foreach prop,TOOL, $(eval $(def_inherit_defaults_one)))
|
---|
[72] | 144 | endif
|
---|
| 145 | ifndef TEMPLATE_$($(target)_TEMPLATE)_SDKS
|
---|
[78] | 146 | $(foreach prop,SDKS, $(eval $(def_inherit_defaults_one)))
|
---|
[72] | 147 | endif
|
---|
| 148 | else
|
---|
[78] | 149 | $(foreach prop,TEMPLATE TOOL SDKS,$(eval $(def_inherit_defaults_one)))
|
---|
[72] | 150 | endif
|
---|
| 151 | endef
|
---|
| 152 | # Inherit default properties.
|
---|
| 153 | $(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_defaults)))
|
---|
| 154 |
|
---|
| 155 |
|
---|
[78] | 156 | ## Inherit one template property in a accumulative manner.
|
---|
[72] | 157 | # @param $(prop) Property name
|
---|
| 158 | # @param $(target) Target name
|
---|
[78] | 159 | # @todo fix the precedence order for some properties.
|
---|
[72] | 160 | define def_inherit_template_one
|
---|
[78] | 161 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 162 | ifndef $(target)_$(prop)
|
---|
[78] | 163 | $(eval $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[72] | 164 | endif
|
---|
| 165 | endif
|
---|
[79] | 166 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
| 167 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
| 168 | $(eval $(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
|
---|
| 169 | endif
|
---|
| 170 | endif
|
---|
[72] | 171 | endef
|
---|
| 172 |
|
---|
[78] | 173 | ## Inherit one template property.
|
---|
| 174 | # @param $(prop) Property name
|
---|
| 175 | # @param $(target) Target name
|
---|
| 176 | define def_inherit_template_one_accumulate
|
---|
| 177 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 178 | $(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
| 179 | endif
|
---|
[79] | 180 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
| 181 | $(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
|
---|
| 182 | endif
|
---|
| 183 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
|
---|
| 184 | $(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
|
---|
| 185 | endif
|
---|
| 186 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
|
---|
| 187 | $(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
|
---|
| 188 | endif
|
---|
[78] | 189 | endef
|
---|
| 190 |
|
---|
[72] | 191 | ## Inherit template properties for on target.
|
---|
| 192 | # @param $(target) Target name.
|
---|
| 193 | define def_inherit_template
|
---|
[79] | 194 | $(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
|
---|
[78] | 195 | ,$(eval $(def_inherit_template_one)))
|
---|
| 196 | $(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS\
|
---|
| 197 | ,$(eval $(def_inherit_template_one_accumulate)))
|
---|
[72] | 198 | endef
|
---|
| 199 | # Inherit template properties
|
---|
| 200 | $(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_template)))
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | #
|
---|
| 205 | # Include tools
|
---|
| 206 | #
|
---|
| 207 | _TOOLS := $(TOOL)
|
---|
| 208 | define def_tools_target_source
|
---|
[78] | 209 | $(foreach tool,\
|
---|
[79] | 210 | $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 211 | $($(source)_TOOL) $($(target)_$(source)_TOOL)\
|
---|
[79] | 212 | $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 213 | $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
|
---|
[79] | 214 | $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 215 | $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
|
---|
[79] | 216 | $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 217 | $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
|
---|
[79] | 218 | $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 219 | $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
|
---|
[79] | 220 | $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 221 | $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
|
---|
| 222 | ,$(eval _TOOLS += $(tool)))
|
---|
[72] | 223 | endef
|
---|
| 224 | define def_tools_target
|
---|
[78] | 225 | $(foreach tool,\
|
---|
[79] | 226 | $($(target)_TOOL.$(BUILD_TARGET))\
|
---|
[78] | 227 | $($(target)_TOOL)\
|
---|
[79] | 228 | $($(target)_CTOOL.$(BUILD_TARGET))\
|
---|
[78] | 229 | $($(target)_CTOOL)\
|
---|
[79] | 230 | $($(target)_CXXTOOL.$(BUILD_TARGET))\
|
---|
[78] | 231 | $($(target)_CXXTOOL)\
|
---|
[79] | 232 | $($(target)_ASTOOL.$(BUILD_TARGET))\
|
---|
[78] | 233 | $($(target)_ASTOOL)\
|
---|
[79] | 234 | $($(target)_ARTOOL.$(BUILD_TARGET))\
|
---|
[78] | 235 | $($(target)_ARTOOL)\
|
---|
[79] | 236 | $($(target)_LDTOOL.$(BUILD_TARGET))\
|
---|
[78] | 237 | $($(target)_LDTOOL)\
|
---|
[79] | 238 | ,$(eval _TOOLS += $(tool)))
|
---|
[72] | 239 | $(foreach source, $($(target)_SOURCES), $(eval $(def_tools_target_source)))
|
---|
| 240 | endef
|
---|
| 241 | $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
|
---|
| 242 | _TOOLS := $(sort $(_TOOLS))
|
---|
| 243 |
|
---|
| 244 | define def_tools_include
|
---|
| 245 | ifndef TOOL_$(tool)
|
---|
| 246 | include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
|
---|
| 247 | endif
|
---|
| 248 | endef
|
---|
| 249 | $(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | #
|
---|
| 253 | # Include SDKs
|
---|
[73] | 254 | #
|
---|
[72] | 255 | _SDKS := $(SDKS)
|
---|
| 256 | define def_sdks_target_source
|
---|
| 257 | $(foreach sdk, $($(source)_SDKS) $($(target)_$(source)_SDKS), \
|
---|
| 258 | $(eval _SDKS += $(sdk)))
|
---|
| 259 | endef
|
---|
| 260 | define def_sdks_target
|
---|
| 261 | $(foreach sdk, $($(target)_SDKS), $(eval _SDKS += $(sdk)))
|
---|
| 262 | $(foreach source, $($(target)_SOURCES), $(eval $(def_sdks_target_source)))
|
---|
| 263 | endef
|
---|
| 264 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
| 265 | _SDKS := $(sort $(_SDKS))
|
---|
| 266 |
|
---|
| 267 | define def_sdks_include
|
---|
| 268 | ifndef SDK_$(sdk)
|
---|
| 269 | include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
|
---|
| 270 | endif
|
---|
| 271 | endef
|
---|
| 272 | $(foreach sdk, $(_SDKS), $(eval $(def_sdk)))
|
---|
| 273 |
|
---|
[73] | 274 | #
|
---|
| 275 | # Object processing.
|
---|
| 276 | #
|
---|
[72] | 277 |
|
---|
[73] | 278 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 279 | # @param $(target) Normalized target name.
|
---|
| 280 | # @param $(source) Source file name.
|
---|
| 281 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[72] | 282 | #
|
---|
[73] | 283 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
| 284 | define def_target_source_c_cpp_asm
|
---|
| 285 | #$ (warning dbg: def_target_source_c_cpp_asm: source=$(source) target=$(target) type=$(type))
|
---|
| 286 |
|
---|
[78] | 287 | $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
|
---|
[73] | 288 | $(eval defs :=\
|
---|
[78] | 289 | $(TOOL_$(tool)_DEFS)\
|
---|
| 290 | $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
|
---|
| 291 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
|
---|
| 292 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 293 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 294 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
| 295 | $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
[78] | 296 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 297 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 298 | $(SDKS),\
|
---|
| 299 | $(SDK_$(sdk)_DEFS)\
|
---|
| 300 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 301 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 302 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 303 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 304 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 305 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 306 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 307 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 308 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 309 | $(DEFS)\
|
---|
| 310 | $(DEFS.$(BUILD_TYPE))\
|
---|
[78] | 311 | $(DEFS.$(BUILD_TARGET))\
|
---|
| 312 | $(DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 313 | $(DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 314 | $($(type)DEFS)\
|
---|
| 315 | $($(type)DEFS.$(BUILD_TYPE))\
|
---|
| 316 | $($(type)DEFS.$(BUILD_TARGET))\
|
---|
| 317 | $($(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 318 | $($(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 319 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 320 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 321 | $($(target)_SDKS),\
|
---|
| 322 | $(SDK_$(sdk)_DEFS)\
|
---|
| 323 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 324 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 325 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 326 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 327 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 328 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 329 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 330 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 331 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 332 | $($(target)_DEFS)\
|
---|
| 333 | $($(target)_DEFS.$(BUILD_TYPE))\
|
---|
| 334 | $($(target)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 335 | $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 336 | $($(target)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 337 | $($(target)_$(type)DEFS)\
|
---|
| 338 | $($(target)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 339 | $($(target)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 340 | $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 341 | $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 342 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 343 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 344 | $($(source)_SDKS),\
|
---|
| 345 | $(SDK_$(sdk)_DEFS)\
|
---|
| 346 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 347 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 348 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 349 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 350 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 351 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 352 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 353 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 354 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 355 | $($(source)_DEFS)\
|
---|
| 356 | $($(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 357 | $($(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 358 | $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 359 | $($(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 360 | $($(source)_$(type)DEFS)\
|
---|
[74] | 361 | $($(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 362 | $($(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 363 | $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 364 | $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
| 365 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 366 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 367 | $($(target)_$(source)_SDKS),\
|
---|
| 368 | $(SDK_$(sdk)_DEFS)\
|
---|
| 369 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
| 370 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
| 371 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 372 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
|
---|
| 373 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 374 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 375 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
| 376 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 377 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
[74] | 378 | $($(target)_$(source)_DEFS)\
|
---|
| 379 | $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
|
---|
| 380 | $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
|
---|
[78] | 381 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 382 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
[74] | 383 | $($(target)_$(source)_$(type)DEFS)\
|
---|
| 384 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
| 385 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
[78] | 386 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
| 387 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 388 | )
|
---|
| 389 | $(eval incs :=\
|
---|
[78] | 390 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 391 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 392 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 393 | $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 394 | $($(target)_$(source)_$(type)INCS)\
|
---|
[78] | 395 | $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 396 | $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 397 | $($(target)_$(source)_INCS.$(BUILD_TARGET))\
|
---|
| 398 | $($(target)_$(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 399 | $($(target)_$(source)_INCS)\
|
---|
[78] | 400 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 401 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 402 | $($(target)_$(source)_SDKS),
|
---|
| 403 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 404 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 405 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 406 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 407 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 408 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 409 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 410 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 411 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 412 | $(SDK_$(sdk)_INCS))\
|
---|
| 413 | $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 414 | $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 415 | $($(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 416 | $($(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 417 | $($(source)_$(type)INCS)\
|
---|
[78] | 418 | $($(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 419 | $($(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 420 | $($(source)_INCS.$(BUILD_TARGET))\
|
---|
| 421 | $($(source)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 422 | $($(source)_INCS)\
|
---|
[78] | 423 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
| 424 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 425 | $($(source)_SDKS),\
|
---|
| 426 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 427 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 428 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 429 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 430 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 431 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 432 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 433 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 434 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 435 | $(SDK_$(sdk)_INCS))\
|
---|
| 436 | $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 437 | $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 438 | $($(target)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 439 | $($(target)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 440 | $($(target)_$(type)INCS)\
|
---|
[78] | 441 | $($(target)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 442 | $($(target)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 443 | $($(target)_INCS.$(BUILD_TARGET))\
|
---|
| 444 | $($(target)_INCS.$(BUILD_TYPE))\
|
---|
[73] | 445 | $($(target)_INCS)\
|
---|
[78] | 446 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
| 447 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
| 448 | $($(target)_SDKS),\
|
---|
| 449 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 450 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 451 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 452 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 453 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 454 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 455 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 456 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 457 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 458 | $(SDK_$(sdk)_INCS))\
|
---|
| 459 | $(INCS.$(BUILD_TARGET_CPU))\
|
---|
| 460 | $(INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 461 | $(INCS.$(BUILD_TARGET))\
|
---|
| 462 | $(INCS.$(BUILD_TYPE))\
|
---|
[73] | 463 | $(INCS)\
|
---|
[78] | 464 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
| 465 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 466 | $(SDKS),\
|
---|
| 467 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 468 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 469 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 470 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
| 471 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 472 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
| 473 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
| 474 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
| 475 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
| 476 | $(SDK_$(sdk)_INCS))\
|
---|
| 477 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
| 478 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
[74] | 479 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
|
---|
| 480 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
|
---|
[73] | 481 | $(TOOL_$(tool)_$(type)INCS)\
|
---|
| 482 | )
|
---|
| 483 | $(eval flags :=\
|
---|
| 484 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
| 485 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 486 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 487 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 488 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 489 | $($(type)FLAGS)\
|
---|
| 490 | $($(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 491 | $($(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 492 | $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 493 | $($(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 494 | $($(target)_$(type)FLAGS)\
|
---|
| 495 | $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 496 | $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 497 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 498 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 499 | $($(source)_$(type)FLAGS)\
|
---|
| 500 | $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 501 | $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 502 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 503 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 504 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
| 505 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
[74] | 506 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
[78] | 507 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
| 508 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
[73] | 509 | )
|
---|
| 510 | $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
|
---|
| 511 | $(eval dirdep := $(dir $(outbase)).dir_created)
|
---|
[74] | 512 | $(eval objsuff := $(firstword \
|
---|
| 513 | $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 514 | $($(target)_$(source)_OBJSUFF)\
|
---|
| 515 | $($(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 516 | $($(source)_OBJSUFF)\
|
---|
| 517 | $($(target)_OBJSUFF.$(BUILD_TARGET))\
|
---|
| 518 | $($(target)_OBJSUFF)\
|
---|
| 519 | $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
|
---|
| 520 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
| 521 | $(SUFF_OBJ)\
|
---|
| 522 | ))
|
---|
[73] | 523 | $(eval obj := $(outbase)$(objsuff))
|
---|
[74] | 524 | $(eval dep := $(outbase)$(SUFF_DEP))
|
---|
[73] | 525 |
|
---|
| 526 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
---|
| 527 | $(eval $(TOOL_$(tool)_COMPILE_$(type)))
|
---|
| 528 |
|
---|
| 529 | $(eval _OBJS_$(target) += $(obj))
|
---|
| 530 | $(eval _DEPFILES += $(dep))
|
---|
| 531 |
|
---|
| 532 | endef
|
---|
| 533 |
|
---|
| 534 | ## Generic macro for processing all target sources.
|
---|
[74] | 535 | # @param $(target) Normalized target name.
|
---|
[73] | 536 | define def_target_sources
|
---|
| 537 | #$ (warning def_target_sources)
|
---|
| 538 | # C sources
|
---|
| 539 | $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES))\
|
---|
| 540 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 541 |
|
---|
| 542 | # C++ sources
|
---|
| 543 | $(foreach type,CXX,$(foreach source, $(filter %.cpp, $($(target)_SOURCES)) $(filter %.cxx, $($(target)_SOURCES)) $(filter %.cc, $($(target)_SOURCES))\
|
---|
| 544 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 545 |
|
---|
| 546 | # ASM sources
|
---|
| 547 | $(foreach type,AS,$(foreach source, $(filter %.asm, $($(target)_SOURCES)) $(filter %.s, $($(target)_SOURCES)) $(filter %.S, $($(target)_SOURCES))\
|
---|
| 548 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
| 549 | endef
|
---|
| 550 |
|
---|
| 551 |
|
---|
| 552 | #
|
---|
[72] | 553 | # LIBRARIES
|
---|
[73] | 554 | #
|
---|
[72] | 555 |
|
---|
| 556 | ## Library (one).
|
---|
[74] | 557 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 558 | define def_lib
|
---|
[73] | 559 | # source -> object
|
---|
| 560 | $(eval $(def_target_sources))
|
---|
[72] | 561 |
|
---|
[73] | 562 | # library
|
---|
[78] | 563 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
| 564 | ifeq ($(tool),)
|
---|
| 565 | $$(error kBuild: Library target $(target) doesn't have a tool defined!)
|
---|
| 566 | endif
|
---|
[74] | 567 | $(eval flags :=\
|
---|
| 568 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
| 569 | $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 570 | $(ARFLAGS)\
|
---|
| 571 | $(ARFLAGS.$(BUILD_TYPE))\
|
---|
| 572 | $($(target)_ARFLAGS)\
|
---|
| 573 | $($(target)_ARFLAGS.$(BUILD_TYPE))\
|
---|
| 574 | )
|
---|
| 575 | $(eval libsuff := $(firstword\
|
---|
| 576 | $($(target)_LIBSUFF.$(BUILD_TARGET))\
|
---|
| 577 | $($(target)_LIBSUFF)\
|
---|
| 578 | $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
|
---|
| 579 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
| 580 | $(SUFF_LIB)\
|
---|
| 581 | ))
|
---|
[73] | 582 | ## @todo prefix
|
---|
| 583 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 584 | $(eval lib := $(outbase)$(libsuff))
|
---|
| 585 | $(eval objs = $(_OBJS_$(target)))
|
---|
| 586 | $(eval dirdep := $(dir $(lib)).dir_created)
|
---|
[78] | 587 | ## @todo fix dependencies on makefiles an such
|
---|
[73] | 588 | $(eval deps := )
|
---|
[72] | 589 |
|
---|
[73] | 590 | $(eval $(TOOL_$(tool)_LINK_LIBRARY))
|
---|
[72] | 591 |
|
---|
[73] | 592 | _OBJS += $(_OBJS_$(target))
|
---|
| 593 | _LIBS += $(lib)
|
---|
[75] | 594 | _OUT_FILES += $(lib)
|
---|
[72] | 595 | endef
|
---|
| 596 |
|
---|
| 597 | # Process libraries
|
---|
| 598 | $(foreach target, $(LIBRARIES), $(eval $(def_lib)))
|
---|
| 599 |
|
---|
| 600 |
|
---|
| 601 |
|
---|
| 602 | #
|
---|
| 603 | # PROGRAMS
|
---|
| 604 | #
|
---|
| 605 |
|
---|
[74] | 606 | ## Program (one).
|
---|
| 607 | # @param $(target) Normalized target (program) name.
|
---|
| 608 | define def_program
|
---|
| 609 | # source -> object
|
---|
| 610 | $(eval $(def_target_sources))
|
---|
[72] | 611 |
|
---|
[74] | 612 | # library
|
---|
[78] | 613 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
[74] | 614 | $(eval flags :=\
|
---|
| 615 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
| 616 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 617 | $(LDFLAGS)\
|
---|
| 618 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
| 619 | $($(target)_LDFLAGS)\
|
---|
| 620 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
| 621 | )
|
---|
| 622 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
|
---|
| 623 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
| 624 | $(eval exe := $(outbase)$(exesuff))
|
---|
| 625 | $(eval objs = $(_OBJS_$(target)))
|
---|
| 626 | $(eval libs :=\
|
---|
| 627 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
| 628 | $($(target)_LIBS)\
|
---|
| 629 | $(LIBS.$(BUILD_TYPE))\
|
---|
| 630 | $(LIBS)\
|
---|
| 631 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
| 632 | $(TOOL_$(tool)_LIBS)\
|
---|
| 633 | )
|
---|
| 634 | $(eval libpath :=\
|
---|
| 635 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 636 | $($(target)_LIBPATH)\
|
---|
| 637 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
| 638 | $(LIBPATH)\
|
---|
| 639 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
| 640 | $(TOOL_$(tool)_LIBPATH)\
|
---|
| 641 | )
|
---|
| 642 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
| 643 | ## @todo fix dependencies
|
---|
| 644 | $(eval deps := )
|
---|
| 645 | #
|
---|
| 646 | $(eval deffile := $(strip $(firstword
|
---|
| 647 | $($(target)_DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 648 | $($(target)_DEFFILE.$(BUILD_TARGET))\
|
---|
| 649 | $($(target)_DEFFILE.$(BUILD_TYPE))\
|
---|
| 650 | $($(target)_DEFFILE)\
|
---|
| 651 | $(DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 652 | $(DEFFILE.$(BUILD_TARGET))\
|
---|
| 653 | $(DEFFILE.$(BUILD_TYPE))\
|
---|
| 654 | $(DEFFILE)\
|
---|
| 655 | )))
|
---|
| 656 | $(eval custom_pre := $(strip $(firstword
|
---|
| 657 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 658 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 659 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 660 | $($(target)_CUSTOM_PRE)\
|
---|
| 661 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 662 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
| 663 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
| 664 | $(CUSTOM_PRE)\
|
---|
| 665 | )))
|
---|
| 666 | $(eval custom_post := $(strip $(firstword
|
---|
| 667 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 668 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 669 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 670 | $($(target)_CUSTOM_POST)\
|
---|
| 671 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
| 672 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
| 673 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
| 674 | $(CUSTOM_POST)\
|
---|
| 675 | )))
|
---|
[72] | 676 |
|
---|
[74] | 677 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
| 678 |
|
---|
| 679 | _OBJS += $(_OBJS_$(target))
|
---|
| 680 | _EXES += $(exe)
|
---|
[75] | 681 | _OUT_FILES += $(exe)
|
---|
[74] | 682 | endef
|
---|
| 683 |
|
---|
| 684 | # Process libraries
|
---|
| 685 | $(foreach target, $(PROGRAMS), $(eval $(def_program)))
|
---|
| 686 |
|
---|
| 687 |
|
---|
| 688 |
|
---|
[72] | 689 | #
|
---|
| 690 | # DLLS
|
---|
| 691 | #
|
---|
| 692 |
|
---|
| 693 |
|
---|
| 694 |
|
---|
| 695 | #
|
---|
| 696 | # DRIVERS
|
---|
| 697 | #
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 | #
|
---|
| 702 | # OTHERS
|
---|
| 703 | #
|
---|
| 704 |
|
---|
| 705 |
|
---|
| 706 |
|
---|
| 707 | #
|
---|
| 708 | # DOCS
|
---|
| 709 | #
|
---|
| 710 |
|
---|
| 711 |
|
---|
| 712 | #
|
---|
| 713 | # Directories.
|
---|
| 714 | #
|
---|
[75] | 715 | _OUTPUT_FILES := $(_OBJS) $(_LIBS) $(_EXES) $(_DLLS)
|
---|
| 716 | _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(dir $(_OUTPUT_FILES))))
|
---|
[72] | 717 |
|
---|
| 718 | define def_createdir
|
---|
| 719 | $(dirfile):
|
---|
[73] | 720 | $(call MSG_L1,Creating directory $$(@D))
|
---|
[72] | 721 | $(MKDIR) -p $$(@D)
|
---|
[73] | 722 | @echo dir_created > $$@
|
---|
[72] | 723 | endef
|
---|
| 724 |
|
---|
| 725 | $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
|
---|
| 726 |
|
---|
[75] | 727 |
|
---|
[72] | 728 | #
|
---|
[75] | 729 | # Include dependency files.
|
---|
[72] | 730 | #
|
---|
[75] | 731 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
[72] | 732 |
|
---|
[75] | 733 |
|
---|
| 734 | #
|
---|
| 735 | # PASSES (including directory and makefile walking)
|
---|
| 736 | #
|
---|
| 737 | # Do all the default passes if it's unspecified.
|
---|
| 738 | PASSES ?= needed libraries binaries others publish
|
---|
[72] | 739 |
|
---|
[75] | 740 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 741 | # The user can overload this list.
|
---|
| 742 | DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
|
---|
[72] | 743 |
|
---|
[75] | 744 | ## Subdir
|
---|
| 745 | # @param $(pass) Lowercase pass name.
|
---|
| 746 | # @param $(PASS) Uppercase pass name.
|
---|
| 747 | # @param $(subdir) Subdirectory
|
---|
| 748 | # @param $(tag) tag to attach to the rule name.
|
---|
| 749 | define def_pass_subdir
|
---|
| 750 | pass_$(pass)$(tag)::
|
---|
| 751 | $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
| 752 | endef
|
---|
[72] | 753 |
|
---|
[75] | 754 | ## Submakefile
|
---|
| 755 | # @param $(pass) Lowercase pass name.
|
---|
| 756 | # @param $(PASS) Uppercase pass name.
|
---|
| 757 | # @param $(makefile) Makefile.
|
---|
| 758 | # @param $(tag) tag to attach to the rule name.
|
---|
| 759 | define def_pass_makefile
|
---|
| 760 | pass_$(pass)$(tag)::
|
---|
| 761 | $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
| 762 | endef
|
---|
[73] | 763 |
|
---|
[74] | 764 |
|
---|
[75] | 765 | ## Execute a pass.
|
---|
| 766 | # @param $(pass) Lowercase pass name.
|
---|
| 767 | # @param $(PASS) Uppercase pass name.
|
---|
| 768 | define def_pass
|
---|
| 769 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS))
|
---|
| 770 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER))
|
---|
| 771 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
|
---|
| 772 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER))
|
---|
| 773 |
|
---|
| 774 | $(eval tag:=_before)
|
---|
| 775 | $(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
| 776 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
| 777 |
|
---|
| 778 | $(eval tag:=_after)
|
---|
| 779 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
| 780 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
| 781 |
|
---|
| 782 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 783 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
| 784 | pass_$(pass): \
|
---|
| 785 | pass_$(pass)_before \
|
---|
| 786 | pass_$(pass)_doit \
|
---|
| 787 | pass_$(pass)_after
|
---|
| 788 |
|
---|
| 789 | endef
|
---|
| 790 |
|
---|
[76] | 791 |
|
---|
[75] | 792 | ## PASS: needed
|
---|
| 793 | # This pass builds targets which are required for building the rest.
|
---|
| 794 | pass_needed_doit: $(_NEEDEDS)
|
---|
| 795 | pass := needed
|
---|
| 796 | PASS := NEEDED
|
---|
| 797 | $(eval $(def_pass))
|
---|
| 798 |
|
---|
| 799 | ## PASS: libraries
|
---|
| 800 | # This pass builds library targets.
|
---|
| 801 | pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
| 802 | pass := libraries
|
---|
| 803 | PASS := LIBRARIES
|
---|
| 804 | $(eval $(def_pass))
|
---|
| 805 |
|
---|
| 806 | ## PASS: binaries
|
---|
| 807 | # This pass builds binary targets, i.e. programs, dlls, drivers and stuff.
|
---|
| 808 | pass_binaries_doit: $(_DLLS) $(_EXES) $(_KMODS) $(_OTHER_BINARIES)
|
---|
| 809 | pass := binaries
|
---|
| 810 | PASS := BINARIES
|
---|
| 811 | $(eval $(def_pass))
|
---|
| 812 |
|
---|
| 813 | ## PASS: others
|
---|
| 814 | # This pass builds binary targets, i.e. programs, dlls, drivers and stuff.
|
---|
| 815 | pass_others_doit: $(_OTHERS)
|
---|
| 816 | pass := others
|
---|
| 817 | PASS := OTHERS
|
---|
| 818 | $(eval $(def_pass))
|
---|
| 819 |
|
---|
| 820 | ## PASS: publish
|
---|
| 821 | # This pass installs the built entities to a sandbox area.
|
---|
| 822 | pass_publish_doit: publish
|
---|
| 823 | publish::
|
---|
| 824 | pass := publish
|
---|
| 825 | PASS := PUBLISH
|
---|
[76] | 826 | # $(sort).. not nice.
|
---|
[75] | 827 | SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
|
---|
| 828 | SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
|
---|
| 829 | MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
|
---|
| 830 | MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
|
---|
| 831 | $(eval $(def_pass))
|
---|
| 832 |
|
---|
| 833 | ## PASS: packing
|
---|
| 834 | # This pass processes custom packing rules.
|
---|
| 835 | pass_packing_doit: packing
|
---|
| 836 | packing::
|
---|
| 837 | pass := packing
|
---|
| 838 | PASS := PACKING
|
---|
| 839 | $(eval $(def_pass))
|
---|
| 840 |
|
---|
| 841 | ## PASS: clean
|
---|
| 842 | # This pass removes all generated files.
|
---|
| 843 | pass_clean_doit:
|
---|
| 844 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES)
|
---|
| 845 | pass := clean
|
---|
| 846 | PASS := CLEAN
|
---|
| 847 | $(eval $(def_pass))
|
---|
| 848 | clean: pass_clean
|
---|
| 849 |
|
---|
| 850 | ## PASS: nothing
|
---|
| 851 | # This pass just walks the tree.
|
---|
| 852 | pass_nothing_doit:
|
---|
| 853 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
| 854 | pass := nothing
|
---|
| 855 | PASS := NOTHING
|
---|
| 856 | $(eval $(def_pass))
|
---|
| 857 | nothing: pass_nothing
|
---|
| 858 |
|
---|
[78] | 859 |
|
---|
| 860 |
|
---|
[75] | 861 | #
|
---|
| 862 | # THE MAIN RULES
|
---|
| 863 | #
|
---|
| 864 | all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
|
---|
| 865 |
|
---|
[78] | 866 | rebuild: clean all_recursive
|
---|
| 867 |
|
---|
| 868 |
|
---|
[75] | 869 | # misc shortcuts.
|
---|
| 870 | target: needed libraries binaries others
|
---|
| 871 | objects: $(_OBJS)
|
---|
| 872 | programs: $(_EXES)
|
---|
| 873 | dlls: $(_DLLS)
|
---|
| 874 | kernelmodules: $(_KMODS)
|
---|
| 875 |
|
---|
| 876 |
|
---|
[72] | 877 | # end-of-file-content
|
---|
| 878 | __footer_kmk__ := 1
|
---|
| 879 | endif # __footer_kmk__
|
---|