222 # dependency files to contain paths compatible with make.
223 #
224 ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)-$(FILE_MACRO_CFLAGS), false-)
225 # Need to handle -I flags as both '-Ifoo' and '-I foo'.
226 MakeCommandRelative = \
227 $(CD) $(WORKSPACE_ROOT) && \
228 $(foreach o, $1, \
229 $(if $(filter $(WORKSPACE_ROOT)/% $(OUTPUTDIR)/%, $o), \
230 $(call RelativePath, $o, $(WORKSPACE_ROOT)) \
231 , \
232 $(if $(filter -I$(WORKSPACE_ROOT)/%, $o), \
233 -I$(call RelativePath, $(patsubst -I%, %, $o), $(WORKSPACE_ROOT)) \
234 , \
235 $o \
236 ) \
237 ) \
238 )
239
240 # When compiling with relative paths, the deps file comes out with relative
241 # paths.
242 ifeq ($(TOOLCHAIN_TYPE), solstudio)
243 define fix-deps-file
244 $(SED) -e 's|\./|$(WORKSPACE_ROOT)/|g' $1.tmp > $1
245 endef
246 else
247 define fix-deps-file
248 $(SED) -e 's|^\([ ]*\)|\1$(WORKSPACE_ROOT)|' $1.tmp > $1
249 endef
250 endif
251 else
252 # By default the MakeCommandRelative macro does nothing.
253 MakeCommandRelative = $1
254
255 # Even with absolute paths on the command line, the Solaris studio compiler
256 # doesn't output the full path to the object file in the generated deps files.
257 # For other toolchains, no adjustment is needed.
258 ifeq ($(TOOLCHAIN_TYPE), solstudio)
259 define fix-deps-file
260 $(SED) 's|^$$(@F):|$$@:|' $1.tmp > $1
261 endef
262 else
263 define fix-deps-file
264 $(MV) $1.tmp $1
265 endef
266 endif
267 endif
268
269 ################################################################################
270 # Create the recipe needed to compile a single native source file.
271 #
272 # Parameter 1 is the name of the rule, based on the name of the library/
273 # program being build and the name of the source code file, e.g.
274 # BUILD_LIBFOO_fooMain.cpp.
275 #
276 # Remaining parameters are named arguments:
277 # FILE - The full path of the source file to compiler
278 # BASE - The name of the rule for the entire binary to build ($1)
279 #
280 SetupCompileNativeFile = $(NamedParamsMacroTemplate)
281 define SetupCompileNativeFileBody
282 $1_FILENAME := $$(notdir $$($1_FILE))
283
284 # The target file to be generated.
285 $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \
286 $$($1_FILENAME))
682 ifeq ($(STATIC_LIBS), true)
683 $1_EXTRA_CXXFLAGS += $$(STATIC_LIB_CFLAGS)
684 endif
685
686 # If no C++ flags are explicitly set, default to using the C flags.
687 # After that, we can set additional C++ flags that should not interfere
688 # with the mechanism for copying the C flags by default.
689 ifeq ($$($1_CXXFLAGS), )
690 $1_CXXFLAGS := $$($1_CFLAGS)
691 endif
692 ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
693 $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
694 endif
695
696 ifeq ($$($1_COMPILE_WITH_DEBUG_SYMBOLS), true)
697 $1_EXTRA_CFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
698 $1_EXTRA_CXXFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
699 $1_EXTRA_ASFLAGS += $$(ASFLAGS_DEBUG_SYMBOLS)
700 endif
701
702 ifneq ($$($1_REORDER), )
703 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
704 $1_EXTRA_CXXFLAGS += $$(C_FLAG_REORDER)
705 endif
706
707 # Pass the library name for static JNI library naming
708 ifeq ($$($1_TYPE), STATIC_LIBRARY)
709 $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
710 $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_NAME)
711 endif
712
713 # Pick up disabled warnings, if possible on this platform.
714 ifneq ($(DISABLE_WARNING_PREFIX), )
715 $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
716 $$(DISABLED_WARNINGS) \
717 $$(DISABLED_WARNINGS_C) \
718 $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
719 $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)))
720 $1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
721 $$(DISABLED_WARNINGS) \
722 $$(DISABLED_WARNINGS_CXX) \
723 $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
724 $$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)))
725 endif
726
956
957 ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
958 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
959 endif
960
961 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
962 ifneq ($$($1_DEBUG_SYMBOLS), false)
963 $$(call SetIfEmpty, $1_SYMBOLS_DIR, $$($1_OUTPUT_DIR))
964 # Only copy debug symbols for dynamic libraries and programs.
965 ifneq ($$($1_TYPE), STATIC_LIBRARY)
966 # Generate debuginfo files.
967 ifeq ($(call isTargetOs, windows), true)
968 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \
969 "-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map"
970 ifeq ($(SHIP_DEBUG_SYMBOLS), public)
971 $1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).stripped.pdb"
972 endif
973 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \
974 $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map
975
976 else ifeq ($(call isTargetOs, linux solaris), true)
977 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
978 # Setup the command line creating debuginfo files, to be run after linking.
979 # It cannot be run separately since it updates the original target file
980 $1_CREATE_DEBUGINFO_CMDS := \
981 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
982 $(CD) $$($1_SYMBOLS_DIR) && \
983 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
984
985 else ifeq ($(call isTargetOs, macosx), true)
986 $1_DEBUGINFO_FILES := \
987 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
988 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
989 $1_CREATE_DEBUGINFO_CMDS := \
990 $(DSYMUTIL) --out $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
991 endif
992
993 # Since the link rule creates more than one file that we want to track,
994 # we have to use some tricks to get make to cooperate. To properly
995 # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
996 # a recipe in the rule below. To avoid rerunning the recipe every time
|
222 # dependency files to contain paths compatible with make.
223 #
224 ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)-$(FILE_MACRO_CFLAGS), false-)
225 # Need to handle -I flags as both '-Ifoo' and '-I foo'.
226 MakeCommandRelative = \
227 $(CD) $(WORKSPACE_ROOT) && \
228 $(foreach o, $1, \
229 $(if $(filter $(WORKSPACE_ROOT)/% $(OUTPUTDIR)/%, $o), \
230 $(call RelativePath, $o, $(WORKSPACE_ROOT)) \
231 , \
232 $(if $(filter -I$(WORKSPACE_ROOT)/%, $o), \
233 -I$(call RelativePath, $(patsubst -I%, %, $o), $(WORKSPACE_ROOT)) \
234 , \
235 $o \
236 ) \
237 ) \
238 )
239
240 # When compiling with relative paths, the deps file comes out with relative
241 # paths.
242 define fix-deps-file
243 $(SED) -e 's|^\([ ]*\)|\1$(WORKSPACE_ROOT)|' $1.tmp > $1
244 endef
245 else
246 # By default the MakeCommandRelative macro does nothing.
247 MakeCommandRelative = $1
248
249 # No adjustment is needed.
250 define fix-deps-file
251 $(MV) $1.tmp $1
252 endef
253 endif
254
255 ################################################################################
256 # Create the recipe needed to compile a single native source file.
257 #
258 # Parameter 1 is the name of the rule, based on the name of the library/
259 # program being build and the name of the source code file, e.g.
260 # BUILD_LIBFOO_fooMain.cpp.
261 #
262 # Remaining parameters are named arguments:
263 # FILE - The full path of the source file to compiler
264 # BASE - The name of the rule for the entire binary to build ($1)
265 #
266 SetupCompileNativeFile = $(NamedParamsMacroTemplate)
267 define SetupCompileNativeFileBody
268 $1_FILENAME := $$(notdir $$($1_FILE))
269
270 # The target file to be generated.
271 $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \
272 $$($1_FILENAME))
668 ifeq ($(STATIC_LIBS), true)
669 $1_EXTRA_CXXFLAGS += $$(STATIC_LIB_CFLAGS)
670 endif
671
672 # If no C++ flags are explicitly set, default to using the C flags.
673 # After that, we can set additional C++ flags that should not interfere
674 # with the mechanism for copying the C flags by default.
675 ifeq ($$($1_CXXFLAGS), )
676 $1_CXXFLAGS := $$($1_CFLAGS)
677 endif
678 ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
679 $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
680 endif
681
682 ifeq ($$($1_COMPILE_WITH_DEBUG_SYMBOLS), true)
683 $1_EXTRA_CFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
684 $1_EXTRA_CXXFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
685 $1_EXTRA_ASFLAGS += $$(ASFLAGS_DEBUG_SYMBOLS)
686 endif
687
688 # Pass the library name for static JNI library naming
689 ifeq ($$($1_TYPE), STATIC_LIBRARY)
690 $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
691 $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_NAME)
692 endif
693
694 # Pick up disabled warnings, if possible on this platform.
695 ifneq ($(DISABLE_WARNING_PREFIX), )
696 $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
697 $$(DISABLED_WARNINGS) \
698 $$(DISABLED_WARNINGS_C) \
699 $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
700 $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)))
701 $1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
702 $$(DISABLED_WARNINGS) \
703 $$(DISABLED_WARNINGS_CXX) \
704 $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
705 $$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)))
706 endif
707
937
938 ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
939 $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
940 endif
941
942 ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
943 ifneq ($$($1_DEBUG_SYMBOLS), false)
944 $$(call SetIfEmpty, $1_SYMBOLS_DIR, $$($1_OUTPUT_DIR))
945 # Only copy debug symbols for dynamic libraries and programs.
946 ifneq ($$($1_TYPE), STATIC_LIBRARY)
947 # Generate debuginfo files.
948 ifeq ($(call isTargetOs, windows), true)
949 $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \
950 "-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map"
951 ifeq ($(SHIP_DEBUG_SYMBOLS), public)
952 $1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).stripped.pdb"
953 endif
954 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \
955 $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map
956
957 else ifeq ($(call isTargetOs, linux), true)
958 $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
959 # Setup the command line creating debuginfo files, to be run after linking.
960 # It cannot be run separately since it updates the original target file
961 $1_CREATE_DEBUGINFO_CMDS := \
962 $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
963 $(CD) $$($1_SYMBOLS_DIR) && \
964 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
965
966 else ifeq ($(call isTargetOs, macosx), true)
967 $1_DEBUGINFO_FILES := \
968 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
969 $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
970 $1_CREATE_DEBUGINFO_CMDS := \
971 $(DSYMUTIL) --out $$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
972 endif
973
974 # Since the link rule creates more than one file that we want to track,
975 # we have to use some tricks to get make to cooperate. To properly
976 # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
977 # a recipe in the rule below. To avoid rerunning the recipe every time
|