You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
9.6 KiB

  1. # Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  2. #
  3. # This file is part of Threading Building Blocks.
  4. #
  5. # Threading Building Blocks is free software; you can redistribute it
  6. # and/or modify it under the terms of the GNU General Public License
  7. # version 2 as published by the Free Software Foundation.
  8. #
  9. # Threading Building Blocks is distributed in the hope that it will be
  10. # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  11. # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with Threading Building Blocks; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. #
  18. # As a special exception, you may use this file as part of a free software
  19. # library without restriction. Specifically, if other files instantiate
  20. # templates or use macros or inline functions from this file, or you compile
  21. # this file and link it with other files to produce an executable, this
  22. # file does not by itself cause the resulting executable to be covered by
  23. # the GNU General Public License. This exception does not however
  24. # invalidate any other reasons why the executable file might be covered by
  25. # the GNU General Public License.
  26. # default target
  27. default_malloc: malloc malloc_test
  28. tbb_root ?= $(TBBROOT)
  29. BUILDING_PHASE=1
  30. TEST_RESOURCE = $(MALLOC.RES)
  31. include $(tbb_root)/build/common.inc
  32. DEBUG_SUFFIX=$(findstring _debug,_$(cfg))
  33. MALLOC_ROOT ?= $(tbb_root)/src/tbbmalloc
  34. MALLOC_SOURCE_ROOT ?= $(MALLOC_ROOT)
  35. VPATH = $(tbb_root)/src/tbb/$(ASSEMBLY_SOURCE) $(tbb_root)/src/tbb $(tbb_root)/src/test
  36. VPATH += $(MALLOC_ROOT) $(MALLOC_SOURCE_ROOT)
  37. CPLUS_FLAGS += $(if $(crosstest),$(DEFINE_KEY)__TBBMALLOC_NO_IMPLICIT_LINKAGE=1)
  38. include $(tbb_root)/build/common_rules.inc
  39. #------------------------------------------------------
  40. # Define rules for making the TBBMalloc shared library.
  41. #------------------------------------------------------
  42. # Object files that make up TBBMalloc
  43. MALLOC_CPLUS.OBJ = backend.$(OBJ) large_objects.$(OBJ) backref.$(OBJ) tbbmalloc.$(OBJ)
  44. MALLOC.OBJ := $(MALLOC_CPLUS.OBJ) $(MALLOC_ASM.OBJ) itt_notify_malloc.$(OBJ) frontend.$(OBJ)
  45. PROXY.OBJ := proxy.$(OBJ) tbb_function_replacement.$(OBJ)
  46. M_CPLUS_FLAGS := $(subst $(WARNING_KEY),,$(M_CPLUS_FLAGS)) $(DEFINE_KEY)__TBBMALLOC_BUILD=1
  47. M_INCLUDES = $(INCLUDES) $(INCLUDE_KEY)$(MALLOC_ROOT) $(INCLUDE_KEY)$(MALLOC_SOURCE_ROOT)
  48. # Suppress superfluous warnings for TBBmalloc compilation
  49. $(MALLOC.OBJ): M_CPLUS_FLAGS += $(WARNING_SUPPRESS)
  50. frontend.$(OBJ): frontend.cpp version_string.ver
  51. $(CPLUS) $(COMPILE_ONLY) $(M_CPLUS_FLAGS) $(PIC_KEY) $(M_INCLUDES) $(INCLUDE_KEY). $<
  52. $(PROXY.OBJ): %.$(OBJ): %.cpp
  53. $(CPLUS) $(COMPILE_ONLY) $(CPLUS_FLAGS) $(PIC_KEY) $(DEFINE_KEY)__TBBMALLOC_BUILD=1 $(M_INCLUDES) $<
  54. $(MALLOC_CPLUS.OBJ): %.$(OBJ): %.cpp
  55. $(CPLUS) $(COMPILE_ONLY) $(M_CPLUS_FLAGS) $(PIC_KEY) $(M_INCLUDES) $<
  56. itt_notify_malloc.$(OBJ): itt_notify.cpp
  57. $(CPLUS) $(COMPILE_ONLY) $(M_CPLUS_FLAGS) $(PIC_KEY) $(OUTPUTOBJ_KEY)$@ $(INCLUDES) $<
  58. MALLOC_LINK_FLAGS = $(LIB_LINK_FLAGS)
  59. PROXY_LINK_FLAGS = $(LIB_LINK_FLAGS)
  60. ifneq (,$(MALLOC.DEF))
  61. tbbmalloc.def: $(MALLOC.DEF)
  62. $(CPLUS) $(PREPROC_ONLY) $< $(CPLUS_FLAGS) $(INCLUDES) > $@
  63. MALLOC_LINK_FLAGS += $(EXPORT_KEY)tbbmalloc.def
  64. $(MALLOC.DLL): tbbmalloc.def
  65. endif
  66. $(MALLOC.DLL): BUILDING_LIBRARY = $(MALLOC.DLL)
  67. $(MALLOC.DLL): $(MALLOC.OBJ) $(MALLOC.RES) $(MALLOC_NO_VERSION.DLL)
  68. $(subst $(CPLUS),$(CONLY),$(LIB_LINK_CMD)) $(LIB_OUTPUT_KEY)$(MALLOC.DLL) $(MALLOC.OBJ) $(MALLOC.RES) $(LIB_LINK_LIBS) $(MALLOC_LINK_FLAGS)
  69. ifneq (,$(MALLOCPROXY.DEF))
  70. tbbmallocproxy.def: $(MALLOCPROXY.DEF)
  71. $(CPLUS) $(PREPROC_ONLY) $< $(CPLUS_FLAGS) $(INCLUDES) > $@
  72. PROXY_LINK_FLAGS += $(EXPORT_KEY)tbbmallocproxy.def
  73. $(MALLOCPROXY.DLL): tbbmallocproxy.def
  74. endif
  75. ifneq (,$(MALLOCPROXY.DLL))
  76. $(MALLOCPROXY.DLL): BUILDING_LIBRARY = $(MALLOCPROXY.DLL)
  77. $(MALLOCPROXY.DLL): $(PROXY.OBJ) $(MALLOCPROXY_NO_VERSION.DLL) $(MALLOC.DLL) $(MALLOC.RES)
  78. $(LIB_LINK_CMD) $(LIB_OUTPUT_KEY)$(MALLOCPROXY.DLL) $(PROXY.OBJ) $(MALLOC.RES) $(LIB_LINK_LIBS) $(LINK_MALLOC_LIB) $(PROXY_LINK_FLAGS)
  79. endif
  80. ifneq (,$(MALLOC_NO_VERSION.DLL))
  81. $(MALLOC_NO_VERSION.DLL):
  82. echo "INPUT ($(MALLOC.DLL))" > $(MALLOC_NO_VERSION.DLL)
  83. endif
  84. ifneq (,$(MALLOCPROXY_NO_VERSION.DLL))
  85. $(MALLOCPROXY_NO_VERSION.DLL):
  86. echo "INPUT ($(MALLOCPROXY.DLL))" > $(MALLOCPROXY_NO_VERSION.DLL)
  87. endif
  88. malloc: $(MALLOC.DLL) $(MALLOCPROXY.DLL)
  89. malloc_dll: $(MALLOC.DLL)
  90. malloc_proxy_dll: $(MALLOCPROXY.DLL)
  91. .PHONY: malloc malloc_dll malloc_proxy_dll
  92. #------------------------------------------------------
  93. # End of rules for making the TBBMalloc shared library
  94. #------------------------------------------------------
  95. #------------------------------------------------------
  96. # Define rules for making the TBBMalloc unit tests
  97. #------------------------------------------------------
  98. add_debug=$(basename $(1))_debug$(suffix $(1))
  99. cross_suffix=$(if $(crosstest),$(if $(DEBUG_SUFFIX),$(subst _debug,,$(1)),$(call add_debug,$(1))),$(1))
  100. MALLOC_MAIN_TESTS = test_ScalableAllocator.$(TEST_EXT) \
  101. test_ScalableAllocator_STL.$(TEST_EXT) \
  102. test_malloc_compliance.$(TEST_EXT) \
  103. test_malloc_regression.$(TEST_EXT) \
  104. test_malloc_init_shutdown.$(TEST_EXT) \
  105. test_malloc_pools.$(TEST_EXT)
  106. MALLOC_OVERLOAD_TESTS = test_malloc_overload.$(TEST_EXT) test_malloc_overload_proxy.$(TEST_EXT) test_malloc_atexit.$(TEST_EXT)
  107. MALLOC_LIB ?= $(call cross_suffix,$(MALLOC.LIB))
  108. MALLOC_PROXY_LIB ?= $(call cross_suffix,$(MALLOCPROXY.LIB))
  109. LINK_MALLOC_LIB ?= $(call cross_suffix,$(LINK_MALLOC.LIB))
  110. LINK_MALLOC_PROXY_LIB ?= $(call cross_suffix,$(LINK_MALLOCPROXY.LIB))
  111. ifeq (windows.gcc,$(tbb_os).$(compiler))
  112. test_malloc_overload.$(TEST_EXT): LIBS += $(MALLOC_PROXY_LIB)
  113. endif
  114. # on Ubuntu 11.10 linker called with --as-needed, so dependence on libtbbmalloc_proxy
  115. # is not created, and malloc overload via linking with -ltbbmalloc_proxy is not working.
  116. # Overcome with --no-as-needed.
  117. ifeq (linux.gcc,$(tbb_os).$(compiler))
  118. test_malloc_atexit.$(TEST_EXT): MALLOC_PROXY_LIB := -Wl,--no-as-needed $(MALLOC_PROXY_LIB)
  119. endif
  120. test_malloc_overload.$(TEST_EXT): test_malloc_overload.cpp
  121. $(CPLUS) $(OUTPUT_KEY)$@ $(subst /MT,/MD,$(M_CPLUS_FLAGS)) $(M_INCLUDES) $< $(LIBDL) $(LIBS) $(LINK_FLAGS)
  122. test_malloc_overload_proxy.$(TEST_EXT): test_malloc_overload.cpp $(MALLOC_PROXY_LIB)
  123. $(CPLUS) $(OUTPUT_KEY)$@ $(subst /MT,/MD,$(M_CPLUS_FLAGS)) $(M_INCLUDES) $< $(LIBDL) $(MALLOC_PROXY_LIB) $(LIBS) $(LINK_FLAGS)
  124. test_malloc_whitebox.$(TEST_EXT): test_malloc_whitebox.cpp $(MALLOC_ASM.OBJ) version_string.ver
  125. $(CPLUS) $(OUTPUT_KEY)$@ $(M_CPLUS_FLAGS) $(M_INCLUDES) $(INCLUDE_KEY). $< $(MALLOC_ASM.OBJ) $(LIBS) $(LIBDL) $(LINK_FLAGS)
  126. test_malloc_lib_unload.$(TEST_EXT): test_malloc_lib_unload.cpp test_malloc_lib_unload_dll.$(DLL)
  127. $(CPLUS) $(OUTPUT_KEY)$@ $(M_CPLUS_FLAGS) $(M_INCLUDES) $< $(LIBS) test_malloc_lib_unload_dll.$(LIBEXT) $(LIBDL) $(LINK_FLAGS)
  128. # TODO: use generic rules
  129. test_malloc_used_by_lib.$(TEST_EXT): test_malloc_used_by_lib.cpp test_malloc_used_by_lib.$(DLL)
  130. $(CPLUS) $(OUTPUT_KEY)$@ $(M_CPLUS_FLAGS) $(M_INCLUDES) $< $(LIBS) $(LIBDL) $(LINK_FLAGS)
  131. test_malloc_used_by_lib.$(DLL): test_malloc_used_by_lib.cpp $(MALLOC_LIB)
  132. $(CPLUS) $(OUTPUT_KEY)$@ $(subst /MT,/LD,$(M_CPLUS_FLAGS)) $(PIC_KEY) $(M_INCLUDES) $(DEFINE_KEY)_USRDLL $< $(LINK_MALLOC_LIB) $(LINK_FLAGS) $(DYLIB_KEY)
  133. $(MALLOC_MAIN_TESTS): %.$(TEST_EXT): %.$(OBJ) $(MALLOC_LIB)
  134. $(CPLUS) $(OUTPUT_KEY)$@ $(CPLUS_FLAGS) $< $(LINK_MALLOC_LIB) $(LIBS) $(LINK_FLAGS)
  135. MALLOC_C_TESTS = test_malloc_pure_c.$(TEST_EXT)
  136. $(MALLOC_C_TESTS): %.$(TEST_EXT): %.$(OBJ) $(MALLOC_LIB)
  137. $(CPLUS) $(OUTPUT_KEY)$@ $(CPLUS_FLAGS) $^ $(LINK_MALLOC_LIB) $(LIBS) $(LINK_FLAGS)
  138. # Rules for generating a test DLL
  139. %_dll.$(DLL): %_dll.$(OBJ)
  140. $(LIB_LINK_CMD) $(OUTPUT_KEY)$@ $(CPLUS_FLAGS) $(PIC_KEY) $< $(LIBS) $(LIBDL) $(LINK_FLAGS) $(DYLIB_KEY)
  141. .PRECIOUS: %_dll.$(OBJ)
  142. test_malloc_atexit.$(TEST_EXT): test_malloc_atexit.$(OBJ) test_malloc_atexit_dll.$(DLL) $(MALLOC_LIB)
  143. $(CPLUS) $(OUTPUT_KEY)$@ $(CPLUS_FLAGS) $< $(MALLOC_PROXY_LIB) $(LINK_MALLOC_LIB) test_malloc_atexit_dll.$(LIBEXT) $(LIBS) $(LINK_FLAGS)
  144. MALLOC_TESTS = $(MALLOC_MAIN_TESTS) $(MALLOC_C_TESTS) test_malloc_whitebox.$(TEST_EXT) test_malloc_used_by_lib.$(TEST_EXT)
  145. ifneq (,$(MALLOCPROXY.DLL))
  146. MALLOC_TESTS += $(MALLOC_OVERLOAD_TESTS) test_malloc_lib_unload.$(TEST_EXT)
  147. endif
  148. # run_cmd is usually empty
  149. malloc_test: $(call cross_suffix,$(MALLOC.DLL)) malloc_test_no_depends
  150. malloc_test_no_depends: $(TEST_PREREQUISITE) $(MALLOC_TESTS)
  151. $(run_cmd) ./test_malloc_pools.$(TEST_EXT) $(args) 1:4
  152. ifneq (,$(MALLOCPROXY.DLL))
  153. $(run_cmd) ./test_malloc_atexit.$(TEST_EXT) $(args)
  154. $(run_cmd) $(TEST_LAUNCHER) test_malloc_lib_unload.$(TEST_EXT) $(args)
  155. $(run_cmd) $(TEST_LAUNCHER) -l $(call cross_suffix,$(MALLOCPROXY.DLL)) test_malloc_overload.$(TEST_EXT) $(args)
  156. $(run_cmd) $(TEST_LAUNCHER) test_malloc_overload_proxy.$(TEST_EXT) $(args)
  157. endif
  158. $(run_cmd) ./test_malloc_used_by_lib.$(TEST_EXT)
  159. $(run_cmd) ./test_malloc_whitebox.$(TEST_EXT) $(args) 1:4
  160. $(run_cmd) $(TEST_LAUNCHER) -u test_malloc_compliance.$(TEST_EXT) $(args) 1:4
  161. $(run_cmd) ./test_ScalableAllocator.$(TEST_EXT) $(args)
  162. $(run_cmd) ./test_ScalableAllocator_STL.$(TEST_EXT) $(args)
  163. $(run_cmd) ./test_malloc_regression.$(TEST_EXT) $(args)
  164. $(run_cmd) ./test_malloc_init_shutdown.$(TEST_EXT) $(args)
  165. $(run_cmd) ./test_malloc_pure_c.$(TEST_EXT) $(args)
  166. #------------------------------------------------------
  167. # End of rules for making the TBBMalloc unit tests
  168. #------------------------------------------------------
  169. # Include automatically generated dependences
  170. -include *.d