380
381 # Setup make rules for creating a native binary (a shared library or an
382 # executable).
383 #
384 # Parameter 1 is the name of the rule. This name is used as variable prefix,
385 # and the targets generated are listed in a variable by that name.
386 #
387 # Remaining parameters are named arguments. These include:
388 # NAME The base name for the resulting binary, excluding decorations (like *.exe)
389 # TYPE Type of binary (EXECUTABLE, LIBRARY or STATIC_LIBRARY). Default is LIBRARY.
390 # SUFFIX Override the default suffix for the output file
391 # TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
392 # SRC one or more directory roots to scan for C/C++ files.
393 # CFLAGS the compiler flags to be used, used both for C and C++.
394 # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.
395 # LDFLAGS the linker flags to be used, used both for C and C++.
396 # LIBS the libraries to link to
397 # ARFLAGS the archiver flags to be used
398 # OBJECT_DIR the directory where we store the object files
399 # OUTPUT_DIR the directory where the resulting binary is put
400 # INCLUDES only pick source from these directories
401 # EXCLUDES do not pick source from these directories
402 # INCLUDE_FILES only compile exactly these files!
403 # EXCLUDE_FILES with these names
404 # EXCLUDE_PATTERN exclude files matching any of these substrings
405 # EXTRA_FILES List of extra files not in any of the SRC dirs
406 # EXTRA_OBJECT_FILES List of extra object files to include when linking
407 # EXTRA_DEPS List of extra dependencies to be added to each compiled file
408 # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
409 # RC_FLAGS flags for RC.
410 # EMBED_MANIFEST if true, embed manifest on Windows.
411 # MAPFILE mapfile
412 # REORDER reorder file
413 # USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
414 # mapfile for the output symbols file
415 # CC the compiler to use, default is $(CC)
416 # LD the linker to use, default is $(LD)
417 # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
418 # DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain
419 # DISABLED_WARNINGS_C_<toolchain> Disable the given warnings for the specified toolchain
494 $1_NOSUFFIX := $$($1_PREFIX)$$($1_NAME)
495 $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
496
497 # Need to make sure TARGET is first on list
498 $1 := $$($1_TARGET)
499
500 # Setup the toolchain to be used
501 $$(call SetIfEmpty, $1_TOOLCHAIN, TOOLCHAIN_DEFAULT)
502 $$(call SetIfEmpty, $1_CC, $$($$($1_TOOLCHAIN)_CC))
503 $$(call SetIfEmpty, $1_CXX, $$($$($1_TOOLCHAIN)_CXX))
504 $$(call SetIfEmpty, $1_LD, $$($$($1_TOOLCHAIN)_LD))
505 $$(call SetIfEmpty, $1_AR, $$($$($1_TOOLCHAIN)_AR))
506 $$(call SetIfEmpty, $1_AS, $$($$($1_TOOLCHAIN)_AS))
507 $$(call SetIfEmpty, $1_MT, $$($$($1_TOOLCHAIN)_MT))
508 $$(call SetIfEmpty, $1_RC, $$($$($1_TOOLCHAIN)_RC))
509 $$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_TOOLCHAIN)_OBJCOPY))
510 $$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP))
511 $$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS))
512 $$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS))
513
514 # Make sure the dirs exist.
515 $$(call MakeDir, $$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
516 $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \
517 $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
518
519 $1_SRCS_RAW := $$(call FindFiles, $$($1_SRC))
520 # Order src files according to the order of the src dirs
521 $1_SRCS := $$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_SRCS_RAW)))
522 $1_SRCS := $$(filter $$(NATIVE_SOURCE_EXTENSIONS), $$($1_SRCS))
523 # Extract the C/C++ files.
524 ifneq ($$($1_EXCLUDE_PATTERNS), )
525 # We must not match the exclude pattern against the src root(s).
526 $1_SRCS_WITHOUT_ROOTS := $$($1_SRCS)
527 $$(foreach i, $$($1_SRC), $$(eval $1_SRCS_WITHOUT_ROOTS := $$(patsubst \
528 $$i/%,%, $$($1_SRCS_WITHOUT_ROOTS))))
529 $1_ALL_EXCLUDE_FILES := $$(call containing, $$($1_EXCLUDE_PATTERNS), \
530 $$($1_SRCS_WITHOUT_ROOTS))
531 endif
532 ifneq ($$($1_EXCLUDE_FILES), )
533 $1_ALL_EXCLUDE_FILES += $$($1_EXCLUDE_FILES)
534 endif
535 ifneq ($$($1_ALL_EXCLUDE_FILES), )
866 endif
867
868 # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
869 # for LDFLAGS and LIBS
870 $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
871 $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
872 ifneq ($$($1_REAL_MAPFILE), )
873 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
874 endif
875
876 ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
877 $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
878 endif
879
880 ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
881 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
882 endif
883
884 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
885 ifneq ($$($1_DEBUG_SYMBOLS), false)
886 # Only copy debug symbols for dynamic libraries and programs.
887 ifneq ($$($1_TYPE), STATIC_LIBRARY)
888 # Generate debuginfo files.
889 ifeq ($(call isTargetOs, windows), true)
890 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
891 "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
892 $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
893 $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
894
895 else ifeq ($(call isTargetOs, linux solaris), true)
896 $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
897 # Setup the command line creating debuginfo files, to be run after linking.
898 # It cannot be run separately since it updates the original target file
899 $1_CREATE_DEBUGINFO_CMDS := \
900 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
901 $(CD) $$($1_OUTPUT_DIR) && \
902 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
903
904 else ifeq ($(call isTargetOs, macosx), true)
905 $1_DEBUGINFO_FILES := \
906 $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
907 $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
908 $1_CREATE_DEBUGINFO_CMDS := \
909 $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
910 endif
911
912 # Since the link rule creates more than one file that we want to track,
913 # we have to use some tricks to get make to cooperate. To properly
914 # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
915 # a recipe in the rule below. To avoid rerunning the recipe every time
916 # have it touch the target. If a debuginfo file is deleted by something
917 # external, explicitly delete the TARGET to trigger a rebuild of both.
918 ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
919 $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
920 $$(shell $(RM) $$($1_TARGET))
921 endif
922 $$($1_DEBUGINFO_FILES): $$($1_TARGET)
923 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
924 $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
925 )
926 $(TOUCH) $$@
927
928 $1 += $$($1_DEBUGINFO_FILES)
929
930 ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
931 $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
932 $1 += $$($1_DEBUGINFO_ZIP)
933
934 # The dependency on TARGET is needed for debuginfo files
935 # to be rebuilt properly.
936 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
937 $(CD) $$($1_OUTPUT_DIR) && \
938 $(ZIPEXE) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
939
940 endif
941 endif # !STATIC_LIBRARY
942 endif # $1_DEBUG_SYMBOLS != false
943 endif # COPY_DEBUG_SYMBOLS
944
945 # Unless specifically set, stripping should only happen if symbols are also
946 # being copied.
947 $$(call SetIfEmpty, $1_STRIP_SYMBOLS, $$($1_COPY_DEBUG_SYMBOLS))
948
949 ifneq ($$($1_STRIP_SYMBOLS), false)
950 ifneq ($$($1_STRIP), )
951 # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
952 $1_STRIPFLAGS ?= $(STRIPFLAGS)
953 $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
954 endif
955 endif
956
957 ifeq ($$($1_TYPE), STATIC_LIBRARY)
958 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
959 $$($1_EXTRA_LIBS)
960 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
961 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
962
963 # Generating a static library, ie object file archive.
964 ifeq ($(STATIC_BUILD), true)
965 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
966 STATIC_MAPFILE_DEP := $$($1_MAPFILE)
967 endif
968 endif
969
970 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
971
972 $$($1_TARGET): $$($1_TARGET_DEPS)
973 $$(call LogInfo, Building static library $$($1_BASENAME))
974 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
975 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
976 $$($1_RES))
977 ifeq ($(STATIC_BUILD), true)
978 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
979 $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
980 else
981 $(GetSymbols)
982 endif
983 endif
984 else
985 # A shared dynamic library or an executable binary has been specified
986 ifeq ($$($1_TYPE), LIBRARY)
987 # Generating a dynamic library.
988 $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
989
990 # Create loadmap on AIX. Helps in diagnosing some problems.
991 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
992 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
993 endif
1055 $1_LINK_OBJS_RELATIVE := true
1056 $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
1057 endif
1058 endif
1059 endif
1060
1061 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
1062 $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
1063
1064 $$($1_TARGET): $$($1_TARGET_DEPS)
1065 ifneq ($$($1_OBJ_FILE_LIST), )
1066 ifeq ($$($1_LINK_OBJS_RELATIVE), true)
1067 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
1068 else
1069 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
1070 endif
1071 endif
1072 # Keep as much as possible on one execution line for best performance
1073 # on Windows
1074 $$(call LogInfo, Linking $$($1_BASENAME))
1075 ifeq ($(call isTargetOs, windows), true)
1076 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1077 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1078 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1079 $$($1_LIBS) $$($1_EXTRA_LIBS)) \
1080 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \
1081 test "$$$$?" = "1" ; \
1082 $$($1_CREATE_DEBUGINFO_CMDS)
1083 $$($1_STRIP_CMD)
1084 else
1085 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1086 $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
1087 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1088 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1089 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
1090 $$($1_CREATE_DEBUGINFO_CMDS)
1091 $$($1_STRIP_CMD)
1092 endif
1093 ifeq ($(call isTargetOs, windows), true)
1094 ifneq ($$($1_MANIFEST), )
1095 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
|
380
381 # Setup make rules for creating a native binary (a shared library or an
382 # executable).
383 #
384 # Parameter 1 is the name of the rule. This name is used as variable prefix,
385 # and the targets generated are listed in a variable by that name.
386 #
387 # Remaining parameters are named arguments. These include:
388 # NAME The base name for the resulting binary, excluding decorations (like *.exe)
389 # TYPE Type of binary (EXECUTABLE, LIBRARY or STATIC_LIBRARY). Default is LIBRARY.
390 # SUFFIX Override the default suffix for the output file
391 # TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
392 # SRC one or more directory roots to scan for C/C++ files.
393 # CFLAGS the compiler flags to be used, used both for C and C++.
394 # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.
395 # LDFLAGS the linker flags to be used, used both for C and C++.
396 # LIBS the libraries to link to
397 # ARFLAGS the archiver flags to be used
398 # OBJECT_DIR the directory where we store the object files
399 # OUTPUT_DIR the directory where the resulting binary is put
400 # SYMBOLS_DIR the directory where the debug symbols are put, defaults to OUTPUT_DIR
401 # INCLUDES only pick source from these directories
402 # EXCLUDES do not pick source from these directories
403 # INCLUDE_FILES only compile exactly these files!
404 # EXCLUDE_FILES with these names
405 # EXCLUDE_PATTERN exclude files matching any of these substrings
406 # EXTRA_FILES List of extra files not in any of the SRC dirs
407 # EXTRA_OBJECT_FILES List of extra object files to include when linking
408 # EXTRA_DEPS List of extra dependencies to be added to each compiled file
409 # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
410 # RC_FLAGS flags for RC.
411 # EMBED_MANIFEST if true, embed manifest on Windows.
412 # MAPFILE mapfile
413 # REORDER reorder file
414 # USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
415 # mapfile for the output symbols file
416 # CC the compiler to use, default is $(CC)
417 # LD the linker to use, default is $(LD)
418 # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
419 # DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain
420 # DISABLED_WARNINGS_C_<toolchain> Disable the given warnings for the specified toolchain
495 $1_NOSUFFIX := $$($1_PREFIX)$$($1_NAME)
496 $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
497
498 # Need to make sure TARGET is first on list
499 $1 := $$($1_TARGET)
500
501 # Setup the toolchain to be used
502 $$(call SetIfEmpty, $1_TOOLCHAIN, TOOLCHAIN_DEFAULT)
503 $$(call SetIfEmpty, $1_CC, $$($$($1_TOOLCHAIN)_CC))
504 $$(call SetIfEmpty, $1_CXX, $$($$($1_TOOLCHAIN)_CXX))
505 $$(call SetIfEmpty, $1_LD, $$($$($1_TOOLCHAIN)_LD))
506 $$(call SetIfEmpty, $1_AR, $$($$($1_TOOLCHAIN)_AR))
507 $$(call SetIfEmpty, $1_AS, $$($$($1_TOOLCHAIN)_AS))
508 $$(call SetIfEmpty, $1_MT, $$($$($1_TOOLCHAIN)_MT))
509 $$(call SetIfEmpty, $1_RC, $$($$($1_TOOLCHAIN)_RC))
510 $$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_TOOLCHAIN)_OBJCOPY))
511 $$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP))
512 $$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS))
513 $$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS))
514
515 $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \
516 $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
517
518 $1_SRCS_RAW := $$(call FindFiles, $$($1_SRC))
519 # Order src files according to the order of the src dirs
520 $1_SRCS := $$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_SRCS_RAW)))
521 $1_SRCS := $$(filter $$(NATIVE_SOURCE_EXTENSIONS), $$($1_SRCS))
522 # Extract the C/C++ files.
523 ifneq ($$($1_EXCLUDE_PATTERNS), )
524 # We must not match the exclude pattern against the src root(s).
525 $1_SRCS_WITHOUT_ROOTS := $$($1_SRCS)
526 $$(foreach i, $$($1_SRC), $$(eval $1_SRCS_WITHOUT_ROOTS := $$(patsubst \
527 $$i/%,%, $$($1_SRCS_WITHOUT_ROOTS))))
528 $1_ALL_EXCLUDE_FILES := $$(call containing, $$($1_EXCLUDE_PATTERNS), \
529 $$($1_SRCS_WITHOUT_ROOTS))
530 endif
531 ifneq ($$($1_EXCLUDE_FILES), )
532 $1_ALL_EXCLUDE_FILES += $$($1_EXCLUDE_FILES)
533 endif
534 ifneq ($$($1_ALL_EXCLUDE_FILES), )
865 endif
866
867 # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
868 # for LDFLAGS and LIBS
869 $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
870 $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
871 ifneq ($$($1_REAL_MAPFILE), )
872 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
873 endif
874
875 ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
876 $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
877 endif
878
879 ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
880 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
881 endif
882
883 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
884 ifneq ($$($1_DEBUG_SYMBOLS), false)
885 $$(call SetIfEmpty, $1_SYMBOLS_DIR, $$($1_OUTPUT_DIR))
886 # Only copy debug symbols for dynamic libraries and programs.
887 ifneq ($$($1_TYPE), STATIC_LIBRARY)
888 # Generate debuginfo files.
889 ifeq ($(call isTargetOs, windows), true)
890 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \
891 "-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map"
892 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \
893 $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map
894
895 else ifeq ($(call isTargetOs, linux solaris), true)
896 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
897 # Setup the command line creating debuginfo files, to be run after linking.
898 # It cannot be run separately since it updates the original target file
899 $1_CREATE_DEBUGINFO_CMDS := \
900 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
901 $(CD) $$($1_SYMBOLS_DIR) && \
902 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
903
904 else ifeq ($(call isTargetOs, macosx), true)
905 $1_DEBUGINFO_FILES := \
906 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
907 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
908 $1_CREATE_DEBUGINFO_CMDS := \
909 $(DSYMUTIL) --out $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
910 endif
911
912 # Since the link rule creates more than one file that we want to track,
913 # we have to use some tricks to get make to cooperate. To properly
914 # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
915 # a recipe in the rule below. To avoid rerunning the recipe every time
916 # have it touch the target. If a debuginfo file is deleted by something
917 # external, explicitly delete the TARGET to trigger a rebuild of both.
918 ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
919 $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
920 $$(shell $(RM) $$($1_TARGET))
921 endif
922 $$($1_DEBUGINFO_FILES): $$($1_TARGET)
923 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
924 $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
925 )
926 $(TOUCH) $$@
927
928 $1 += $$($1_DEBUGINFO_FILES)
929
930 ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
931 $1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
932 $1 += $$($1_DEBUGINFO_ZIP)
933
934 # The dependency on TARGET is needed for debuginfo files
935 # to be rebuilt properly.
936 $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
937 $(CD) $$($1_SYMBOLS_DIR) && \
938 $(ZIPEXE) -q -r $$@ $$(subst $$($1_SYMBOLS_DIR)/,, $$($1_DEBUGINFO_FILES))
939
940 endif
941 endif # !STATIC_LIBRARY
942 endif # $1_DEBUG_SYMBOLS != false
943 endif # COPY_DEBUG_SYMBOLS
944
945 # Unless specifically set, stripping should only happen if symbols are also
946 # being copied.
947 $$(call SetIfEmpty, $1_STRIP_SYMBOLS, $$($1_COPY_DEBUG_SYMBOLS))
948
949 ifneq ($$($1_STRIP_SYMBOLS), false)
950 ifneq ($$($1_STRIP), )
951 # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
952 $1_STRIPFLAGS ?= $(STRIPFLAGS)
953 $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
954 endif
955 endif
956
957 ifeq ($$($1_TYPE), STATIC_LIBRARY)
958 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
959 $$($1_EXTRA_LIBS)
960 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
961 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
962
963 # Generating a static library, ie object file archive.
964 ifeq ($(STATIC_BUILD), true)
965 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
966 STATIC_MAPFILE_DEP := $$($1_MAPFILE)
967 endif
968 endif
969
970 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
971
972 $$($1_TARGET): $$($1_TARGET_DEPS)
973 $$(call LogInfo, Building static library $$($1_BASENAME))
974 $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
975 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
976 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
977 $$($1_RES))
978 ifeq ($(STATIC_BUILD), true)
979 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
980 $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
981 else
982 $(GetSymbols)
983 endif
984 endif
985 else
986 # A shared dynamic library or an executable binary has been specified
987 ifeq ($$($1_TYPE), LIBRARY)
988 # Generating a dynamic library.
989 $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
990
991 # Create loadmap on AIX. Helps in diagnosing some problems.
992 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
993 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
994 endif
1056 $1_LINK_OBJS_RELATIVE := true
1057 $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
1058 endif
1059 endif
1060 endif
1061
1062 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
1063 $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
1064
1065 $$($1_TARGET): $$($1_TARGET_DEPS)
1066 ifneq ($$($1_OBJ_FILE_LIST), )
1067 ifeq ($$($1_LINK_OBJS_RELATIVE), true)
1068 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
1069 else
1070 $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
1071 endif
1072 endif
1073 # Keep as much as possible on one execution line for best performance
1074 # on Windows
1075 $$(call LogInfo, Linking $$($1_BASENAME))
1076 $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
1077 ifeq ($(call isTargetOs, windows), true)
1078
1079 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1080 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1081 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1082 $$($1_LIBS) $$($1_EXTRA_LIBS)) \
1083 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \
1084 test "$$$$?" = "1" ; \
1085 $$($1_CREATE_DEBUGINFO_CMDS)
1086 $$($1_STRIP_CMD)
1087 else
1088 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
1089 $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
1090 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
1091 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
1092 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
1093 $$($1_CREATE_DEBUGINFO_CMDS)
1094 $$($1_STRIP_CMD)
1095 endif
1096 ifeq ($(call isTargetOs, windows), true)
1097 ifneq ($$($1_MANIFEST), )
1098 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
|