Changeset 2523 for trunk/kBuild/footer-pass2-compiling-targets.kmk
- Timestamp:
- Aug 1, 2011, 1:45:20 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer-pass2-compiling-targets.kmk
r2521 r2523 137 137 $(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE) 138 138 endif 139 $(out) + $($(target)_2_OUTPUT) +| $($(target)_2_OUTPUT_MAYBE) : \ 139 $(out) \ 140 + $($(target)_2_OUTPUT) \ 141 + $($(target)_2_OUTPUT_DEBUG_FILES) \ 142 + $($(target)_2_OUTPUT_DEBUG_DIRS) \ 143 +| $($(target)_2_OUTPUT_MAYBE) : \ 140 144 $$$$($(target)_2_DEPEND) \ 141 145 $(value _DEP_LINK_CMDS) \ … … 143 147 $$$$($(target)_2_DEPORD) 144 148 %$$(call MSG_LINK,$(target),$$@,$(tool_do)) 145 $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) 149 $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $($(target)_2_OUTPUT_DEBUG_FILES) 150 ifdef $(target)_2_OUTPUT_DEBUG_DIRS 151 $$(QUIET)$$(RM) -Rf -- $($(target)_2_OUTPUT_DEBUG_DIRS) 152 endif 146 153 147 154 $(cmds) … … 281 288 # 282 289 # @param 1 The property name. 290 # @param 2 The default property name, empty if none. 291 # @param 3 What to return if all variables are empty. (optional) 283 292 # @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type. 284 293 # @returns Expanded property value. 285 294 # 286 ## @todo bld_trg_cpu is missing here.287 295 define def_fn_prop_get_first_defined 288 ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) 289 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) 290 else ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch) 291 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch)) 292 else ifdef $(target)_$(1).$(bld_trg).$(bld_type) 293 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_type)) 294 else ifdef $(target)_$(1).$(bld_trg_arch) 295 local .RETURN := $($(target)_$(1).$(bld_trg_arch)) 296 else ifdef $(target)_$(1).$(bld_trg) 297 local .RETURN := $($(target)_$(1).$(bld_trg)) 298 else ifdef $(target)_$(1).$(bld_type) 299 local .RETURN := $($(target)_$(1).$(bld_type)) 300 else ifdef $(target)_$(1) 301 local .RETURN := $($(target)_$(1)) 302 else ifdef $(1).$(bld_trg).$(bld_trg_arch).$(bld_type) 303 local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) 304 else ifdef $(1).$(bld_trg).$(bld_trg_arch) 305 local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch)) 306 else ifdef $(1).$(bld_trg).$(bld_type) 307 local .RETURN := $($(1).$(bld_trg).$(bld_type)) 308 else ifdef $(1).$(bld_trg_arch) 309 local .RETURN := $($(1).$(bld_trg_arch)) 310 else ifdef $(1).$(bld_trg) 311 local .RETURN := $($(1).$(bld_trg)) 312 else ifdef $(1).$(bld_type) 313 local .RETURN := $($(1).$(bld_type)) 296 local .RETURN := $(firstdefined \ 297 $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \ 298 $(target)_$(1).$(bld_trg).$(bld_trg_arch) \ 299 $(target)_$(1).$(bld_trg).$(bld_type) \ 300 $(target)_$(1).$(bld_trg_cpu) \ 301 $(target)_$(1).$(bld_trg_arch) \ 302 $(target)_$(1).$(bld_trg) \ 303 $(target)_$(1).$(bld_type) \ 304 $(target)_$(1) \ 305 ) 306 ifeq ($(.RETURN),) 307 ifneq ($(2),) 308 local .RETURN := $(firstdefined \ 309 $(2).$(bld_trg).$(bld_trg_arch).$(bld_type) \ 310 $(2).$(bld_trg).$(bld_trg_arch) \ 311 $(2).$(bld_trg).$(bld_type) \ 312 $(2).$(bld_trg_cpu) \ 313 $(2).$(bld_trg_arch) \ 314 $(2).$(bld_trg) \ 315 $(2).$(bld_type) \ 316 $(2) \ 317 3 \ 318 ) 319 else 320 local .RETURN := $(firstdefined \ 321 kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \ 322 kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch) \ 323 kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type) \ 324 kBuildGlobalDefaults_$(1).$(bld_trg_cpu) \ 325 kBuildGlobalDefaults_$(1).$(bld_trg_arch) \ 326 kBuildGlobalDefaults_$(1).$(bld_trg) \ 327 kBuildGlobalDefaults_$(1).$(bld_type) \ 328 kBuildGlobalDefaults_$(1) \ 329 3 \ 330 ) 331 endif 332 endif 333 local .RETURN := $(strip $($(.RETURN))) 334 endef # def_fn_prop_get_first_defined 335 336 ## 337 # Function for getting the first property value (ignoring empty defines). 338 # 339 # @param 1 The property name. 340 # @param 2 The default property name, empty if none. 341 # @param 3 What to return if all variables are empty. (optional) 342 # @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type. 343 # @returns First word. 344 # 345 define def_fn_prop_get_first_word 346 local .RETURN := $(firstword \ 347 $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ 348 $($(target)_$(1).$(bld_trg).$(bld_trg_arch)) \ 349 $($(target)_$(1).$(bld_trg).$(bld_type)) \ 350 $($(target)_$(1).$(bld_trg_cpu)) \ 351 $($(target)_$(1).$(bld_trg_arch)) \ 352 $($(target)_$(1).$(bld_trg)) \ 353 $($(target)_$(1).$(bld_type)) \ 354 $($(target)_$(1)) \ 355 ) 356 ifeq ($(.RETURN),) 357 ifneq ($(2),) 358 local .RETURN := $(firstword \ 359 $($(2).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ 360 $($(2).$(bld_trg).$(bld_trg_arch)) \ 361 $($(2).$(bld_trg).$(bld_type)) \ 362 $($(2).$(bld_trg_cpu)) \ 363 $($(2).$(bld_trg_arch)) \ 364 $($(2).$(bld_trg)) \ 365 $($(2).$(bld_type)) \ 366 $($(2)) \ 367 $(3) \ 368 ) 369 else 370 local .RETURN := $(firstword \ 371 $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \ 372 $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch)) \ 373 $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type)) \ 374 $(kBuildGlobalDefaults_$(1).$(bld_trg_cpu)) \ 375 $(kBuildGlobalDefaults_$(1).$(bld_trg_arch)) \ 376 $(kBuildGlobalDefaults_$(1).$(bld_trg)) \ 377 $(kBuildGlobalDefaults_$(1).$(bld_type)) \ 378 $(kBuildGlobalDefaults_$(1)) \ 379 $(3) \ 380 ) 381 endif 382 endif 383 endef # def_fn_prop_get_first_word 384 385 ## 386 # Install a debug directory. 387 # @param debug_dir The directory name. 388 define def_link_install_debug_dir_rule 389 local dir := $(debug_inst_path)/$(debug_inst)$(debug_dir) 390 $$(dir): | $$$$(dir $$$$(patsubst %/,%,$$$$@)) 391 %$$(call MSG_INST_DIR,$$@) 392 $$(QUIET)$$(MKDIR) -p -- $$@ 393 $(target)_2_DEBUG_$(debug_var)_TARGET_DIRS += $$(dir) 394 endef # def_link_install_debug_dir_rule 395 396 ## 397 # Install a debug file. 398 # @param debug_file Src=>Dst file pair. 399 define def_link_install_debug_file_rule 400 local dst := $(debug_inst_path)/$(debug_inst)$(word 2, $(subst =>,$(SP),$(debug_file))) 401 $$(dst): $(word 1, $(subst =>,$(SP),$(debug_file))) | $$$$(dir $$$$@) 402 %$$(call MSG_INST_FILE,$$@,$$<) 403 $$(QUIET)$(debug_install_cmd) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $$< $$@ 404 $(target)_2_DEBUG_$(debug_var)_TARGET_FILES += $$(dst) 405 endef # def_link_install_debug_file_rule 406 407 ## 408 # Install debug info to $(debug_inst), where debug_inst can be a directory or 409 # file (just like $(inst) and $(stage). Used for both staging and installing. 410 define def_target_install_only_debug 411 if "$(substr $(debug_inst),-1,1)" == "/" 412 if "$(debug_inst)" == "./" 413 local debug_inst := 414 endif 415 local debug_dirs := $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_DIRS)) 416 ifneq ($(strip $(root $(debug_dirs))),) 417 $(error kBuild: Bad tool? debug_dirs='$(debug_dirs)', expected all to be under '$(outbase)') 418 endif 419 local debug_files := $(foreach file, $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_FILES)) \ 420 ,$($(target)_0_OUTDIR)/$(file)=>$(file)) 314 421 else 315 local .RETURN := $($(1)) 316 endif 317 endef # def_fn_prop_get_first_defined 422 local debug_files := $(call TOOL_$(tool)_$(tool_do)_DEBUG_INSTALL_FN,$(out),$(outbase),$(debug_inst)) 423 local debug_dirs := $(filter %/,$(debug_files)) 424 local debug_files := $(filter-out %/,$(debug_files)) 425 endif 426 $(foreach debug_dir, $(debug_dirs), $(eval $(def_link_install_debug_dir_rule))) 427 $(foreach debug_file, $(debug_files), $(eval $(def_link_install_debug_file_rule))) 428 endef 318 429 319 430 … … 365 476 $(typevar) += $(out) 366 477 endif # INSTTYPE == none 478 479 # Install debug info. 480 $(target)_2_DEBUG_STAGE_TARGET_DIRS := 481 $(target)_2_DEBUG_STAGE_TARGET_FILES := 482 $(target)_2_DEBUG_INSTALL_TARGET_DIRS := 483 $(target)_2_DEBUG_INSTALL_TARGET_FILES := 484 485 if ( defined($(target)_2_OUTPUT_DEBUG_DIRS) \ 486 || defined($(target)_2_OUTPUT_DEBUG_FILES) ) \ 487 && "$($(target)_1_DEBUG_INSTTYPE)" != "none" 488 local mode := $(if $(mode),$(mode)$(COMMA)a-x,0644) 489 490 ifeq ($($(target)_1_DEBUG_INSTTYPE),both) 491 local debug_inst_path := $(PATH_INS) 492 local debug_install_cmd := $(INSTALL) 493 local debug_var := INSTALL 494 $(foreach debug_inst, $($(target)_1_DEBUG_INST), $(evalval def_target_install_only_debug)) 495 endif 496 497 local debug_inst_path := $(PATH_STAGE) 498 local debug_install_cmd := $(INSTALL_STAGING) 499 local debug_var := STAGE 500 if1of ($($(target)_1_DEBUG_INSTTYPE), stage both) 501 $(foreach debug_inst, $($(target)_1_DEBUG_STAGE), $(evalval def_target_install_only_debug)) 502 endif 503 if1of ($($(target)_1_INSTTYPE), stage both) 504 ifndef debug_nostage 505 $(foreach debug_inst,$($(target)_1_STAGE), $(evalval def_target_install_only_debug)) 506 endif 507 endif 508 509 _DEBUG_STAGE_DIRS += $($(target)_2_DEBUG_STAGE_TARGET_DIRS) 510 _DEBUG_STAGE_FILES += $($(target)_2_DEBUG_STAGE_TARGET_FILES) 511 _DEBUG_INSTALL_DIRS += $($(target)_2_DEBUG_INSTALL_TARGET_DIRS) 512 _DEBUG_INSTALL_FILES += $($(target)_2_DEBUG_INSTALL_TARGET_FILES) 513 514 $(basename $(notdir $(out))):: $($(target)_2_DEBUG_STAGE_TARGET_DIRS) $($(target)_2_DEBUG_STAGE_TARGET_FILES) 515 endif 367 516 368 517 endef # def_target_install_only … … 534 683 535 684 # call the tool 536 local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)685 local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS) 537 686 ifneq ($(pre_cmds),) 538 687 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds) 539 688 endif 540 689 ifneq ($(post_cmds),) 541 local cmds 690 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) 542 691 endif 543 692 $(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT) … … 813 962 endif 814 963 964 # Debug info. 965 local ld_debug := $(evalcall def_fn_prop_get_first_defined,LD_DEBUG) 966 local debug_inst := $(evalcall def_fn_prop_get_first_defined,DEBUG_INST) 967 local debug_stage := $(evalcall def_fn_prop_get_first_defined,DEBUG_STAGE) 968 local debug_nostage := $(evalcall def_fn_prop_get_first_word,DEBUG_NOSTAGE) 969 815 970 # Custom pre/post-link actions. 816 local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)817 local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)971 local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS) 972 local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS) 818 973 819 974 # eliminate this guy? 820 975 local objs = $($(target)_2_OBJS) 821 822 # installation targets823 local target_type_mode :=824 $(evalval def_target_install_only)825 976 826 977 # dependency file … … 861 1012 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds) 862 1013 endif 863 $(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT) 864 $(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE) 865 $(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS) 866 $(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps) 1014 $(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT) 1015 $(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE) 1016 if1of ($(ld_debug), split) 1017 $(target)_2_OUTPUT_DEBUG_FILES := $(filter-out %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG)) 1018 $(target)_2_OUTPUT_DEBUG_DIRS := $(filter %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG)) 1019 else 1020 $(target)_2_OUTPUT_DEBUG_FILES := 1021 $(target)_2_OUTPUT_DEBUG_DIRS := 1022 endif 1023 $(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS) 1024 $(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps) 867 1025 868 1026 # generate the link rule. 869 1027 $(eval $(def_link_rule)) 870 1028 1029 # installation targets 1030 local target_type_mode := 1031 $(evalval def_target_install_only) 871 1032 872 1033 # Update globals.
Note:
See TracChangeset
for help on using the changeset viewer.