Changeset 353 for trunk/kBuild/footer.kmk
- Timestamp:
- Dec 12, 2005, 4:36:07 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer.kmk
r316 r353 4 4 # kBuild - File included at top of makefile. 5 5 # 6 # Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>6 # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net> 7 7 # 8 8 # … … 21 21 # You should have received a copy of the GNU General Public License 22 22 # along with kBuild; if not, write to the Free Software 23 # Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA 0sourcetargettargettarget-targettype07 USA23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 24 # 25 25 # … … 34 34 35 35 # all targets. 36 ALL_TARGETS := \36 ALL_TARGETS += \ 37 37 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \ 38 38 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \ … … 41 41 $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \ 42 42 $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \ 43 $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \ 43 44 $(OTHERS) $(OTHERS.$(BUILD_TARGET)) 44 45 … … 50 51 # required dependency file must add those output files to this variable. 51 52 _OUT_FILES := 53 54 # Files which only requires cleaning up. 55 _CLEAN_FILES := 52 56 53 57 # all of a type … … 58 62 _PROGRAMS := 59 63 _SYSMODS := 60 _DIRS := 64 _INSTALLS := 65 _OTHERS := 66 _DIRS := $(PATH_TARGET)/ 61 67 _IMPORT_LIBS := 62 68 … … 64 70 pass_prev := 65 71 66 67 # all objs of a specific target68 define def_objs_var69 _OBJS_$target :=70 endef71 $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))72 72 73 73 # … … 136 136 137 137 138 ## Figure out the actual name of an installed file. 139 # @param $1 The file to install. 140 # @param $2 The target name. 141 # @param $3 The _INST value (can be empty). 142 # @param $4 The default directory to use when $3 is empty. 143 _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/)) 144 145 138 146 # 139 147 # Check syntax which leads to weird syntax errors. … … 165 173 define def_templates_include 166 174 ifndef TEMPLATE_$(template) 167 include $(firstword $( wildcard $(PATH_KBUILD)/templates/$(template).kmk))175 include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk))) 168 176 endif 169 177 endef … … 213 221 214 222 215 ## Inherit one template property in a accumulative manner.223 ## Inherit one template property in a non-accumulative manner. 216 224 # @param $(prop) Property name 217 225 # @param $(target) Target name … … 220 228 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) 221 229 ifndef $(target)_$(prop) 222 #$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))'TEMPLATE_$($(target)_TEMPLATE)_$(prop))223 $$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))230 $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) 231 #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop)) 224 232 endif 225 233 endif 226 234 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET) 227 235 ifndef $(target)_$(prop).$(BUILD_TARGET) 228 #$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 229 $$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET)) 236 #$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 237 $(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 238 endif 239 endif 240 endef 241 242 ## Inherit one template property in a non-accumulative manner, deferred expansion. 243 # @param 1: $(prop) Property name 244 # @param 2: $(target) Target name 245 # @todo fix the precedence order for some properties. 246 # @remark this define relies on double evaluation 247 define def_inherit_template_one_deferred 248 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) 249 ifndef $(target)_$(prop) 250 $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) 251 #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop)) 252 endif 253 endif 254 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET) 255 ifndef $(target)_$(prop).$(BUILD_TARGET) 256 #$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 257 $(target)_$(prop).$(BUILD_TARGET) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 230 258 endif 231 259 endif … … 237 265 define def_inherit_template_one_accumulate 238 266 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop) 239 #$ $(warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))240 $ $(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))241 #$ $(warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))267 #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))) 268 $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) 269 #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop))) 242 270 endif 243 271 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)))272 #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)) 273 $(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)) 246 274 endif 247 275 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET) 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)))276 #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 277 $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)) 250 278 endif 251 279 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU) 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)))280 #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)) 281 $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)) 254 282 endif 255 283 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH) 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))) 258 endif 259 endef 260 284 #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)) 285 $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)) 286 endif 287 endef 261 288 262 289 ## Inherit template properties for on target. 263 290 # @param $(target) Target name. 264 291 define def_inherit_template 265 $$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST\ 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 \ 268 BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ 269 ,$$(eval $$(def_inherit_template_one_accumulate))) 270 endef 292 $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one))) 293 $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value! 294 $(foreach prop,$(PROPS_ACCUMULATE),$(eval $(value def_inherit_template_one_accumulate))) 295 endef 296 271 297 # Inherit template properties 272 $(foreach target, $(ALL_TARGETS),$(eval $( def_inherit_template)))298 $(foreach target, $(ALL_TARGETS),$(eval $(value def_inherit_template))) 273 299 274 300 … … 278 304 _TOOLS := $(TOOL) 279 305 define def_tools_target_source 280 $(foreach tool,\ 281 $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\ 282 $($(source)_TOOL) $($(target)_$(source)_TOOL)\ 283 $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\ 284 $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\ 285 $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\ 286 $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\ 287 $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\ 288 $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\ 289 $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\ 290 $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\ 291 $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\ 292 $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\ 293 ,$(eval _TOOLS += $(tool))) 294 endef 306 $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ 307 $($(source)_$(prop).$(BUILD_TARGET)) \ 308 $($(target)_$(source)_$(prop).$(BUILD_TARGET)) \ 309 $($(source)_$(prop)) \ 310 $($(target)_$(source)_$(prop)))) 311 endef 312 295 313 define def_tools_target 296 $(foreach tool,\ 297 $($(target)_TOOL.$(BUILD_TARGET))\ 298 $($(target)_TOOL)\ 299 $($(target)_CTOOL.$(BUILD_TARGET))\ 300 $($(target)_CTOOL)\ 301 $($(target)_CXXTOOL.$(BUILD_TARGET))\ 302 $($(target)_CXXTOOL)\ 303 $($(target)_ASTOOL.$(BUILD_TARGET))\ 304 $($(target)_ASTOOL)\ 305 $($(target)_ARTOOL.$(BUILD_TARGET))\ 306 $($(target)_ARTOOL)\ 307 $($(target)_LDTOOL.$(BUILD_TARGET))\ 308 $($(target)_LDTOOL)\ 309 ,$(eval _TOOLS += $(tool))) 310 $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE)) \ 311 , $(eval $(def_tools_target_source))) 312 endef 313 $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target))) 314 $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \ 315 $($(target)_$(prop).$(BUILD_TARGET)) \ 316 $($(target)_$(prop)))) 317 $(foreach source, \ 318 $($(target)_SOURCES.$(BUILD_TARGET)) \ 319 $($(target)_SOURCES.$(BUILD_TYPE)) \ 320 $($(target)_SOURCES) \ 321 , $(eval $(value def_tools_target_source))) 322 endef 323 324 $(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target))) 314 325 _TOOLS := $(sort $(_TOOLS)) 315 326 316 327 define def_tools_include 317 328 ifndef TOOL_$(tool) 318 include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk)) 319 endif 320 endef 321 $(foreach tool, $(_TOOLS), $(eval $(def_tools_include))) 329 TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk))) 330 ifeq ($(TOOL_$(tool)_KMK_FILE),) 331 $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools) 332 endif 333 include $(TOOL_$(tool)_KMK_FILE) 334 endif 335 endef 336 $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include))) 322 337 323 338 … … 342 357 define def_sdks_include_one 343 358 ifndef SDK_$(sdk) 344 include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk)) 345 endif 346 endef 347 $(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one))) 359 SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk))) 360 ifeq ($(SDK_$(sdk)_KMK_FILE),) 361 $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks) 362 endif 363 include $(SDK_$(sdk)_KMK_FILE) 364 endif 365 endef 366 $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one))) 348 367 349 368 # 350 369 # Object processing. 351 370 # 371 372 ## Generates the '::' rule for building all objects of a source file. 373 # @param $(obj) The object file. 374 define def_target_obj_rule 375 $(basename $(notdir $(obj))).o:: 376 + $$(MAKE) -B -f $$(MAKEFILE) $(obj) 377 $(basename $$(notdir $$(obj))).obj:: 378 + $$(MAKE) -B -f $$(MAKEFILE) $(obj) 379 endef 352 380 353 381 … … 366 394 #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)') 367 395 368 $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))369 $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))370 $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))371 $(eval dirdep := $(dir $(outbase)).dir_created)372 $(evaldefs :=\396 tool := $(call _SOURCE_TOOL,$(source),$(target),$(type)) 397 outbase := $(call _OBJECT_BASE,$(source),$(target)) 398 PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))) 399 dirdep := $(call DIRDEP,$(dir $(outbase))) 400 defs :=\ 373 401 $(TOOL_$(tool)_DEFS)\ 374 402 $(TOOL_$(tool)_DEFS.$(bld_type))\ … … 381 409 $(SDKS.$(bld_type)) \ 382 410 $(SDKS),\ 383 $(SDK_$(sdk)_DEFS)\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))\388 $(SDK_$(sdk)_$(type)DEFS)\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)))\411 $(SDK_$(sdk)_DEFS)\ 412 $(SDK_$(sdk)_DEFS.$(bld_type))\ 413 $(SDK_$(sdk)_DEFS.$(bld_trg))\ 414 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\ 415 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\ 416 $(SDK_$(sdk)_$(type)DEFS)\ 417 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\ 418 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\ 419 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\ 420 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\ 393 421 $(DEFS)\ 394 422 $(DEFS.$(bld_type))\ … … 404 432 $($(target)_SDKS.$(bld_type)) \ 405 433 $($(target)_SDKS),\ 406 $(SDK_$(sdk)_DEFS)\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))\411 $(SDK_$(sdk)_$(type)DEFS)\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)))\434 $(SDK_$(sdk)_DEFS)\ 435 $(SDK_$(sdk)_DEFS.$(bld_type))\ 436 $(SDK_$(sdk)_DEFS.$(bld_trg))\ 437 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\ 438 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\ 439 $(SDK_$(sdk)_$(type)DEFS)\ 440 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\ 441 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\ 442 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\ 443 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\ 416 444 $($(target)_DEFS)\ 417 445 $($(target)_DEFS.$(bld_type))\ … … 427 455 $($(source)_SDKS.$(bld_type)) \ 428 456 $($(source)_SDKS),\ 429 $(SDK_$(sdk)_DEFS)\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))\434 $(SDK_$(sdk)_$(type)DEFS)\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)))\457 $(SDK_$(sdk)_DEFS)\ 458 $(SDK_$(sdk)_DEFS.$(bld_type))\ 459 $(SDK_$(sdk)_DEFS.$(bld_trg))\ 460 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\ 461 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\ 462 $(SDK_$(sdk)_$(type)DEFS)\ 463 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\ 464 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\ 465 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\ 466 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\ 439 467 $($(source)_DEFS)\ 440 468 $($(source)_DEFS.$(bld_type))\ … … 450 478 $($(target)_$(source)_SDKS.$(bld_type)) \ 451 479 $($(target)_$(source)_SDKS),\ 452 $(SDK_$(sdk)_DEFS)\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))\457 $(SDK_$(sdk)_$(type)DEFS)\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)))\480 $(SDK_$(sdk)_DEFS)\ 481 $(SDK_$(sdk)_DEFS.$(bld_type))\ 482 $(SDK_$(sdk)_DEFS.$(bld_trg))\ 483 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\ 484 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\ 485 $(SDK_$(sdk)_$(type)DEFS)\ 486 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\ 487 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\ 488 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\ 489 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\ 462 490 $($(target)_$(source)_DEFS)\ 463 491 $($(target)_$(source)_DEFS.$(bld_type))\ … … 469 497 $($(target)_$(source)_$(type)DEFS.$(bld_trg))\ 470 498 $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\ 471 $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))\ 472 ) 473 $(eval incs :=\ 499 $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu)) 500 incs :=\ 474 501 $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\ 475 502 $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\ … … 485 512 $($(target)_$(source)_SDKS.$(bld_type)) \ 486 513 $($(target)_$(source)_SDKS),\ 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))\491 $(SDK_$(sdk)_$(type)INCS)\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))\496 $(SDK_$(sdk)_INCS))\514 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\ 515 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\ 516 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\ 517 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\ 518 $(SDK_$(sdk)_$(type)INCS)\ 519 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\ 520 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\ 521 $(SDK_$(sdk)_INCS.$(bld_trg))\ 522 $(SDK_$(sdk)_INCS.$(bld_type))\ 523 $(SDK_$(sdk)_INCS))\ 497 524 $($(source)_$(type)INCS.$(bld_trg_cpu))\ 498 525 $($(source)_$(type)INCS.$(bld_trg_arch))\ … … 508 535 $($(source)_SDKS.$(bld_type)) \ 509 536 $($(source)_SDKS),\ 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))\514 $(SDK_$(sdk)_$(type)INCS)\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))\519 $(SDK_$(sdk)_INCS))\537 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\ 538 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\ 539 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\ 540 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\ 541 $(SDK_$(sdk)_$(type)INCS)\ 542 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\ 543 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\ 544 $(SDK_$(sdk)_INCS.$(bld_trg))\ 545 $(SDK_$(sdk)_INCS.$(bld_type))\ 546 $(SDK_$(sdk)_INCS))\ 520 547 $($(target)_$(type)INCS.$(bld_trg_cpu))\ 521 548 $($(target)_$(type)INCS.$(bld_trg_arch))\ … … 531 558 $($(target)_SDKS.$(bld_type)) \ 532 559 $($(target)_SDKS),\ 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))\537 $(SDK_$(sdk)_$(type)INCS)\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))\542 $(SDK_$(sdk)_INCS))\560 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\ 561 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\ 562 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\ 563 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\ 564 $(SDK_$(sdk)_$(type)INCS)\ 565 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\ 566 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\ 567 $(SDK_$(sdk)_INCS.$(bld_trg))\ 568 $(SDK_$(sdk)_INCS.$(bld_type))\ 569 $(SDK_$(sdk)_INCS))\ 543 570 $(INCS.$(bld_trg_cpu))\ 544 571 $(INCS.$(bld_trg_arch))\ … … 549 576 $(SDKS.$(bld_type)) \ 550 577 $(SDKS),\ 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))\555 $(SDK_$(sdk)_$(type)INCS)\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))\560 $(SDK_$(sdk)_INCS))\578 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\ 579 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\ 580 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\ 581 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\ 582 $(SDK_$(sdk)_$(type)INCS)\ 583 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\ 584 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\ 585 $(SDK_$(sdk)_INCS.$(bld_trg))\ 586 $(SDK_$(sdk)_INCS.$(bld_type))\ 587 $(SDK_$(sdk)_INCS))\ 561 588 $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\ 562 589 $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\ 563 590 $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\ 564 591 $(TOOL_$(tool)_$(type)INCS.$(bld_type))\ 565 $(TOOL_$(tool)_$(type)INCS)\ 566 ) 567 $(eval flags :=\ 592 $(TOOL_$(tool)_$(type)INCS) 593 flags :=\ 568 594 $(TOOL_$(tool)_$(type)FLAGS)\ 569 595 $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\ … … 590 616 $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\ 591 617 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\ 592 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))\ 593 ) 594 $(eval objsuff := $(firstword \ 618 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu)) 619 objsuff := $(firstword \ 595 620 $($(target)_$(source)_OBJSUFF.$(bld_trg))\ 596 621 $($(target)_$(source)_OBJSUFF)\ … … 601 626 $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\ 602 627 $(TOOL_$(tool)_$(type)OBJSUFF)\ 603 $(SUFF_OBJ)\ 604 )) 605 $(eval obj := $(outbase)$(objsuff)) 606 $(eval dep := $(outbase)$(SUFF_DEP)) 607 $(eval deps := \ 628 $(SUFF_OBJ)) 629 obj := $(outbase)$(objsuff) 630 dep := $(outbase)$(SUFF_DEP) 631 deps := \ 608 632 $($(target)_$(source)_DEPS)\ 609 610 611 612 633 $($(target)_$(source)_DEPS.$(bld_type))\ 634 $($(target)_$(source)_DEPS.$(bld_trg))\ 635 $($(target)_$(source)_DEPS.$(bld_trg_arch))\ 636 $($(target)_$(source)_DEPS.$(bld_trg_cpu))\ 613 637 $($(source)_DEPS)\ 614 638 $($(source)_DEPS.$(bld_type))\ 615 639 $($(source)_DEPS.$(bld_trg))\ 640 $($(source)_DEPS.$(bld_trg_arch))\ 641 $($(source)_DEPS.$(bld_trg_cpu))\ 616 642 $($(target)_DEPS)\ 643 $($(target)_DEPS.$(bld_type))\ 617 644 $($(target)_DEPS.$(bld_trg_arch))\ 618 $($(target)_DEPS.$(bld_trg_cpu)) )645 $($(target)_DEPS.$(bld_trg_cpu)) 619 646 620 647 621 648 #$ (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)) 622 649 ifndef TOOL_$(tool)_COMPILE_$(type) 623 $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) ) 624 $$(warning kBuild: tools: \ 650 $(warning kBuild: tools: \ 625 651 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \ 626 652 2 $($(target)_$(source)_$(type)TOOL) \ … … 639 665 15 $(TOOL.$(bld_trg)) \ 640 666 16 $(TOOL) ) 641 endif 667 $(error kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) ) 668 endif 669 670 # generate the rules 642 671 $(eval $(TOOL_$(tool)_COMPILE_$(type))) 643 672 644 $$(basename $$(notdir $$(obj))).o:: 645 + $$(MAKE) -B -f $$(MAKEFILE) $(obj) 646 $$(basename $$(notdir $$(obj))).obj:: 647 + $$(MAKE) -B -f $$(MAKEFILE) $(obj) 648 649 $(eval _OBJS_$(target) += $(obj)) 650 $(eval _DEPFILES += $(dep)) 673 $(eval $(def_target_obj_rule)) 674 675 $(target)_OBJS_ += $(obj) 676 _DEPFILES += $(dep) 651 677 652 678 endef … … 657 683 #$ (warning def_target_sources) 658 684 # C sources 659 $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\ 660 ,$(eval $(def_target_source_c_cpp_asm)) )) 685 type := C 686 $(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 687 ,$(eval $(value def_target_source_c_cpp_asm)) ) 661 688 662 689 # C++ sources 663 $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\ 664 ,$(eval $(def_target_source_c_cpp_asm)) )) 690 type := CXX 691 $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 692 ,$(eval $(value def_target_source_c_cpp_asm)) ) 665 693 666 694 # ASM sources 667 $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\ 668 ,$(eval $(def_target_source_c_cpp_asm)) )) 669 endef 670 671 672 # 673 # BLDPROGS 674 # 675 676 ## Build program (one). 677 # @param $(target) Normalized target (program) name. 678 define def_bldprog 695 type := AS 696 $(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 697 ,$(eval $(value def_target_source_c_cpp_asm)) ) 698 699 endef 700 701 ## Generate the link & lib install rule 702 # @param $(target) Normalized target name. 703 # @param $(out) The build target. 704 # @param $(INSTARGET_$(target)) The installation targets. 705 define def_link_install_rule 706 $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target)))) 707 $(RM) -f $$@ 708 $(CP) $(out) $$@ 709 endef 710 711 712 713 ## Generic macro for generating the install rule(s) for a target 714 # and update the globals with default out. 715 # 716 # @param $(target) Normalized target name. 717 # @param $(out) The output file. 718 # @param $(definst) The default _INST value. 719 # @param $(typevar) The name of the variable with all the root targets of its type. 720 # @obsolete 721 define def_target_install_pluss 722 ifndef $(target)_NOINST 723 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \ 724 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/)) 725 726 $(eval $(def_link_install_rule)) 727 728 _INSTALLS += $(INSTARGET_$(target)) 729 730 ifdef KBUILD_DO_AUTO_INSTALL 731 $(typevar) += $(INSTARGET_$(target)) 732 else 733 $(typevar) += $(out) 734 endif 735 else # _NOINST 736 $(typevar) += $(out) 737 endif 738 739 _OUT_FILES += $(out) 740 _CLEAN_FILES += $($(target)_CLEAN) 741 _OBJS += $($(target)_OBJS_) 742 743 endef 744 745 746 747 # 748 # LIBRARIES 749 # 750 751 ## Library (one). 752 # @param $(target) Normalized library (target) name. 753 define def_lib 754 # library basics 755 ## @todo prefix 756 bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE)) 757 bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET)) 758 bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)) 759 bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU)) 760 tool := $(call _TARGET_TOOL,$(target),AR) 761 ifeq ($(tool),) 762 $(error kBuild: Library target $(target) does not have a tool defined!) 763 endif 764 outbase := $(call _TARGET_BASE,$(target),$(target)) 765 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))) 766 suff := $(firstword\ 767 $($(target)_LIBSUFF.$(bld_trg))\ 768 $($(target)_LIBSUFF)\ 769 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\ 770 $(TOOL_$(tool)_ARLIBSUFF)\ 771 $(SUFF_LIB)) 772 out := $(outbase)$(suff) 773 TARGET_$(target) := $(out) 774 $(target)_OBJS_ := $(filter %.o %.obj, \ 775 $($(target)_SOURCES) \ 776 $($(target)_SOURCES.$(bld_trg)) \ 777 $($(target)_SOURCES.$(bld_trg_arch)) \ 778 $($(target)_SOURCES.$(bld_trg_cpu)) \ 779 $($(target)_SOURCES.$(bld_type))) 780 781 782 # source -> object 783 $(eval $(value def_target_sources)) 784 785 # library linking 786 tool := $(call _TARGET_TOOL,$(target),AR) 787 outbase := $(call _TARGET_BASE,$(target),$(target)) 788 flags :=\ 789 $(TOOL_$(tool)_ARFLAGS)\ 790 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\ 791 $(ARFLAGS)\ 792 $(ARFLAGS.$(bld_type))\ 793 $($(target)_ARFLAGS)\ 794 $($(target)_ARFLAGS.$(bld_type)) 795 othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\ 796 $($(target)_SOURCES) \ 797 $($(target)_SOURCES.$(bld_trg)) \ 798 $($(target)_SOURCES.$(bld_trg_arch)) \ 799 $($(target)_SOURCES.$(bld_trg_cpu)) \ 800 $($(target)_SOURCES.$(bld_type))) 801 objs = $($(target)_OBJS_) 802 dirdep := $(call DIRDEP,$(dir $(out))) 803 ## @todo fix dependencies on makefiles an such 804 deps := $($(target)_DEPS) 805 806 lib := $(out) 807 libsuff := $(suff) 808 $(eval $(TOOL_$(tool)_LINK_LIBRARY)) 809 810 # installing and globals 811 definst := $(PATH_LIB) 812 typevar :=_LIBS 813 $(eval $(value def_target_install_pluss)) 814 endef 815 816 # Process libraries 817 $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib))) 818 819 820 # 821 # Link operations. 822 # 823 824 ## 825 # Link prolog 826 # 827 # @param $(target) Normalized target name. 828 # @param $(EXT) EXE,DLL,SYS. 829 # @param $(definst) The default _INST value. 830 # @param $(typevar) The name of the variable with all the root targets of its type. 831 define def_link_prolog 679 832 # basics 680 $(eval bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))) 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))) 684 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 685 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 686 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))) 687 $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(HOSTSUFF_EXE))) 688 $(eval exe := $(outbase)$(exesuff)) 689 $(eval TARGET_$(target) := $(exe)) 833 bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE)) 834 bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var))) 835 bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH)) 836 bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU)) 837 838 tool := $(call _TARGET_TOOL,$(target),LD) 839 outbase := $(call _TARGET_BASE,$(target),$(target)) 840 suff := $(firstword \ 841 $($(target)_$(EXT)SUFF) \ 842 $($(target)_$(EXT)SUFF) \ 843 $(TOOL_$(tool)_LD$(EXT)SUFF) \ 844 $($(EXTPRE)SUFF_$(EXT))) 845 out := $(outbase)$(suff) 846 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))) 847 TARGET_$(target) := $(out) 848 $(target)_OBJS_ := $(filter %.o %.obj, \ 849 $($(target)_SOURCES) \ 850 $($(target)_SOURCES.$(bld_trg)) \ 851 $($(target)_SOURCES.$(bld_trg_arch)) \ 852 $($(target)_SOURCES.$(bld_trg_cpu)) \ 853 $($(target)_SOURCES.$(bld_type))) 690 854 691 855 # source -> object 692 $(eval $( def_target_sources))856 $(eval $(value def_target_sources)) 693 857 694 858 # more library stuff. 695 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 696 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 697 $(eval objs = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 698 $(eval flags :=\ 859 tool := $(call _TARGET_TOOL,$(target),LD) 860 outbase := $(call _TARGET_BASE,$(target),$(target)) 861 flags :=\ 699 862 $(TOOL_$(tool)_LDFLAGS)\ 700 863 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\ … … 711 874 $($(target)_LDFLAGS.$(bld_trg))\ 712 875 $($(target)_LDFLAGS.$(bld_trg_arch))\ 713 $($(target)_LDFLAGS.$(bld_trg_cpu))\ 714 ) 715 $(eval libs :=\ 876 $($(target)_LDFLAGS.$(bld_trg_cpu)) 877 othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\ 878 $($(target)_SOURCES)\ 879 $($(target)_SOURCES.$(bld_trg)) \ 880 $($(target)_SOURCES.$(bld_trg_arch)) \ 881 $($(target)_SOURCES.$(bld_trg_cpu)) \ 882 $($(target)_SOURCES.$(bld_type))) 883 objs = $($(target)_OBJS_) 884 libs :=\ 716 885 $($(target)_LIBS.$(bld_trg_cpu))\ 717 886 $($(target)_LIBS.$(bld_trg_arch))\ … … 722 891 $($(target)_SDKS.$(bld_type)) \ 723 892 $($(target)_SDKS),\ 724 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\725 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\726 $(SDK_$(sdk)_LIBS.$(bld_trg))\727 $(SDK_$(sdk)_LIBS.$(bld_type))\728 $(SDK_$(sdk)_LIBS))\893 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ 894 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ 895 $(SDK_$(sdk)_LIBS.$(bld_trg))\ 896 $(SDK_$(sdk)_LIBS.$(bld_type))\ 897 $(SDK_$(sdk)_LIBS))\ 729 898 $(LIBS.$(bld_trg_cpu))\ 730 899 $(LIBS.$(bld_trg_arch))\ … … 735 904 $(SDKS.$(bld_type)) \ 736 905 $(SDKS),\ 737 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\738 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\739 $(SDK_$(sdk)_LIBS.$(bld_trg))\740 $(SDK_$(sdk)_LIBS.$(bld_type))\741 $(SDK_$(sdk)_LIBS))\906 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\ 907 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\ 908 $(SDK_$(sdk)_LIBS.$(bld_trg))\ 909 $(SDK_$(sdk)_LIBS.$(bld_type))\ 910 $(SDK_$(sdk)_LIBS))\ 742 911 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\ 743 912 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\ 744 913 $(TOOL_$(tool)_LIBS.$(bld_trg))\ 745 914 $(TOOL_$(tool)_LIBS.$(bld_type))\ 746 $(TOOL_$(tool)_LIBS)\ 747 ) 748 $(eval libpath :=\ 915 $(TOOL_$(tool)_LIBS) 916 libpath :=\ 749 917 $($(target)_LIBPATH.$(bld_trg_cpu))\ 750 918 $($(target)_LIBPATH.$(bld_trg_arch))\ … … 755 923 $($(target)_SDKS.$(bld_type)) \ 756 924 $($(target)_SDKS),\ 757 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\758 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\759 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\760 $(SDK_$(sdk)_LIBPATH.$(bld_type))\761 $(SDK_$(sdk)_LIBPATH))\925 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ 926 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ 927 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ 928 $(SDK_$(sdk)_LIBPATH.$(bld_type))\ 929 $(SDK_$(sdk)_LIBPATH))\ 762 930 $(LIBPATH.$(bld_trg_cpu))\ 763 931 $(LIBPATH.$(bld_trg_arch))\ … … 768 936 $(SDKS.$(bld_type)) \ 769 937 $(SDKS),\ 770 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\771 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\772 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\773 $(SDK_$(sdk)_LIBPATH.$(bld_type))\774 $(SDK_$(sdk)_LIBPATH))\938 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\ 939 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\ 940 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\ 941 $(SDK_$(sdk)_LIBPATH.$(bld_type))\ 942 $(SDK_$(sdk)_LIBPATH))\ 775 943 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\ 776 944 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\ 777 945 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\ 778 946 $(TOOL_$(tool)_LIBPATH.$(bld_type))\ 779 $(TOOL_$(tool)_LIBPATH)\ 780 ) 781 $(eval dirdep := $(dir $(exe)).dir_created) 947 $(TOOL_$(tool)_LIBPATH) 948 dirdep := $(call DIRDEP,$(dir $(out))) 782 949 ## @todo fix dependencies 783 $(eval deps := $($(target)_DEPS)) 784 # 785 $(eval custom_pre := $(strip $(firstword 950 deps := $($(target)_DEPS) 951 952 ## @todo this stuff can't be working. 953 custom_pre := $(strip $(firstword \ 786 954 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\ 787 955 $($(target)_CUSTOM_PRE.$(bld_trg))\ … … 792 960 $(CUSTOM_PRE.$(bld_type))\ 793 961 $(CUSTOM_PRE)\ 794 )) )795 $(eval custom_post := $(strip $(firstword 962 )) 963 custom_post := $(strip $(firstword \ 796 964 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\ 797 965 $($(target)_CUSTOM_POST.$(bld_trg))\ … … 802 970 $(CUSTOM_POST.$(bld_type))\ 803 971 $(CUSTOM_POST)\ 804 ))) 805 $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 806 972 )) 973 974 # installation targets 975 ifndef $(target)_NOINST 976 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \ 977 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/)) 978 ifdef KBUILD_DO_AUTO_INSTALL 979 $(typevar) += $(INSTARGET_$(target)) 980 else 981 $(typevar) += $(out) 982 endif 983 # generate the install rule 984 $(eval $(def_link_install_rule)) 985 986 else # NOINST 987 INSTARGET_$(target) := 988 $(typevar) += $(out) 989 endif # NOINST 990 991 endef 992 993 994 ## 995 # Typical link epilog. 996 # 997 # @param $(target) Normalized target name. 998 # @param $(out) The output file. 999 define def_link_epilog 1000 1001 _INSTALLS += $(INSTARGET_$(target)) 1002 _OBJS += $($(target)_OBJS_) 1003 _OUT_FILES += $(out) 1004 _CLEAN_FILES += $($(target)_CLEAN) 1005 1006 endef 1007 1008 1009 # 1010 # BLDPROGS 1011 # 1012 1013 ## Build program (one). 1014 # @param $(target) Normalized target (program) name. 1015 define def_bldprog 1016 1017 # set NOINST if not forced installation. 1018 ifndef $(target)_INST 1019 $(target)_NOINST := 1 1020 endif 1021 1022 # prolog 1023 $(eval $(value def_link_prolog)) 1024 1025 # body 807 1026 ifndef TOOL_$(tool)_LINK_PROGRAM 808 $$(warning kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) ) 809 $$(warning kBuild: tools: \ 1027 $(warning kBuild: tools: \ 810 1028 1 $($(target)_$(source)TOOL.$(bld_trg)) \ 811 1029 2 $($(target)_$(source)TOOL) \ … … 814 1032 5 $(TOOL.$(bld_trg)) \ 815 1033 6 $(TOOL) ) 816 endif 817 1034 $(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) ) 1035 endif 818 1036 $(eval $(TOOL_$(tool)_LINK_PROGRAM)) 819 1037 820 # installing 821 ifdef $(target)_INST 822 #ifndef KBUILD_NEW_STUFF 823 $(eval pubexe := $(PATH_BIN)/$(notdir $(exe))) 824 $(pubexe) : $(exe) $(dir $(pubexe)).dir_created 825 $(RM) -f $(pubexe) 826 $(CP) $(exe) $(pubexe) 827 #else 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) $$@ 833 #endif 834 835 _BLDPROGS += $(pubexe) 836 _OUT_FILES += $(exe) $(pubexe) 837 _DIRS += $(dir $(pubexe)) 838 else 839 _BLDPROGS += $(exe) 840 _OUT_FILES += $(exe) 841 endif 842 _OBJS += $(_OBJS_$(target)) 1038 # epilog 1039 $(eval $(value def_link_epilog)) 1040 843 1041 endef 844 1042 845 1043 # Process build programs. 846 $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(def_bldprog))) 847 848 849 850 # 851 # LIBRARIES 852 # 853 854 ## Library (one). 855 # @param $(target) Normalized library (target) name. 856 define def_lib 857 # library basics 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))) 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 867 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 868 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))) 869 $(eval libsuff := $(firstword\ 870 $($(target)_LIBSUFF.$(bld_trg))\ 871 $($(target)_LIBSUFF)\ 872 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\ 873 $(TOOL_$(tool)_ARLIBSUFF)\ 874 $(SUFF_LIB)\ 875 )) 876 $(eval lib := $(outbase)$(libsuff)) 877 $(eval TARGET_$(target) := $(lib)) 878 879 # source -> object 880 $(eval $(def_target_sources)) 881 882 # library linking 883 $(eval tool := $(call _TARGET_TOOL,$(target),AR)) 884 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 885 $(eval flags :=\ 886 $(TOOL_$(tool)_ARFLAGS)\ 887 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\ 888 $(ARFLAGS)\ 889 $(ARFLAGS.$(bld_type))\ 890 $($(target)_ARFLAGS)\ 891 $($(target)_ARFLAGS.$(bld_type))\ 892 ) 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)))) 895 $(eval dirdep := $(dir $(lib)).dir_created) 896 ## @todo fix dependencies on makefiles an such 897 $(eval deps := $($(target)_DEPS)) 898 899 $(eval $(TOOL_$(tool)_LINK_LIBRARY)) 900 901 # installing 902 ifndef $(target)_NOINST 903 # ifndef KBUILD_NEW_STUFF 904 $(eval publib := $(PATH_LIB)/$(notdir $(lib))) 905 $(publib) : $(lib) $(dir $(publib)).dir_created 906 $(RM) -f $(publib) 907 $(CP) $(lib) $(publib) 908 #else 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) $$@ 914 #endif 915 916 _LIBS += $(publib) 917 _OUT_FILES += $(lib) $(publib) 918 _DIRS += $(dir $(publib)) 919 else 920 _LIBS += $(lib) 921 _OUT_FILES += $(lib) 922 endif 923 _OBJS += $(_OBJS_$(target)) 924 endef 925 926 # Process libraries 927 $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib))) 1044 EXT := EXE 1045 EXTPRE := HOST 1046 definst := $(PATH_BIN) 1047 typevar := _BLDPROGS 1048 bld_trg_base_var := PLATFORM 1049 $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog))) 928 1050 929 1051 … … 936 1058 # @param $(target) Normalized target (program) name. 937 1059 define def_dll 938 # dllmod basics 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))) 943 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 944 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 945 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))) 946 $(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL))) 947 $(eval dll := $(outbase)$(dllsuff)) 948 $(eval TARGET_$(target) := $(dll)) 949 950 # source -> object 951 $(eval $(def_target_sources)) 952 953 # dllmod linking. 954 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 955 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 956 $(eval objs = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 957 958 $(eval flags :=\ 959 $(TOOL_$(tool)_LDFLAGS)\ 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))\ 964 $(LDFLAGS)\ 965 $(LDFLAGS.$(bld_type))\ 966 $(LDFLAGS.$(bld_trg))\ 967 $(LDFLAGS.$(bld_trg_arch))\ 968 $(LDFLAGS.$(bld_trg_cpu))\ 969 $($(target)_LDFLAGS)\ 970 $($(target)_LDFLAGS.$(bld_type))\ 971 $($(target)_LDFLAGS.$(bld_trg))\ 972 $($(target)_LDFLAGS.$(bld_trg_arch))\ 973 $($(target)_LDFLAGS.$(bld_trg_cpu))\ 974 ) 975 $(eval libs :=\ 976 $($(target)_LIBS.$(bld_trg_cpu))\ 977 $($(target)_LIBS.$(bld_trg_arch))\ 978 $($(target)_LIBS.$(bld_trg))\ 979 $($(target)_LIBS.$(bld_type))\ 980 $($(target)_LIBS)\ 981 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 982 $($(target)_SDKS.$(bld_type)) \ 983 $($(target)_SDKS),\ 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))\ 988 $(SDK_$(sdk)_LIBS))\ 989 $(LIBS.$(bld_trg_cpu))\ 990 $(LIBS.$(bld_trg_arch))\ 991 $(LIBS.$(bld_trg))\ 992 $(LIBS.$(bld_type))\ 993 $(LIBS)\ 994 $(foreach sdk, $(SDKS.$(bld_trg)) \ 995 $(SDKS.$(bld_type)) \ 996 $(SDKS),\ 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))\ 1001 $(SDK_$(sdk)_LIBS))\ 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))\ 1006 $(TOOL_$(tool)_LIBS)\ 1007 ) 1008 $(eval libpath :=\ 1009 $($(target)_LIBPATH.$(bld_trg_cpu))\ 1010 $($(target)_LIBPATH.$(bld_trg_arch))\ 1011 $($(target)_LIBPATH.$(bld_trg))\ 1012 $($(target)_LIBPATH.$(bld_type))\ 1013 $($(target)_LIBPATH)\ 1014 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 1015 $($(target)_SDKS.$(bld_type)) \ 1016 $($(target)_SDKS),\ 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))\ 1021 $(SDK_$(sdk)_LIBPATH))\ 1022 $(LIBPATH.$(bld_trg_cpu))\ 1023 $(LIBPATH.$(bld_trg_arch))\ 1024 $(LIBPATH.$(bld_trg))\ 1025 $(LIBPATH.$(bld_type))\ 1026 $(LIBPATH)\ 1027 $(foreach sdk, $(SDKS.$(bld_trg)) \ 1028 $(SDKS.$(bld_type)) \ 1029 $(SDKS),\ 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))\ 1034 $(SDK_$(sdk)_LIBPATH))\ 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))\ 1039 $(TOOL_$(tool)_LIBPATH)\ 1040 ) 1041 $(eval dirdep := $(dir $(dll)).dir_created) 1042 ## @todo fix dependencies 1043 $(eval deps := $($(target)_DEPS)) 1044 # 1045 $(eval custom_pre := $(strip $(firstword 1046 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1047 $($(target)_CUSTOM_PRE.$(bld_trg))\ 1048 $($(target)_CUSTOM_PRE.$(bld_type))\ 1049 $($(target)_CUSTOM_PRE)\ 1050 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1051 $(CUSTOM_PRE.$(bld_trg))\ 1052 $(CUSTOM_PRE.$(bld_type))\ 1053 $(CUSTOM_PRE)\ 1054 ))) 1055 $(eval custom_post := $(strip $(firstword 1056 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\ 1057 $($(target)_CUSTOM_POST.$(bld_trg))\ 1058 $($(target)_CUSTOM_POST.$(bld_type))\ 1059 $($(target)_CUSTOM_POST)\ 1060 $(CUSTOM_POST.$(bld_trg).$(bld_type))\ 1061 $(CUSTOM_POST.$(bld_trg))\ 1062 $(CUSTOM_POST.$(bld_type))\ 1063 $(CUSTOM_POST)\ 1064 ))) 1065 $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 1066 1060 1061 # prolog 1062 $(eval $(value def_link_prolog)) 1063 1064 # body 1067 1065 ifndef TOOL_$(tool)_LINK_DLL 1068 $$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) ) 1069 $$(warning kBuild: tools: \ 1066 $(warning kBuild: tools: \ 1070 1067 1 $($(target)_$(source)TOOL.$(bld_trg)) \ 1071 1068 2 $($(target)_$(source)TOOL) \ … … 1076 1073 7 $(TOOL.$(bld_trg)) \ 1077 1074 8 $(TOOL) ) 1078 endif 1079 1075 $(error kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) ) 1076 endif 1080 1077 $(eval $(TOOL_$(tool)_LINK_DLL)) 1081 1078 1082 1083 # installing 1084 ifndef $(target)_NOINST 1085 #ifndef KBUILD_NEW_STUFF 1086 $(eval pubdll := $(PATH_BIN)/$(notdir $(dll))) 1087 $(pubdll) : $(dll) $(dir $(pubdll)).dir_created 1088 $(RM) -f $(pubdll) 1089 $(CP) $(dll) $(pubdll) 1090 #else 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))) 1094 # $(RM) -f $$@ 1095 # $(CP) $(dll) $$@ 1096 #endif 1097 1098 $(eval TARGET_PUB_$(target) := $(pubdll)) 1099 _DLLS += $(pubdll) 1100 _OUT_FILES += $(dll) $(pubdll) 1101 _DIRS += $(dir $(pubdll)) 1102 else 1103 _DLLS += $(dll) 1104 _OUT_FILES += $(dll) 1105 endif 1106 _OBJS += $(_OBJS_$(target)) 1079 # epilog 1080 $(eval $(value def_link_epilog)) 1081 1107 1082 endef 1108 1083 1109 1084 # Process dlls 1110 $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll))) 1085 EXT := DLL 1086 EXTPRE := 1087 definst := $(PATH_DLL) 1088 typevar := _DLLS 1089 bld_trg_base_var := TARGET 1090 $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_dll))) 1111 1091 1112 1092 … … 1118 1098 # - On other platforms they are fake DLLs. 1119 1099 ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2) 1120 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $( def_lib)))1100 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib))) 1121 1101 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)))))1125 1102 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_dll))) 1103 endif 1104 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \ 1105 $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target))))) 1126 1106 1127 1107 … … 1133 1113 # @param $(target) Normalized target (program) name. 1134 1114 define def_program 1135 # basics 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))) 1140 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 1141 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 1142 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))) 1143 $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE))) 1144 $(eval exe := $(outbase)$(exesuff)) 1145 $(eval TARGET_$(target) := $(exe)) 1146 1147 # source -> object 1148 $(eval $(def_target_sources)) 1149 1150 # more library stuff. 1151 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 1152 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 1153 $(eval objs = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 1154 1155 $(eval flags :=\ 1156 $(TOOL_$(tool)_LDFLAGS)\ 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))\ 1161 $(LDFLAGS)\ 1162 $(LDFLAGS.$(bld_type))\ 1163 $(LDFLAGS.$(bld_trg))\ 1164 $(LDFLAGS.$(bld_trg_arch))\ 1165 $(LDFLAGS.$(bld_trg_cpu))\ 1166 $($(target)_LDFLAGS)\ 1167 $($(target)_LDFLAGS.$(bld_type))\ 1168 $($(target)_LDFLAGS.$(bld_trg))\ 1169 $($(target)_LDFLAGS.$(bld_trg_arch))\ 1170 $($(target)_LDFLAGS.$(bld_trg_cpu))\ 1171 ) 1172 $(eval libs :=\ 1173 $($(target)_LIBS.$(bld_trg_cpu))\ 1174 $($(target)_LIBS.$(bld_trg_arch))\ 1175 $($(target)_LIBS.$(bld_trg))\ 1176 $($(target)_LIBS.$(bld_type))\ 1177 $($(target)_LIBS)\ 1178 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 1179 $($(target)_SDKS.$(bld_type)) \ 1180 $($(target)_SDKS),\ 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))\ 1185 $(SDK_$(sdk)_LIBS))\ 1186 $(LIBS.$(bld_trg_cpu))\ 1187 $(LIBS.$(bld_trg_arch))\ 1188 $(LIBS.$(bld_trg))\ 1189 $(LIBS.$(bld_type))\ 1190 $(LIBS)\ 1191 $(foreach sdk, $(SDKS.$(bld_trg)) \ 1192 $(SDKS.$(bld_type)) \ 1193 $(SDKS),\ 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))\ 1198 $(SDK_$(sdk)_LIBS))\ 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))\ 1203 $(TOOL_$(tool)_LIBS)\ 1204 ) 1205 $(eval libpath :=\ 1206 $($(target)_LIBPATH.$(bld_trg_cpu))\ 1207 $($(target)_LIBPATH.$(bld_trg_arch))\ 1208 $($(target)_LIBPATH.$(bld_trg))\ 1209 $($(target)_LIBPATH.$(bld_type))\ 1210 $($(target)_LIBPATH)\ 1211 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 1212 $($(target)_SDKS.$(bld_type)) \ 1213 $($(target)_SDKS),\ 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))\ 1218 $(SDK_$(sdk)_LIBPATH))\ 1219 $(LIBPATH.$(bld_trg_cpu))\ 1220 $(LIBPATH.$(bld_trg_arch))\ 1221 $(LIBPATH.$(bld_trg))\ 1222 $(LIBPATH.$(bld_type))\ 1223 $(LIBPATH)\ 1224 $(foreach sdk, $(SDKS.$(bld_trg)) \ 1225 $(SDKS.$(bld_type)) \ 1226 $(SDKS),\ 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))\ 1231 $(SDK_$(sdk)_LIBPATH))\ 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))\ 1236 $(TOOL_$(tool)_LIBPATH)\ 1237 ) 1238 $(eval dirdep := $(dir $(exe)).dir_created) 1239 ## @todo fix dependencies 1240 $(eval deps := $($(target)_DEPS)) 1241 # 1242 $(eval custom_pre := $(strip $(firstword 1243 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1244 $($(target)_CUSTOM_PRE.$(bld_trg))\ 1245 $($(target)_CUSTOM_PRE.$(bld_type))\ 1246 $($(target)_CUSTOM_PRE)\ 1247 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1248 $(CUSTOM_PRE.$(bld_trg))\ 1249 $(CUSTOM_PRE.$(bld_type))\ 1250 $(CUSTOM_PRE)\ 1251 ))) 1252 $(eval custom_post := $(strip $(firstword 1253 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\ 1254 $($(target)_CUSTOM_POST.$(bld_trg))\ 1255 $($(target)_CUSTOM_POST.$(bld_type))\ 1256 $($(target)_CUSTOM_POST)\ 1257 $(CUSTOM_POST.$(bld_trg).$(bld_type))\ 1258 $(CUSTOM_POST.$(bld_trg))\ 1259 $(CUSTOM_POST.$(bld_type))\ 1260 $(CUSTOM_POST)\ 1261 ))) 1262 $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 1263 1264 $(eval $(TOOL_$(tool)_LINK_PROGRAM)) 1265 1266 # installing 1267 ifndef $(target)_NOINST 1268 #ifndef KBUILD_NEW_STUFF 1269 $(eval pubexe := $(PATH_BIN)/$(notdir $(exe))) 1270 $(pubexe) : $(exe) $(dir $(pubexe)).dir_created 1271 $(RM) -f $(pubexe) 1272 $(CP) $(exe) $(pubexe) 1273 #else 1274 #$ (eval pubexe := $(patsubst %/,%/$(notdir $(exe)), \ 1275 # $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_BIN)/))) 1276 #$ (pubexe) : $(exe) $(addsuffix .dir_created, $(dir $(pubexe))) 1277 # $(RM) -f $$@ 1278 # $(CP) $(exe) $$@ 1279 #endif 1280 1281 _PROGRAMS += $(pubexe) 1282 _OUT_FILES += $(exe) $(pubexe) 1283 _DIRS += $(dir $(pubexe)) 1284 else 1285 _PROGRAMS += $(exe) 1286 _OUT_FILES += $(exe) 1287 endif 1288 _OBJS += $(_OBJS_$(target)) 1289 endef 1290 1291 # Process libraries 1292 $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program))) 1293 1294 1295 1296 # 1297 # SYSMODS 1298 # 1299 1300 ## System module (one). 1301 # @param $(target) Normalized target (program) name. 1302 define def_sysmod 1303 # sysmod basics 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))) 1308 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 1309 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 1310 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))) 1311 $(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS))) 1312 $(eval sys := $(outbase)$(syssuff)) 1313 $(eval TARGET_$(target) := $(sys)) 1314 1315 # source -> object 1316 $(eval $(def_target_sources)) 1317 1318 # sysmod linking 1319 $(eval tool := $(call _TARGET_TOOL,$(target),LD)) 1320 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 1321 $(eval objs = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 1322 1323 $(eval flags :=\ 1324 $(TOOL_$(tool)_LDFLAGS)\ 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))\ 1329 $(LDFLAGS)\ 1330 $(LDFLAGS.$(bld_type))\ 1331 $(LDFLAGS.$(bld_trg))\ 1332 $(LDFLAGS.$(bld_trg_arch))\ 1333 $(LDFLAGS.$(bld_trg_cpu))\ 1334 $($(target)_LDFLAGS)\ 1335 $($(target)_LDFLAGS.$(bld_type))\ 1336 $($(target)_LDFLAGS.$(bld_trg))\ 1337 $($(target)_LDFLAGS.$(bld_trg_arch))\ 1338 $($(target)_LDFLAGS.$(bld_trg_cpu))\ 1339 ) 1340 $(eval libs :=\ 1341 $($(target)_LIBS.$(bld_trg_cpu))\ 1342 $($(target)_LIBS.$(bld_trg_arch))\ 1343 $($(target)_LIBS.$(bld_trg))\ 1344 $($(target)_LIBS.$(bld_type))\ 1345 $($(target)_LIBS)\ 1346 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 1347 $($(target)_SDKS.$(bld_type)) \ 1348 $($(target)_SDKS),\ 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))\ 1353 $(SDK_$(sdk)_LIBS))\ 1354 $(LIBS.$(bld_trg_cpu))\ 1355 $(LIBS.$(bld_trg_arch))\ 1356 $(LIBS.$(bld_trg))\ 1357 $(LIBS.$(bld_type))\ 1358 $(LIBS)\ 1359 $(foreach sdk, $(SDKS.$(bld_trg)) \ 1360 $(SDKS.$(bld_type)) \ 1361 $(SDKS),\ 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))\ 1366 $(SDK_$(sdk)_LIBS))\ 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))\ 1371 $(TOOL_$(tool)_LIBS)\ 1372 ) 1373 $(eval libpath :=\ 1374 $($(target)_LIBPATH.$(bld_trg_cpu))\ 1375 $($(target)_LIBPATH.$(bld_trg_arch))\ 1376 $($(target)_LIBPATH.$(bld_trg))\ 1377 $($(target)_LIBPATH.$(bld_type))\ 1378 $($(target)_LIBPATH)\ 1379 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \ 1380 $($(target)_SDKS.$(bld_type)) \ 1381 $($(target)_SDKS),\ 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))\ 1386 $(SDK_$(sdk)_LIBPATH))\ 1387 $(LIBPATH.$(bld_trg_cpu))\ 1388 $(LIBPATH.$(bld_trg_arch))\ 1389 $(LIBPATH.$(bld_trg))\ 1390 $(LIBPATH.$(bld_type))\ 1391 $(LIBPATH)\ 1392 $(foreach sdk, $(SDKS.$(bld_trg)) \ 1393 $(SDKS.$(bld_type)) \ 1394 $(SDKS),\ 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))\ 1399 $(SDK_$(sdk)_LIBPATH))\ 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))\ 1404 $(TOOL_$(tool)_LIBPATH)\ 1405 ) 1406 $(eval dirdep := $(dir $(sys)).dir_created) 1407 ## @todo fix dependencies 1408 $(eval deps := $($(target)_DEPS)) 1409 # 1410 $(eval custom_pre := $(strip $(firstword 1411 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1412 $($(target)_CUSTOM_PRE.$(bld_trg))\ 1413 $($(target)_CUSTOM_PRE.$(bld_type))\ 1414 $($(target)_CUSTOM_PRE)\ 1415 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\ 1416 $(CUSTOM_PRE.$(bld_trg))\ 1417 $(CUSTOM_PRE.$(bld_type))\ 1418 $(CUSTOM_PRE)\ 1419 ))) 1420 $(eval custom_post := $(strip $(firstword 1421 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\ 1422 $($(target)_CUSTOM_POST.$(bld_trg))\ 1423 $($(target)_CUSTOM_POST.$(bld_type))\ 1424 $($(target)_CUSTOM_POST)\ 1425 $(CUSTOM_POST.$(bld_trg).$(bld_type))\ 1426 $(CUSTOM_POST.$(bld_trg))\ 1427 $(CUSTOM_POST.$(bld_type))\ 1428 $(CUSTOM_POST)\ 1429 ))) 1430 $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))) 1431 1432 ifndef TOOL_$(tool)_LINK_SYSMOD 1433 $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) ) 1434 $$(warning kBuild: tools: \ 1115 1116 # prolog 1117 $(eval $(value def_link_prolog)) 1118 1119 # body 1120 ifndef TOOL_$(tool)_LINK_PROGRAM 1121 $(warning kBuild: tools: \ 1435 1122 1 $($(target)_$(source)TOOL.$(bld_trg)) \ 1436 1123 2 $($(target)_$(source)TOOL) \ … … 1441 1128 7 $(TOOL.$(bld_trg)) \ 1442 1129 8 $(TOOL) ) 1443 endif 1444 1130 $(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) ) 1131 endif 1132 $(eval $(TOOL_$(tool)_LINK_PROGRAM)) 1133 1134 # epilog 1135 $(eval $(value def_link_epilog)) 1136 1137 endef 1138 1139 # Process programs 1140 EXT := EXE 1141 EXTPRE := 1142 definst := $(PATH_BIN) 1143 typevar := _PROGRAMS 1144 bld_trg_base_var := TARGET 1145 $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_program))) 1146 1147 1148 1149 # 1150 # SYSMODS 1151 # 1152 1153 ## System module (one). 1154 # @param $(target) Normalized target (program) name. 1155 define def_sysmod 1156 1157 # prolog 1158 $(eval $(value def_link_prolog)) 1159 1160 # body 1161 ifndef TOOL_$(tool)_LINK_SYSMOD 1162 $(warning kBuild: tools: \ 1163 1 $($(target)_$(source)TOOL.$(bld_trg)) \ 1164 2 $($(target)_$(source)TOOL) \ 1165 3 $($(target)_TOOL.$(bld_trg)) \ 1166 4 $($(target)_TOOL) \ 1167 5 $($(source)TOOL) \ 1168 6 $($(source)TOOL.$(bld_trg)) \ 1169 7 $(TOOL.$(bld_trg)) \ 1170 8 $(TOOL) ) 1171 $(error kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) ) 1172 endif 1445 1173 $(eval $(TOOL_$(tool)_LINK_SYSMOD)) 1446 1174 1447 # installing 1448 ifndef $(target)_NOINST 1449 #ifndef KBUILD_NEW_STUFF 1450 $(eval pubsys := $(PATH_BIN)/$(notdir $(sys))) 1451 $(pubsys): $(sys) $(dir $(pubsys)).dir_created 1452 $(RM) -f $(pubsys) 1453 $(CP) $(sys) $(pubsys) 1454 #else 1455 #$ (eval pubsys := $(patsubst %/,%/$(notdir $(sys)), \ 1456 # $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_SYS)/))) 1457 #$ (pubsys) : $(sys) $(addsuffix .dir_created, $(dir $(pubsys))) 1458 # $(RM) -f $$@ 1459 # $(CP) $(sys) $$@ 1460 #endif 1461 1462 $(eval _SYSMODS += $(pubsys)) 1463 $(eval _OUT_FILES += $(sys) $(pubsys)) 1464 _DIRS += $(dir $(pubsys)) 1175 # epilog 1176 $(eval $(value def_link_epilog)) 1177 1178 endef 1179 1180 # Process sysmods 1181 EXT := SYS 1182 EXTPRE := 1183 definst := $(PATH_SYS) 1184 typevar := _SYSMODS 1185 bld_trg_base_var := TARGET 1186 $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_sysmod))) 1187 1188 1189 # 1190 # OTHERS 1191 # 1192 _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) 1193 1194 1195 # 1196 # INSTALLS 1197 # 1198 1199 ## generate the install rule 1200 define def_install_src_rule 1201 # the install rule 1202 $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst))) 1203 $$(RM) -f $$@ 1204 $(inscmd) 1205 endef 1206 1207 ## install one file 1208 define def_install_src 1209 1210 # deal with '=>' in the source file name. 1211 srcdst := $(subst =>, ,$(src)) 1212 srcsrc := $(firstword $(srcdst)) 1213 srcdst := $(word $(words $(srcdst)),$(srcdst)) 1214 1215 # _INSTFUN 1216 ifdef $(srcsrc)_INSTFUN 1217 instfun := $(srcsrc)_INSTFUN 1465 1218 else 1466 $(eval _SYSMODS += $(sys)) 1467 $(eval _OUT_FILES += $(sys)) 1468 endif 1469 _OBJS += $(_OBJS_$(target)) 1470 endef 1471 1472 # Process sysmods 1473 $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod))) 1474 1475 1476 1477 # 1478 # OTHERS 1479 # 1480 _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) 1481 1219 ifdef $(target)_INSTFUN 1220 instfun := $(target)_INSTFUN 1221 else 1222 instfun := _INSTALL_FILE 1223 endif 1224 endif 1225 1226 # _INST 1227 ifdef $(srcsrc)_INST 1228 inst = $(srcsrc)_INST 1229 else 1230 ifdef $(target)_INST 1231 inst = $(target)_INST 1232 else 1233 inst = 1234 endif 1235 endif 1236 1237 # calc target 1238 insdst := $(call $(instfun),$(srcdst),$(target),$($(inst)),$(PATH_INS)) 1239 #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) srcdst=$(srcsrc) inst=$(inst) => insdst=$(insdst)) 1240 1241 # create the command 1242 ifdef $(srcsrc)_INSTALLER 1243 inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target)) 1244 else 1245 ifdef $(target)_INSTALLER 1246 inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target)) 1247 else 1248 inscmd := $$(CP) $(srcsrc) $(insdst) 1249 endif 1250 endif 1251 1252 # generate the rule (need double evaluation here) 1253 $(eval $(def_install_src_rule)) 1254 1255 INSTARGET_$(target) += $(insdst) 1256 endef 1257 1258 1259 ## generate the symlink rule 1260 define def_install_symlink_rule 1261 # the install rule 1262 $(insdst) : | $(call DIRDEP,$(dir $(insdst))) 1263 $$(RM) -f $$@ 1264 $$(LN_SYMLINK) $(srcsrc) $(insdst) 1265 endef 1266 1267 ## create one symlink 1268 define def_install_symlink 1269 1270 # deal with '=>' in the source file name. 1271 srcdst := $(subst =>, ,$(src)) 1272 srcsrc := $(firstword $(srcdst)) 1273 srcdst := $(word $(words $(srcdst)),$(srcdst)) 1274 1275 # _INSTFUN 1276 ifdef $(srcsrc)_INSTFUN 1277 instfun := $(srcsrc)_INSTFUN 1278 else 1279 ifdef $(target)_INSTFUN 1280 instfun := $(target)_INSTFUN 1281 else 1282 instfun := _INSTALL_FILE 1283 endif 1284 endif 1285 1286 # _INST 1287 ifdef $(srcsrc)_INST 1288 inst = $(srcsrc)_INST 1289 else 1290 ifdef $(target)_INST 1291 inst = $(target)_INST 1292 else 1293 inst = 1294 endif 1295 endif 1296 1297 # calc target 1298 insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS)) 1299 #$(warning srcsrc=$(srcsrc) srcdst=$(srcdst) insdst=$(insdst)) 1300 1301 # generate the rule (need double evaluation here) 1302 $(eval $(def_install_symlink_rule)) 1303 1304 INSTARGET_$(target) += $(insdst) 1305 endef 1306 1307 ## process one install target. 1308 define def_install 1309 bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE)) 1310 bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET)) 1311 bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)) 1312 bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU)) 1313 1314 INSTARGET_$(target) := 1315 $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \ 1316 $(eval $(value def_install_src))) 1317 1318 $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \ 1319 $(eval $(value def_install_symlink))) 1320 1321 _INSTALLS += $(INSTARGET_$(target)) 1322 endef 1323 1324 ## process all install targets 1325 $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \ 1326 $(eval $(value def_install))) 1482 1327 1483 1328 … … 1488 1333 1489 1334 # 1490 # Directories. 1491 # 1492 _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS))))) 1493 1494 define def_createdir 1495 $(dirfile): 1496 $(call MSG_L1,Creating directory $$(@D)) 1497 $(MKDIR) -p $$(@D) 1498 @echo dir_created > $$@ 1499 endef 1500 1501 $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir))) 1502 1503 1504 # 1505 # Include dependency files. 1506 # 1507 $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep))) 1335 # PACKING 1336 # 1337 packing:: 1338 1339 1340 # 1341 # DIRECTORIES 1342 # 1343 _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS))) 1344 1345 define def_mkdir_rule 1346 $(directory): 1347 $(call MSG_L1,Creating directory $$@) 1348 $(MKDIR) -p $$@ 1349 endef 1350 1351 $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule))) 1352 1353 1354 # 1355 # NOTHING 1356 # 1357 do-nothing: 1358 $(call MSG_L1,Did nothing in $(CURDIR)) 1359 1360 1361 # 1362 # CLEAN UP 1363 # 1364 do-clean: 1365 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_CLEAN_FILES) $(OTHER_CLEAN) 1508 1366 1509 1367 … … 1511 1369 # PASSES (including directory and makefile walking) 1512 1370 # 1513 # Do all the default passes if it's unspecified.1514 1515 #PASSES ?= bldprogs libraries binaries others publish1516 PASSES ?= bldprogs libraries dlls binaries others1517 1518 ## @todo figure out a generic way of configuring how pass works!1519 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 makefile1523 1371 1524 1372 ## Subdir … … 1542 1390 endef 1543 1391 1544 1545 1392 ## Execute a pass. 1546 1393 # @param $(pass) Lowercase pass name. 1547 1394 # @param $(PASS) Uppercase pass name. 1395 define def_pass_old 1396 $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET))) 1397 $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET))) 1398 $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET))) 1399 $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET))) 1400 1401 $(eval tag:=_before) 1402 $(eval dep:=) 1403 $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir))) 1404 $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile))) 1405 1406 $(eval tag:=_after) 1407 $(eval dep:=pass_$(pass)_doit) 1408 $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir))) 1409 $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile))) 1410 1411 .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after 1412 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after 1413 pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var)) 1414 pass_$(pass)_this: pass_$(pass)_before 1415 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit 1416 pass_$(pass)_after:: pass_$(pass)_this 1417 pass_$(pass): pass_$(pass)_after 1418 1419 endef 1420 1548 1421 define def_pass 1549 1422 $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET))) … … 1562 1435 $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile))) 1563 1436 1564 .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after 1565 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after 1437 ifdef KBUILD_SAFE_PARALLELL 1438 .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this 1439 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit 1440 pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var)) 1566 1441 pass_$(pass)_this: pass_$(pass)_before 1567 1442 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit 1568 1443 pass_$(pass)_after:: pass_$(pass)_this 1569 1444 pass_$(pass): pass_$(pass)_after 1570 1571 endef 1572 1573 1574 ## PASS: bldprogs 1575 # This pass builds targets which are required for building the rest. 1576 pass_bldprogs_doit: $(_BLDPROGS) 1577 pass := bldprogs 1578 PASS := BLDPROGS 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 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. 1597 pass_binaries_doit: $(_PROGRAMS) $(_SYSMODS) $(_OTHER_BINARIES) 1598 pass := binaries 1599 PASS := BINARIES 1600 $(eval $(def_pass)) 1601 1602 ## PASS: others 1603 # This pass builds other targets. 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 1615 # $(sort).. not nice. 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))) 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: 1633 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN) 1634 pass := clean 1635 PASS := CLEAN 1636 $(eval $(def_pass)) 1637 clean: pass_clean 1638 1639 ## PASS: nothing 1640 # This pass just walks the tree. 1641 pass_nothing_doit: 1642 $(call MSG_L1,Did nothing in $(CURDIR)) 1643 pass := nothing 1644 PASS := NOTHING 1645 $(eval $(def_pass)) 1646 nothing: pass_nothing 1647 1445 else 1446 .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after 1447 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit 1448 pass_$(pass)_doit: pass_$(pass)_before \ 1449 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))) 1450 pass_$(pass): \ 1451 pass_$(pass)_before \ 1452 pass_$(pass)_doit \ 1453 pass_$(pass)_after 1454 endif 1455 1456 #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))) 1457 endef 1458 1459 # Generate the defined passes. 1460 $(foreach PASS, $(PASSES), \ 1461 $(eval pass := $(PASS_$(PASS)_pass)) \ 1462 $(eval $(def_pass))) 1648 1463 1649 1464 ## Pass order … … 1651 1466 # @param $(prev_pass) The previous pass name. 1652 1467 define def_pass_order 1468 ifdef KBUILD_SAFE_PARALLELL 1469 .NOTPARALLEL: pass_$(pass)_order 1470 .PHONY: pass_$(pass)_order 1653 1471 pass_$(pass)_order: $(pass_prev) 1654 $(call MSG_L1,Pass $(pass))1472 $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass))) 1655 1473 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass) 1656 .NOTPARALLEL: pass_$(pass)_order 1474 else 1475 .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner 1476 .PHONY: pass_$(pass)_order pass_$(pass)_banner 1477 pass_$(pass)_banner: 1478 $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass))) 1479 pass_$(pass)_order: \ 1480 $(pass_prev) \ 1481 pass_$(pass)_banner \ 1482 pass_$(pass) 1483 endif 1657 1484 $(eval pass_prev := pass_$(pass)_order) 1658 1485 endef … … 1661 1488 # Use dependencies to ensure correct pass order. 1662 1489 pass_prev := 1663 $(foreach pass,$(PASSES),$(eval $(def_pass_order))) 1490 $(foreach PASS,$(DEFAULT_PASSES),\ 1491 $(eval pass := $(PASS_$(PASS)_pass)) \ 1492 $(eval $(def_pass_order))) 1664 1493 1665 1494 … … 1672 1501 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive 1673 1502 1503 uninstall: 1504 $(RM) -f $(_INSTALLS) 1674 1505 1675 1506 # misc shortcuts. 1676 target : bldprogs libraries binaries others1507 targets: bldprogs libraries dlls programs sysmods others install 1677 1508 objects: $(_OBJS) 1678 1509 bldprogs: $(_BLDPROGS) … … 1681 1512 programs: $(_PROGRAMS) 1682 1513 sysmods: $(_SYSMODS) 1514 others: $(_OTHERS) 1515 install: $(_INSTALLS) 1516 1517 1518 # 1519 # kBuild debugging stuff. 1520 # 1521 _SPACE := $(subst ., ,.) 1522 _TAB := $(subst ., ,.) 1523 define _NEWLINE 1524 1525 1526 endef 1527 NLTAB = $(_NEWLINE)$(TAB) 1528 show_targets: 1529 @$(foreach target, $(ALL_TARGETS),\ 1530 @$(ECHO) "target: $(target)" $(NLTAB)\ 1531 @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\ 1532 @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\ 1533 @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\ 1534 $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_, \ 1535 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \ 1536 $(if $($(target)_$(prop).$(_tmp)),\ 1537 @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \ 1538 $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \ 1539 )\ 1540 $(foreach prop,$(PROPS_DEFERRED), \ 1541 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \ 1542 $(if $(value $(target)_$(prop).$(_tmp)),\ 1543 @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \ 1544 $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \ 1545 )) 1546 1547 1548 1549 # 1550 # Include dependency files. 1551 # 1552 $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep))) 1683 1553 1684 1554
Note:
See TracChangeset
for help on using the changeset viewer.