224 # to avoid make error "No rule to make target" for removed files 225 $1_$2_DEP_TARGETS:=$$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ)) 226 227 # Include previously generated dependency information. (if it exists) 228 -include $$($1_$2_DEP) 229 -include $$($1_$2_DEP_TARGETS) 230 231 ifeq ($(TOOLCHAIN_TYPE), microsoft) 232 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) 233 endif 234 endif 235 236 ifneq ($$($1_$(notdir $2)_CFLAGS)$$($1_$(notdir $2)_CXXFLAGS), ) 237 $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) 238 $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \ 239 $$(patsubst %$(OBJ_SUFFIX),%.vardeps,$$($1_$2_OBJ))) 240 endif 241 242 $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO) 243 $$(call LogInfo, Compiling $$(notdir $2) (for $$(notdir $$($1_TARGET)))) 244 ifneq ($(TOOLCHAIN_TYPE), microsoft) 245 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) 246 # The Solaris studio compiler doesn't output the full path to the object file in the 247 # generated deps files. Fixing it with sed. If compiling assembly, don't try this. 248 $(call LogFailures, $$($1_$2_OBJ).log, $$($1_SAFE_NAME)_$$(notdir $2), \ 249 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) 250 $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) 251 else 252 $(call LogFailures, $$($1_$2_OBJ).log, $$($1_SAFE_NAME)_$$(notdir $2), \ 253 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) 254 endif 255 # Create a dependency target file from the dependency file. 256 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ 257 ifneq ($$($1_$2_DEP),) 258 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) 259 endif 260 else 261 # The Visual Studio compiler lacks a feature for generating make dependencies, but by 262 # setting -showIncludes, all included files are printed. These are filtered out and 263 # parsed into make dependences. 264 # Keep as much as possible on one execution line for best performance on Windows. 265 # No need to save exit code from compilation since pipefail is always active on 266 # Windows. 267 $(call LogFailures, $$($1_$2_OBJ).log, $$($1_SAFE_NAME)_$$(notdir $2), \ 268 $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ 269 $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \ 270 | $(GREP) -v -e "^Note: including file:" \ 271 -e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \ 272 $(ECHO) $$@: \\ > $$($1_$2_DEP) ; \ 273 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_OBJ).log \ 274 | $(SORT) -u >> $$($1_$2_DEP) ; \ 275 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) 276 endif 277 endif 278 endef 279 280 # Setup make rules for creating a native binary (a shared library or an 281 # executable). 282 # 283 # Parameter 1 is the name of the rule. This name is used as variable prefix, 284 # and the targets generated are listed in a variable by that name. 285 # 286 # Remaining parameters are named arguments. These include: 287 # TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT. 767 768 # If there are many object files, use an @-file... 769 ifneq ($$(word 17, $$($1_ALL_OBJS)), ) 770 $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt 771 ifneq ($(COMPILER_COMMAND_FILE_FLAG),) 772 $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) 773 else 774 # ...except for toolchains which don't support them. 775 $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` 776 endif 777 endif 778 779 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \ 780 $$($1_VARDEPS_FILE) 781 ifneq ($$($1_OBJ_FILE_LIST), ) 782 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) 783 endif 784 # Keep as much as possible on one execution line for best performance 785 # on Windows 786 $$(call LogInfo, Linking $$($1_BASENAME)) 787 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ 788 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ 789 $(LD_OUT_OPTION)$$@ \ 790 $$($1_LD_OBJ_ARG) $$($1_RES) \ 791 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \ 792 $$($1_CREATE_DEBUGINFO_CMDS) 793 $$($1_STRIP_CMD) 794 795 endif 796 797 ifneq (,$$($1_STATIC_LIBRARY)) 798 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \ 799 $$($1_EXTRA_LIBS) 800 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 801 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 802 803 # Generating a static library, ie object file archive. 804 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) 805 $$(call LogInfo, Archiving $$($1_STATIC_LIBRARY)) 806 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ 807 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ 808 $$($1_RES)) 809 ifeq ($(STATIC_BUILD), true) 810 $(GetSymbols) 811 endif 812 endif 813 814 ifneq (,$$($1_PROGRAM)) 815 # A executable binary has been specified, setup the target for it. 816 $1_EXTRA_LIBS += $(GLOBAL_LIBS) 817 818 $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ 819 $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ 820 $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \ 821 $$($1_STRIP_CMD) 822 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 823 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 824 825 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ 826 $$($1_VARDEPS_FILE) 827 $$(call LogInfo, Linking executable $$($1_BASENAME)) 828 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ 829 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ 830 $(EXE_OUT_OPTION)$$($1_TARGET) \ 831 $$($1_ALL_OBJS) $$($1_RES) \ 832 $$($1_LIBS) $$($1_EXTRA_LIBS)) 833 ifeq ($(OPENJDK_TARGET_OS), windows) 834 ifneq ($$($1_MANIFEST), ) 835 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_PROGRAM).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 836 endif 837 endif 838 # This only works if the openjdk_codesign identity is present on the system. Let 839 # silently fail otherwise. 840 ifneq (,$(CODESIGN)) 841 ifneq (,$$($1_CODESIGN)) 842 $(CODESIGN) -s openjdk_codesign $$@ 843 endif 844 endif 845 $$($1_CREATE_DEBUGINFO_CMDS) 846 $$($1_STRIP_CMD) 847 848 endif | 224 # to avoid make error "No rule to make target" for removed files 225 $1_$2_DEP_TARGETS:=$$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ)) 226 227 # Include previously generated dependency information. (if it exists) 228 -include $$($1_$2_DEP) 229 -include $$($1_$2_DEP_TARGETS) 230 231 ifeq ($(TOOLCHAIN_TYPE), microsoft) 232 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) 233 endif 234 endif 235 236 ifneq ($$($1_$(notdir $2)_CFLAGS)$$($1_$(notdir $2)_CXXFLAGS), ) 237 $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) 238 $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \ 239 $$(patsubst %$(OBJ_SUFFIX),%.vardeps,$$($1_$2_OBJ))) 240 endif 241 242 $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO) 243 $$(call LogInfo, Compiling $$(notdir $2) (for $$(notdir $$($1_TARGET)))) 244 $$(call MakeDir, $$(@D)) 245 ifneq ($(TOOLCHAIN_TYPE), microsoft) 246 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) 247 # The Solaris studio compiler doesn't output the full path to the object file in the 248 # generated deps files. Fixing it with sed. If compiling assembly, don't try this. 249 $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \ 250 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) 251 $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) 252 else 253 $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \ 254 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) 255 endif 256 # Create a dependency target file from the dependency file. 257 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ 258 ifneq ($$($1_$2_DEP),) 259 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) 260 endif 261 else 262 # The Visual Studio compiler lacks a feature for generating make dependencies, but by 263 # setting -showIncludes, all included files are printed. These are filtered out and 264 # parsed into make dependences. 265 # Keep as much as possible on one execution line for best performance on Windows. 266 # No need to save exit code from compilation since pipefail is always active on 267 # Windows. 268 $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \ 269 $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ 270 $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \ 271 | $(GREP) -v -e "^Note: including file:" \ 272 -e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \ 273 $(ECHO) $$@: \\ > $$($1_$2_DEP) ; \ 274 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_OBJ).log \ 275 | $(SORT) -u >> $$($1_$2_DEP) ; \ 276 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) 277 endif 278 endif 279 endef 280 281 # Setup make rules for creating a native binary (a shared library or an 282 # executable). 283 # 284 # Parameter 1 is the name of the rule. This name is used as variable prefix, 285 # and the targets generated are listed in a variable by that name. 286 # 287 # Remaining parameters are named arguments. These include: 288 # TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT. 768 769 # If there are many object files, use an @-file... 770 ifneq ($$(word 17, $$($1_ALL_OBJS)), ) 771 $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt 772 ifneq ($(COMPILER_COMMAND_FILE_FLAG),) 773 $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) 774 else 775 # ...except for toolchains which don't support them. 776 $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` 777 endif 778 endif 779 780 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \ 781 $$($1_VARDEPS_FILE) 782 ifneq ($$($1_OBJ_FILE_LIST), ) 783 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) 784 endif 785 # Keep as much as possible on one execution line for best performance 786 # on Windows 787 $$(call LogInfo, Linking $$($1_BASENAME)) 788 ifeq ($(OPENJDK_TARGET_OS), windows) 789 ($(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \ 790 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ 791 $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ 792 $$($1_EXTRA_LIBS)) || echo $$$$? > $$($1_SAFE_NAME).exitvalue ) \ 793 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ 794 test "$$$$?" = "1" ; \ 795 ( test -s $$($1_SAFE_NAME).exitvalue \ 796 && exit `$(CAT) $$($1_SAFE_NAME).exitvalue` || true ) ; \ 797 $$($1_CREATE_DEBUGINFO_CMDS) 798 $$($1_STRIP_CMD) 799 else 800 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \ 801 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ 802 $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ 803 $$($1_EXTRA_LIBS)) ; \ 804 $$($1_CREATE_DEBUGINFO_CMDS) 805 $$($1_STRIP_CMD) 806 endif 807 808 endif 809 810 ifneq (,$$($1_STATIC_LIBRARY)) 811 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \ 812 $$($1_EXTRA_LIBS) 813 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 814 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 815 816 # Generating a static library, ie object file archive. 817 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) 818 $$(call LogInfo, Archiving $$($1_STATIC_LIBRARY)) 819 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \ 820 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ 821 $$($1_RES)) 822 ifeq ($(STATIC_BUILD), true) 823 $(GetSymbols) 824 endif 825 endif 826 827 ifneq (,$$($1_PROGRAM)) 828 # A executable binary has been specified, setup the target for it. 829 $1_EXTRA_LIBS += $(GLOBAL_LIBS) 830 831 $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ 832 $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ 833 $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \ 834 $$($1_STRIP_CMD) 835 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 836 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 837 838 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ 839 $$($1_VARDEPS_FILE) 840 $$(call LogInfo, Linking executable $$($1_BASENAME)) 841 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \ 842 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ 843 $(EXE_OUT_OPTION)$$($1_TARGET) \ 844 $$($1_ALL_OBJS) $$($1_RES) \ 845 $$($1_LIBS) $$($1_EXTRA_LIBS)) 846 ifeq ($(OPENJDK_TARGET_OS), windows) 847 ifneq ($$($1_MANIFEST), ) 848 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_PROGRAM).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 849 endif 850 endif 851 # This only works if the openjdk_codesign identity is present on the system. Let 852 # silently fail otherwise. 853 ifneq (,$(CODESIGN)) 854 ifneq (,$$($1_CODESIGN)) 855 $(CODESIGN) -s openjdk_codesign $$@ 856 endif 857 endif 858 $$($1_CREATE_DEBUGINFO_CMDS) 859 $$($1_STRIP_CMD) 860 861 endif |