433 # Need to make sure TARGET is first on list 434 $1 := $$($1_TARGET) 435 ifeq ($$($1_STATIC_LIBRARY),) 436 ifneq ($$($1_DEBUG_SYMBOLS),) 437 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) 438 ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet 439 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) 440 # The dependency on TARGET is needed on windows for debuginfo files 441 # to be rebuilt properly. 442 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET) 443 $(CP) $$< $$@ 444 endif 445 446 # Generate debuginfo files. 447 ifeq ($(OPENJDK_TARGET_OS), windows) 448 $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \ 449 "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map" 450 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \ 451 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map 452 453 # This dependency dance ensures that windows debug info files get rebuilt 454 # properly if deleted. 455 $$($1_TARGET): $$($1_DEBUGINFO_FILES) 456 $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS) 457 458 else ifeq ($(OPENJDK_TARGET_OS), solaris) 459 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 460 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 461 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 462 # empty section headers until a fixed $(OBJCOPY) is available. 463 # An empty section header has sh_addr == 0 and sh_size == 0. 464 # This problem has only been seen on Solaris X64, but we call this tool 465 # on all Solaris builds just in case. 466 # 467 # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 468 # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 469 $$($1_DEBUGINFO_FILES): $$($1_TARGET) \ 470 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) 471 $(RM) $$@ 472 $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< 473 $(OBJCOPY) --only-keep-debug $$< $$@ 474 $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< 475 $(TOUCH) $$@ 476 477 else ifeq ($(OPENJDK_TARGET_OS), linux) 478 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 479 $$($1_DEBUGINFO_FILES): $$($1_TARGET) 480 $(RM) $$@ 481 $(OBJCOPY) --only-keep-debug $$< $$@ 482 $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< 483 $(TOUCH) $$@ 484 485 endif # No MacOS X support 486 487 ifeq ($(ZIP_DEBUGINFO_FILES), true) 488 $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz 489 $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP)) 490 491 # The dependency on TARGET is needed on windows for debuginfo files 492 # to be rebuilt properly. 493 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) 494 $(CD) $$($1_OBJECT_DIR) \ 495 && $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES)) 496 497 else 498 $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES)) 499 endif 500 endif 501 endif # !MacOS X 502 endif # $1_DEBUG_SYMBOLS 503 endif # !STATIC_LIBRARY 504 505 ifneq (,$$($1_LIBRARY)) 506 # Generating a dynamic library. 507 $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) 508 ifeq ($(OPENJDK_TARGET_OS), windows) 509 $1_EXTRA_LDFLAGS+="-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib" 510 endif 511 512 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 513 514 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) 515 $$(call LINKING_MSG,$$($1_BASENAME)) 516 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \ 517 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ 518 $$($1_EXTRA_LDFLAGS_SUFFIX) 519 # Touch target to make sure it has a later time stamp than the debug 520 # symbol files to avoid unnecessary relinking on rebuild. 521 ifeq ($(OPENJDK_TARGET_OS), windows) 522 $(TOUCH) $$@ 523 endif 524 525 endif 526 527 ifneq (,$$($1_STATIC_LIBRARY)) 528 # Generating a static library, ie object file archive. 529 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) 530 $$(call ARCHIVING_MSG,$$($1_LIBRARY)) 531 $(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ 532 $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 533 endif 534 535 ifneq (,$$($1_PROGRAM)) 536 # A executable binary has been specified, setup the target for it. 537 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 538 539 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) 540 $$(call LINKING_EXE_MSG,$$($1_BASENAME)) 541 $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \ 542 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ 543 $$($1_EXTRA_LDFLAGS_SUFFIX) 544 ifneq (,$$($1_GEN_MANIFEST)) 545 $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1 546 endif 547 # This only works if the openjdk_codesign identity is present on the system. Let 548 # silently fail otherwise. 549 ifneq (,$(CODESIGN)) 550 ifneq (,$$($1_CODESIGN)) 551 $(CODESIGN) -s openjdk_codesign $$@ 552 endif 553 endif 554 # Touch target to make sure it has a later time stamp than the debug 555 # symbol files to avoid unnecessary relinking on rebuild. 556 ifeq ($(OPENJDK_TARGET_OS), windows) 557 $(TOUCH) $$@ 558 endif 559 560 endif 561 endef 562 563 endif # _NATIVE_COMPILATION_GMK | 433 # Need to make sure TARGET is first on list 434 $1 := $$($1_TARGET) 435 ifeq ($$($1_STATIC_LIBRARY),) 436 ifneq ($$($1_DEBUG_SYMBOLS),) 437 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) 438 ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet 439 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) 440 # The dependency on TARGET is needed on windows for debuginfo files 441 # to be rebuilt properly. 442 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET) 443 $(CP) $$< $$@ 444 endif 445 446 # Generate debuginfo files. 447 ifeq ($(OPENJDK_TARGET_OS), windows) 448 $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \ 449 "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map" 450 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \ 451 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map 452 453 else ifeq ($(OPENJDK_TARGET_OS), solaris) 454 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 455 # Setup the command line creating debuginfo files, to be run after linking. 456 # It cannot be run separately since it updates the original target file 457 # 458 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 459 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 460 # empty section headers until a fixed $(OBJCOPY) is available. 461 # An empty section header has sh_addr == 0 and sh_size == 0. 462 # This problem has only been seen on Solaris X64, but we call this tool 463 # on all Solaris builds just in case. 464 # 465 # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 466 # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 467 $1_CREATE_DEBUGINFO_CMDS := \ 468 $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$($1_TARGET) $$(NEWLINE) \ 469 $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ 470 $(CD) $$($1_OUTPUT_DIR) && \ 471 $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$($1_DEBUGINFO_FILES) $$($1_TARGET) 472 $1_DEBUGINFO_EXTRA_DEPS := $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) 473 474 else ifeq ($(OPENJDK_TARGET_OS), linux) 475 $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 476 # Setup the command line creating debuginfo files, to be run after linking. 477 # It cannot be run separately since it updates the original target file 478 $1_CREATE_DEBUGINFO_CMDS := \ 479 $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ 480 $(CD) $$($1_OUTPUT_DIR) && \ 481 $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) 482 483 endif # No MacOS X support 484 485 # This dependency dance ensures that debug info files get rebuilt 486 # properly if deleted. 487 $$($1_TARGET): $$($1_DEBUGINFO_FILES) 488 $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS) 489 490 ifeq ($(ZIP_DEBUGINFO_FILES), true) 491 $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz 492 $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP)) 493 494 # The dependency on TARGET is needed for debuginfo files 495 # to be rebuilt properly. 496 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) 497 $(CD) $$($1_OBJECT_DIR) \ 498 && $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES)) 499 500 else 501 $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES)) 502 endif 503 endif 504 endif # !MacOS X 505 endif # $1_DEBUG_SYMBOLS 506 endif # !STATIC_LIBRARY 507 508 ifneq (,$$($1_LIBRARY)) 509 # Generating a dynamic library. 510 $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) 511 ifeq ($(OPENJDK_TARGET_OS), windows) 512 $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib" 513 endif 514 515 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 516 517 $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \ 518 $$($1_DEBUGINFO_EXTRA_DEPS) 519 $$(call LINKING_MSG,$$($1_BASENAME)) 520 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \ 521 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ 522 $$($1_EXTRA_LDFLAGS_SUFFIX) 523 $$($1_CREATE_DEBUGINFO_CMDS) 524 # Touch target to make sure it has a later time stamp than the debug 525 # symbol files to avoid unnecessary relinking on rebuild. 526 ifeq ($(OPENJDK_TARGET_OS), windows) 527 $(TOUCH) $$@ 528 endif 529 530 endif 531 532 ifneq (,$$($1_STATIC_LIBRARY)) 533 # Generating a static library, ie object file archive. 534 $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) 535 $$(call ARCHIVING_MSG,$$($1_LIBRARY)) 536 $(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ 537 $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 538 endif 539 540 ifneq (,$$($1_PROGRAM)) 541 # A executable binary has been specified, setup the target for it. 542 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 543 544 $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) \ 545 $$($1_DEBUGINFO_EXTRA_DEPS) 546 $$(call LINKING_EXE_MSG,$$($1_BASENAME)) 547 $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \ 548 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ 549 $$($1_EXTRA_LDFLAGS_SUFFIX) 550 ifneq (,$$($1_GEN_MANIFEST)) 551 $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1 552 endif 553 # This only works if the openjdk_codesign identity is present on the system. Let 554 # silently fail otherwise. 555 ifneq (,$(CODESIGN)) 556 ifneq (,$$($1_CODESIGN)) 557 $(CODESIGN) -s openjdk_codesign $$@ 558 endif 559 endif 560 $$($1_CREATE_DEBUGINFO_CMDS) 561 # Touch target to make sure it has a later time stamp than the debug 562 # symbol files to avoid unnecessary relinking on rebuild. 563 ifeq ($(OPENJDK_TARGET_OS), windows) 564 $(TOUCH) $$@ 565 endif 566 567 endif 568 endef 569 570 endif # _NATIVE_COMPILATION_GMK |