173 $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \ |
173 $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \ |
174 $(patsubst $(extension),%$(OBJ_SUFFIX), $(filter $(extension), $1))) \ |
174 $(patsubst $(extension),%$(OBJ_SUFFIX), $(filter $(extension), $1))) \ |
175 ) |
175 ) |
176 endef |
176 endef |
177 |
177 |
178 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) |
178 ifeq ($(call isBuildOsEnv, windows.cygwin), true) |
179 UNIX_PATH_PREFIX := /cygdrive |
179 UNIX_PATH_PREFIX := /cygdrive |
180 else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) |
180 else ifeq ($(call isBuildOsEnv, windows.msys), true) |
181 UNIX_PATH_PREFIX := |
181 UNIX_PATH_PREFIX := |
182 endif |
182 endif |
183 |
183 |
184 # This pattern is used to transform the output of the microsoft CL compiler |
184 # This pattern is used to transform the output of the microsoft CL compiler |
185 # into a make syntax dependency file (.d) |
185 # into a make syntax dependency file (.d) |
388 # LDFLAGS the linker flags to be used, used both for C and C++. |
388 # LDFLAGS the linker flags to be used, used both for C and C++. |
389 # LIBS the libraries to link to |
389 # LIBS the libraries to link to |
390 # ARFLAGS the archiver flags to be used |
390 # ARFLAGS the archiver flags to be used |
391 # OBJECT_DIR the directory where we store the object files |
391 # OBJECT_DIR the directory where we store the object files |
392 # OUTPUT_DIR the directory where the resulting binary is put |
392 # OUTPUT_DIR the directory where the resulting binary is put |
393 # SYMBOLS_DIR the directory where the debug symbols are put, defaults to OUTPUT_DIR |
|
394 # INCLUDES only pick source from these directories |
393 # INCLUDES only pick source from these directories |
395 # EXCLUDES do not pick source from these directories |
394 # EXCLUDES do not pick source from these directories |
396 # INCLUDE_FILES only compile exactly these files! |
395 # INCLUDE_FILES only compile exactly these files! |
397 # EXCLUDE_FILES with these names |
396 # EXCLUDE_FILES with these names |
398 # EXCLUDE_PATTERN exclude files matching any of these substrings |
397 # EXCLUDE_PATTERN exclude files matching any of these substrings |
499 $$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_TOOLCHAIN)_OBJCOPY)) |
498 $$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_TOOLCHAIN)_OBJCOPY)) |
500 $$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP)) |
499 $$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP)) |
501 $$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS)) |
500 $$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS)) |
502 $$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS)) |
501 $$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS)) |
503 |
502 |
|
503 # Make sure the dirs exist. |
|
504 $$(call MakeDir, $$($1_OBJECT_DIR) $$($1_OUTPUT_DIR)) |
504 $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \ |
505 $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \ |
505 $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d))) |
506 $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d))) |
506 |
507 |
507 # Find all files in the source trees. Preserve order. |
508 # Find all files in the source trees. Preserve order. |
508 $1_SRCS := $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s))) |
509 $1_SRCS := $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s))) |
767 $$(if $$(filter %.vardeps, $$?), 'due to makefile changes'))) |
768 $$(if $$(filter %.vardeps, $$?), 'due to makefile changes'))) |
768 endif |
769 endif |
769 $(TOUCH) $$@ |
770 $(TOUCH) $$@ |
770 |
771 |
771 # On windows we need to create a resource file |
772 # On windows we need to create a resource file |
772 ifeq ($(OPENJDK_TARGET_OS), windows) |
773 ifeq ($(call isTargetOs, windows), true) |
773 ifneq ($$($1_VERSIONINFO_RESOURCE), ) |
774 ifneq ($$($1_VERSIONINFO_RESOURCE), ) |
774 $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res |
775 $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res |
775 $1_RES_DEP := $$($1_RES).d |
776 $1_RES_DEP := $$($1_RES).d |
776 $1_RES_DEP_TARGETS := $$($1_RES).d.targets |
777 $1_RES_DEP_TARGETS := $$($1_RES).d.targets |
777 -include $$($1_RES_DEP) |
778 -include $$($1_RES_DEP) |
805 endif |
806 endif |
806 endif |
807 endif |
807 |
808 |
808 ifneq ($(DISABLE_MAPFILES), true) |
809 ifneq ($(DISABLE_MAPFILES), true) |
809 $1_REAL_MAPFILE := $$($1_MAPFILE) |
810 $1_REAL_MAPFILE := $$($1_MAPFILE) |
810 ifneq ($(OPENJDK_TARGET_OS), windows) |
811 ifeq ($(call isTargetOs, windows), false) |
811 ifneq ($$($1_REORDER), ) |
812 ifneq ($$($1_REORDER), ) |
812 $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile |
813 $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile |
813 |
814 |
814 $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) |
815 $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) |
815 $$(call MakeDir, $$(@D)) |
816 $$(call MakeDir, $$(@D)) |
839 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS) |
840 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS) |
840 endif |
841 endif |
841 |
842 |
842 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true) |
843 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true) |
843 ifneq ($$($1_DEBUG_SYMBOLS), false) |
844 ifneq ($$($1_DEBUG_SYMBOLS), false) |
844 $$(call SetIfEmpty, $1_SYMBOLS_DIR, $$($1_OUTPUT_DIR)) |
|
845 # Only copy debug symbols for dynamic libraries and programs. |
845 # Only copy debug symbols for dynamic libraries and programs. |
846 ifneq ($$($1_TYPE), STATIC_LIBRARY) |
846 ifneq ($$($1_TYPE), STATIC_LIBRARY) |
847 # Generate debuginfo files. |
847 # Generate debuginfo files. |
848 ifeq ($(OPENJDK_TARGET_OS), windows) |
848 ifeq ($(call isTargetOs, windows), true) |
849 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \ |
849 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \ |
850 "-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map" |
850 "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map" |
851 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \ |
851 $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \ |
852 $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map |
852 $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map |
853 |
853 |
854 else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) |
854 else ifeq ($(call isTargetOs, linux solaris), true) |
855 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo |
855 $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo |
856 # Setup the command line creating debuginfo files, to be run after linking. |
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 |
857 # It cannot be run separately since it updates the original target file |
858 $1_CREATE_DEBUGINFO_CMDS := \ |
858 $1_CREATE_DEBUGINFO_CMDS := \ |
859 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ |
859 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ |
860 $(CD) $$($1_SYMBOLS_DIR) && \ |
860 $(CD) $$($1_OUTPUT_DIR) && \ |
861 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) |
861 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) |
862 |
862 |
863 else ifeq ($(OPENJDK_TARGET_OS), macosx) |
863 else ifeq ($(call isTargetOs, macosx), true) |
864 $1_DEBUGINFO_FILES := \ |
864 $1_DEBUGINFO_FILES := \ |
865 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \ |
865 $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \ |
866 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME) |
866 $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME) |
867 $1_CREATE_DEBUGINFO_CMDS := \ |
867 $1_CREATE_DEBUGINFO_CMDS := \ |
868 $(DSYMUTIL) --out $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) |
868 $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) |
869 endif # OPENJDK_TARGET_OS |
869 endif |
870 |
870 |
871 # Since the link rule creates more than one file that we want to track, |
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 |
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 |
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 |
874 # a recipe in the rule below. To avoid rerunning the recipe every time |
885 $(TOUCH) $$@ |
885 $(TOUCH) $$@ |
886 |
886 |
887 $1 += $$($1_DEBUGINFO_FILES) |
887 $1 += $$($1_DEBUGINFO_FILES) |
888 |
888 |
889 ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true) |
889 ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true) |
890 $1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz |
890 $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz |
891 $1 += $$($1_DEBUGINFO_ZIP) |
891 $1 += $$($1_DEBUGINFO_ZIP) |
892 |
892 |
893 # The dependency on TARGET is needed for debuginfo files |
893 # The dependency on TARGET is needed for debuginfo files |
894 # to be rebuilt properly. |
894 # to be rebuilt properly. |
895 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) |
895 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) |
896 $(CD) $$($1_SYMBOLS_DIR) && \ |
896 $(CD) $$($1_OUTPUT_DIR) && \ |
897 $(ZIPEXE) -q -r $$@ $$(subst $$($1_SYMBOLS_DIR)/,, $$($1_DEBUGINFO_FILES)) |
897 $(ZIPEXE) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES)) |
898 |
898 |
899 endif |
899 endif |
900 endif # !STATIC_LIBRARY |
900 endif # !STATIC_LIBRARY |
901 endif # $1_DEBUG_SYMBOLS != false |
901 endif # $1_DEBUG_SYMBOLS != false |
902 endif # COPY_DEBUG_SYMBOLS |
902 endif # COPY_DEBUG_SYMBOLS |
928 |
928 |
929 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) |
929 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) |
930 |
930 |
931 $$($1_TARGET): $$($1_TARGET_DEPS) |
931 $$($1_TARGET): $$($1_TARGET_DEPS) |
932 $$(call LogInfo, Building static library $$($1_BASENAME)) |
932 $$(call LogInfo, Building static library $$($1_BASENAME)) |
933 $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) |
|
934 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
933 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
935 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ |
934 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ |
936 $$($1_RES)) |
935 $$($1_RES)) |
937 ifeq ($(STATIC_BUILD), true) |
936 ifeq ($(STATIC_BUILD), true) |
938 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
937 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
951 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), ) |
950 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), ) |
952 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap |
951 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap |
953 endif |
952 endif |
954 endif |
953 endif |
955 |
954 |
956 ifeq ($(OPENJDK_TARGET_OS), windows) |
955 ifeq ($(call isTargetOs, windows), true) |
957 ifeq ($$($1_EMBED_MANIFEST), true) |
956 ifeq ($$($1_EMBED_MANIFEST), true) |
958 $1_EXTRA_LDFLAGS += -manifest:embed |
957 $1_EXTRA_LDFLAGS += -manifest:embed |
959 endif |
958 endif |
960 |
959 |
961 $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib |
960 $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib |
1031 endif |
1030 endif |
1032 endif |
1031 endif |
1033 # Keep as much as possible on one execution line for best performance |
1032 # Keep as much as possible on one execution line for best performance |
1034 # on Windows |
1033 # on Windows |
1035 $$(call LogInfo, Linking $$($1_BASENAME)) |
1034 $$(call LogInfo, Linking $$($1_BASENAME)) |
1036 $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) |
1035 ifeq ($(call isTargetOs, windows), true) |
1037 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
1038 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
1036 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
1039 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
1037 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
1040 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
1038 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
1041 $$($1_LIBS) $$($1_EXTRA_LIBS)) \ |
1039 $$($1_LIBS) $$($1_EXTRA_LIBS)) \ |
1042 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ |
1040 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ |
1050 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
1048 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
1051 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \ |
1049 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \ |
1052 $$($1_CREATE_DEBUGINFO_CMDS) |
1050 $$($1_CREATE_DEBUGINFO_CMDS) |
1053 $$($1_STRIP_CMD) |
1051 $$($1_STRIP_CMD) |
1054 endif |
1052 endif |
1055 ifeq ($(OPENJDK_TARGET_OS), windows) |
1053 ifeq ($(call isTargetOs, windows), true) |
1056 ifneq ($$($1_MANIFEST), ) |
1054 ifneq ($$($1_MANIFEST), ) |
1057 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 |
1055 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 |
1058 endif |
1056 endif |
1059 endif |
1057 endif |
1060 # This only works if the openjdk_codesign identity is present on the system. Let |
1058 # This only works if the openjdk_codesign identity is present on the system. Let |