< prev index next >

make/common/NativeCompilation.gmk

Print this page




 158 $(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD_LINK_CXX, \
 159     EXTENDS := TOOLCHAIN_BUILD, \
 160     LD := $(BUILD_LDCXX), \
 161 ))
 162 
 163 ################################################################################
 164 
 165 # Extensions of files handled by this macro.
 166 NATIVE_SOURCE_EXTENSIONS := %.s %.S %.c %.cpp %.cc %.m %.mm
 167 
 168 # Replaces native source extensions with the object file extension in a string.
 169 # Param 1: the string containing source file names with extensions
 170 # The surrounding strip is needed to keep additional whitespace out
 171 define replace_with_obj_extension
 172 $(strip \
 173   $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \
 174       $(patsubst $(extension),%$(OBJ_SUFFIX), $(filter $(extension), $1))) \
 175 )
 176 endef
 177 
 178 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin)
 179   UNIX_PATH_PREFIX := /cygdrive
 180 else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys)
 181   UNIX_PATH_PREFIX :=
 182 endif
 183 
 184 # This pattern is used to transform the output of the microsoft CL compiler
 185 # into a make syntax dependency file (.d)
 186 WINDOWS_SHOWINCLUDE_SED_PATTERN := \
 187     -e '/^Note: including file:/!d' \
 188     -e 's|Note: including file: *||' \
 189     -e 's|\r||g' \
 190     -e 's|\\|/|g' \
 191     -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \
 192     -e '\|$(TOPDIR)|I !d' \
 193     -e 's|$$$$| \\|g' \
 194     #
 195 
 196 # This pattern is used to transform a dependency file (.d) to a list
 197 # of make targets for dependent files (.d.targets)
 198 DEPENDENCY_TARGET_SED_PATTERN := \
 199     -e 's/\#.*//' \
 200     -e 's/^[^:]*: *//' \


 753           FILE := $$(file), \
 754           BASE := $1, \
 755       )) \
 756   )
 757 
 758   # Setup rule for printing progress info when compiling source files.
 759   # This is a rough heuristic and may not always print accurate information.
 760   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
 761         ifeq ($$(wildcard $$($1_TARGET)), )
 762           $(ECHO) 'Creating $$(subst $$(OUTPUTDIR)/,,$$($1_TARGET)) from $$(words \
 763               $$(filter-out %.vardeps, $$?)) file(s)'
 764         else
 765           $(ECHO) $$(strip 'Updating $$(subst $$(OUTPUTDIR)/,,$$($1_TARGET))' \
 766               $$(if $$(filter-out %.vardeps, $$?), \
 767                 'due to $$(words $$(filter-out %.vardeps, $$?)) file(s)', \
 768               $$(if $$(filter %.vardeps, $$?), 'due to makefile changes')))
 769         endif
 770         $(TOUCH) $$@
 771 
 772   # On windows we need to create a resource file
 773   ifeq ($(OPENJDK_TARGET_OS), windows)
 774     ifneq ($$($1_VERSIONINFO_RESOURCE), )
 775       $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res
 776       $1_RES_DEP := $$($1_RES).d
 777       $1_RES_DEP_TARGETS := $$($1_RES).d.targets
 778       -include $$($1_RES_DEP)
 779       -include $$($1_RES_DEP_TARGETS)
 780 
 781       $1_RES_VARDEPS := $$($1_RC) $$($1_RC_FLAGS)
 782       $1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
 783           $$($1_RES).vardeps)
 784 
 785       $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
 786                 $$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
 787                 $$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
 788                 $$(call ExecuteWithLog, $$@, \
 789                     $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
 790                     $$($1_VERSIONINFO_RESOURCE) 2>&1 )
 791                 # Windows RC compiler does not support -showIncludes, so we mis-use CL
 792                 # for this. Filter out RC specific arguments that are unknown to CL.
 793                 # For some unknown reason, in this case CL actually outputs the show
 794                 # includes to stderr so need to redirect it to hide the output from the
 795                 # main log.
 796                 $$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
 797                     $$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
 798                         $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
 799                         $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
 800                         $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
 801                     | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
 802                         -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
 803                 $(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
 804                 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
 805                 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
 806     endif
 807   endif
 808 
 809   ifneq ($(DISABLE_MAPFILES), true)
 810     $1_REAL_MAPFILE := $$($1_MAPFILE)
 811     ifneq ($(OPENJDK_TARGET_OS), windows)
 812       ifneq ($$($1_REORDER), )
 813         $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile
 814 
 815         $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER)
 816                 $$(call MakeDir, $$(@D))
 817                 $$(CP) $$($1_MAPFILE) $$@.tmp
 818                 $$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp
 819                 $$(MV) $$@.tmp $$@
 820       endif
 821     endif
 822   endif
 823 
 824   # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
 825   # for LDFLAGS and LIBS
 826   $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
 827   $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
 828   ifneq ($$($1_REAL_MAPFILE), )
 829     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
 830   endif
 831 
 832   # Need to make sure TARGET is first on list
 833   $1 := $$($1_TARGET)
 834 
 835   ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
 836     $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
 837   endif
 838 
 839   ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
 840     $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
 841   endif
 842 
 843   ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
 844     ifneq ($$($1_DEBUG_SYMBOLS), false)
 845       # Only copy debug symbols for dynamic libraries and programs.
 846       ifneq ($$($1_TYPE), STATIC_LIBRARY)
 847         # Generate debuginfo files.
 848         ifeq ($(OPENJDK_TARGET_OS), windows)
 849           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
 850               "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
 851           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
 852               $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
 853 
 854         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
 855           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
 856           # Setup the command line creating debuginfo files, to be run after linking.
 857           # It cannot be run separately since it updates the original target file
 858           $1_CREATE_DEBUGINFO_CMDS := \
 859               $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
 860               $(CD) $$($1_OUTPUT_DIR) && \
 861                   $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 862 
 863         else ifeq ($(OPENJDK_TARGET_OS), macosx)
 864           $1_DEBUGINFO_FILES := \
 865               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
 866               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
 867           $1_CREATE_DEBUGINFO_CMDS := \
 868               $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
 869         endif # OPENJDK_TARGET_OS
 870 
 871         # Since the link rule creates more than one file that we want to track,
 872         # we have to use some tricks to get make to cooperate. To properly
 873         # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
 874         # a recipe in the rule below. To avoid rerunning the recipe every time
 875         # have it touch the target. If a debuginfo file is deleted by something
 876         # external, explicitly delete the TARGET to trigger a rebuild of both.
 877         ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
 878           $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
 879           $$(shell $(RM) $$($1_TARGET))
 880         endif
 881         $$($1_DEBUGINFO_FILES): $$($1_TARGET)
 882                 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
 883                   $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
 884                 )
 885                 $(TOUCH) $$@
 886 
 887         $1 += $$($1_DEBUGINFO_FILES)
 888 
 889         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)


 935                 $$($1_RES))
 936         ifeq ($(STATIC_BUILD), true)
 937           ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
 938             $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
 939           else
 940             $(GetSymbols)
 941           endif
 942         endif
 943   else
 944     # A shared dynamic library or an executable binary has been specified
 945     ifeq ($$($1_TYPE), LIBRARY)
 946       # Generating a dynamic library.
 947       $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
 948 
 949       # Create loadmap on AIX. Helps in diagnosing some problems.
 950       ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
 951         $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
 952       endif
 953     endif
 954 
 955     ifeq ($(OPENJDK_TARGET_OS), windows)
 956       ifeq ($$($1_EMBED_MANIFEST), true)
 957         $1_EXTRA_LDFLAGS += -manifest:embed
 958       endif
 959 
 960       $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
 961       $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
 962       ifeq ($$($1_TYPE), LIBRARY)
 963         # To properly trigger downstream dependants of the import library, just as
 964         # for debug files, we must have a recipe in the rule. To avoid rerunning
 965         # the recipe every time have it touch the target. If an import library
 966         # file is deleted by something external, explicitly delete the target to
 967         # trigger a rebuild of both.
 968         ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
 969           $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
 970           $$(shell $(RM) $$($1_TARGET))
 971         endif
 972         $$($1_IMPORT_LIBRARY): $$($1_TARGET)
 973                 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
 974                   $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
 975                 )


1015           $1_LINK_OBJS_RELATIVE := true
1016           $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
1017         endif
1018       endif
1019     endif
1020 
1021     $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
1022         $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
1023 
1024     $$($1_TARGET): $$($1_TARGET_DEPS)
1025                 ifneq ($$($1_OBJ_FILE_LIST), )
1026                   ifeq ($$($1_LINK_OBJS_RELATIVE), true)
1027                     $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
1028                   else
1029                     $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
1030                   endif
1031                 endif
1032                 # Keep as much as possible on one execution line for best performance
1033                 # on Windows
1034                 $$(call LogInfo, Linking $$($1_BASENAME))
1035                 ifeq ($(OPENJDK_TARGET_OS), windows)
1036                   $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1037                       $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1038                           $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1039                           $$($1_LIBS) $$($1_EXTRA_LIBS)) \
1040                       | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
1041                           test "$$$$?" = "1" ; \
1042                   $$($1_CREATE_DEBUGINFO_CMDS)
1043                   $$($1_STRIP_CMD)
1044                 else
1045                   $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1046                       $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
1047                       $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1048                           $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1049                           $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
1050                   $$($1_CREATE_DEBUGINFO_CMDS)
1051                   $$($1_STRIP_CMD)
1052                 endif
1053                 ifeq ($(OPENJDK_TARGET_OS), windows)
1054                   ifneq ($$($1_MANIFEST), )
1055                     $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
1056                   endif
1057                 endif
1058                 # This only works if the openjdk_codesign identity is present on the system. Let
1059                 # silently fail otherwise.
1060                 ifneq ($(CODESIGN), )
1061                   ifneq ($$($1_CODESIGN), )
1062                     $(CODESIGN) -s openjdk_codesign $$@
1063                   endif
1064                 endif
1065   endif
1066 
1067   ifeq ($(GENERATE_COMPILE_COMMANDS_ONLY), true)
1068     $1 := $$($1_ALL_OBJS_JSON)
1069   endif
1070 endef
1071 
1072 endif # _NATIVE_COMPILATION_GMK


 158 $(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD_LINK_CXX, \
 159     EXTENDS := TOOLCHAIN_BUILD, \
 160     LD := $(BUILD_LDCXX), \
 161 ))
 162 
 163 ################################################################################
 164 
 165 # Extensions of files handled by this macro.
 166 NATIVE_SOURCE_EXTENSIONS := %.s %.S %.c %.cpp %.cc %.m %.mm
 167 
 168 # Replaces native source extensions with the object file extension in a string.
 169 # Param 1: the string containing source file names with extensions
 170 # The surrounding strip is needed to keep additional whitespace out
 171 define replace_with_obj_extension
 172 $(strip \
 173   $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \
 174       $(patsubst $(extension),%$(OBJ_SUFFIX), $(filter $(extension), $1))) \
 175 )
 176 endef
 177 
 178 ifeq ($(call isBuildOsEnv, windows.cygwin), true)
 179   UNIX_PATH_PREFIX := /cygdrive
 180 else ifeq ($(call isBuildOsEnv, windows.msys), true)
 181   UNIX_PATH_PREFIX :=
 182 endif
 183 
 184 # This pattern is used to transform the output of the microsoft CL compiler
 185 # into a make syntax dependency file (.d)
 186 WINDOWS_SHOWINCLUDE_SED_PATTERN := \
 187     -e '/^Note: including file:/!d' \
 188     -e 's|Note: including file: *||' \
 189     -e 's|\r||g' \
 190     -e 's|\\|/|g' \
 191     -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \
 192     -e '\|$(TOPDIR)|I !d' \
 193     -e 's|$$$$| \\|g' \
 194     #
 195 
 196 # This pattern is used to transform a dependency file (.d) to a list
 197 # of make targets for dependent files (.d.targets)
 198 DEPENDENCY_TARGET_SED_PATTERN := \
 199     -e 's/\#.*//' \
 200     -e 's/^[^:]*: *//' \


 753           FILE := $$(file), \
 754           BASE := $1, \
 755       )) \
 756   )
 757 
 758   # Setup rule for printing progress info when compiling source files.
 759   # This is a rough heuristic and may not always print accurate information.
 760   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
 761         ifeq ($$(wildcard $$($1_TARGET)), )
 762           $(ECHO) 'Creating $$(subst $$(OUTPUTDIR)/,,$$($1_TARGET)) from $$(words \
 763               $$(filter-out %.vardeps, $$?)) file(s)'
 764         else
 765           $(ECHO) $$(strip 'Updating $$(subst $$(OUTPUTDIR)/,,$$($1_TARGET))' \
 766               $$(if $$(filter-out %.vardeps, $$?), \
 767                 'due to $$(words $$(filter-out %.vardeps, $$?)) file(s)', \
 768               $$(if $$(filter %.vardeps, $$?), 'due to makefile changes')))
 769         endif
 770         $(TOUCH) $$@
 771 
 772   # On windows we need to create a resource file
 773   ifeq ($(call isTargetOs, windows), true)
 774     ifneq ($$($1_VERSIONINFO_RESOURCE), )
 775       $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res
 776       $1_RES_DEP := $$($1_RES).d
 777       $1_RES_DEP_TARGETS := $$($1_RES).d.targets
 778       -include $$($1_RES_DEP)
 779       -include $$($1_RES_DEP_TARGETS)
 780 
 781       $1_RES_VARDEPS := $$($1_RC) $$($1_RC_FLAGS)
 782       $1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
 783           $$($1_RES).vardeps)
 784 
 785       $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
 786                 $$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
 787                 $$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
 788                 $$(call ExecuteWithLog, $$@, \
 789                     $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
 790                     $$($1_VERSIONINFO_RESOURCE) 2>&1 )
 791                 # Windows RC compiler does not support -showIncludes, so we mis-use CL
 792                 # for this. Filter out RC specific arguments that are unknown to CL.
 793                 # For some unknown reason, in this case CL actually outputs the show
 794                 # includes to stderr so need to redirect it to hide the output from the
 795                 # main log.
 796                 $$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
 797                     $$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
 798                         $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
 799                         $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
 800                         $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
 801                     | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
 802                         -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
 803                 $(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
 804                 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
 805                 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
 806     endif
 807   endif
 808 
 809   ifneq ($(DISABLE_MAPFILES), true)
 810     $1_REAL_MAPFILE := $$($1_MAPFILE)
 811     ifneq ($(call isTargetOs, windows), true)
 812       ifneq ($$($1_REORDER), )
 813         $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile
 814 
 815         $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER)
 816                 $$(call MakeDir, $$(@D))
 817                 $$(CP) $$($1_MAPFILE) $$@.tmp
 818                 $$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp
 819                 $$(MV) $$@.tmp $$@
 820       endif
 821     endif
 822   endif
 823 
 824   # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
 825   # for LDFLAGS and LIBS
 826   $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
 827   $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
 828   ifneq ($$($1_REAL_MAPFILE), )
 829     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
 830   endif
 831 
 832   # Need to make sure TARGET is first on list
 833   $1 := $$($1_TARGET)
 834 
 835   ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
 836     $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
 837   endif
 838 
 839   ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
 840     $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
 841   endif
 842 
 843   ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
 844     ifneq ($$($1_DEBUG_SYMBOLS), false)
 845       # Only copy debug symbols for dynamic libraries and programs.
 846       ifneq ($$($1_TYPE), STATIC_LIBRARY)
 847         # Generate debuginfo files.
 848         ifeq ($(call isTargetOs, windows), true)
 849           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
 850               "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
 851           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
 852               $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
 853 
 854         else ifeq ($(call isTargetOs, linux solaris), true)
 855           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
 856           # Setup the command line creating debuginfo files, to be run after linking.
 857           # It cannot be run separately since it updates the original target file
 858           $1_CREATE_DEBUGINFO_CMDS := \
 859               $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
 860               $(CD) $$($1_OUTPUT_DIR) && \
 861                   $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 862 
 863         else ifeq ($(call isTargetOs, macosx), true)
 864           $1_DEBUGINFO_FILES := \
 865               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
 866               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
 867           $1_CREATE_DEBUGINFO_CMDS := \
 868               $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
 869         endif
 870 
 871         # Since the link rule creates more than one file that we want to track,
 872         # we have to use some tricks to get make to cooperate. To properly
 873         # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
 874         # a recipe in the rule below. To avoid rerunning the recipe every time
 875         # have it touch the target. If a debuginfo file is deleted by something
 876         # external, explicitly delete the TARGET to trigger a rebuild of both.
 877         ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
 878           $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
 879           $$(shell $(RM) $$($1_TARGET))
 880         endif
 881         $$($1_DEBUGINFO_FILES): $$($1_TARGET)
 882                 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
 883                   $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
 884                 )
 885                 $(TOUCH) $$@
 886 
 887         $1 += $$($1_DEBUGINFO_FILES)
 888 
 889         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)


 935                 $$($1_RES))
 936         ifeq ($(STATIC_BUILD), true)
 937           ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
 938             $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
 939           else
 940             $(GetSymbols)
 941           endif
 942         endif
 943   else
 944     # A shared dynamic library or an executable binary has been specified
 945     ifeq ($$($1_TYPE), LIBRARY)
 946       # Generating a dynamic library.
 947       $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
 948 
 949       # Create loadmap on AIX. Helps in diagnosing some problems.
 950       ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
 951         $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
 952       endif
 953     endif
 954 
 955     ifeq ($(call isTargetOs, windows), true)
 956       ifeq ($$($1_EMBED_MANIFEST), true)
 957         $1_EXTRA_LDFLAGS += -manifest:embed
 958       endif
 959 
 960       $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
 961       $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
 962       ifeq ($$($1_TYPE), LIBRARY)
 963         # To properly trigger downstream dependants of the import library, just as
 964         # for debug files, we must have a recipe in the rule. To avoid rerunning
 965         # the recipe every time have it touch the target. If an import library
 966         # file is deleted by something external, explicitly delete the target to
 967         # trigger a rebuild of both.
 968         ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
 969           $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
 970           $$(shell $(RM) $$($1_TARGET))
 971         endif
 972         $$($1_IMPORT_LIBRARY): $$($1_TARGET)
 973                 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
 974                   $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
 975                 )


1015           $1_LINK_OBJS_RELATIVE := true
1016           $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
1017         endif
1018       endif
1019     endif
1020 
1021     $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
1022         $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
1023 
1024     $$($1_TARGET): $$($1_TARGET_DEPS)
1025                 ifneq ($$($1_OBJ_FILE_LIST), )
1026                   ifeq ($$($1_LINK_OBJS_RELATIVE), true)
1027                     $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
1028                   else
1029                     $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
1030                   endif
1031                 endif
1032                 # Keep as much as possible on one execution line for best performance
1033                 # on Windows
1034                 $$(call LogInfo, Linking $$($1_BASENAME))
1035                 ifeq ($(call isTargetOs, windows), true)
1036                   $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1037                       $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1038                           $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1039                           $$($1_LIBS) $$($1_EXTRA_LIBS)) \
1040                       | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
1041                           test "$$$$?" = "1" ; \
1042                   $$($1_CREATE_DEBUGINFO_CMDS)
1043                   $$($1_STRIP_CMD)
1044                 else
1045                   $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1046                       $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
1047                       $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1048                           $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1049                           $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
1050                   $$($1_CREATE_DEBUGINFO_CMDS)
1051                   $$($1_STRIP_CMD)
1052                 endif
1053                 ifeq ($(call isTargetOs, windows), true)
1054                   ifneq ($$($1_MANIFEST), )
1055                     $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
1056                   endif
1057                 endif
1058                 # This only works if the openjdk_codesign identity is present on the system. Let
1059                 # silently fail otherwise.
1060                 ifneq ($(CODESIGN), )
1061                   ifneq ($$($1_CODESIGN), )
1062                     $(CODESIGN) -s openjdk_codesign $$@
1063                   endif
1064                 endif
1065   endif
1066 
1067   ifeq ($(GENERATE_COMPILE_COMMANDS_ONLY), true)
1068     $1 := $$($1_ALL_OBJS_JSON)
1069   endif
1070 endef
1071 
1072 endif # _NATIVE_COMPILATION_GMK
< prev index next >