1 # Copyright (c) 2005-2019 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 ifeq ($(tbb_strict),1)
17 ifeq ($(WARNING_AS_ERROR_KEY),)
18 $(error WARNING_AS_ERROR_KEY is empty)
20 # Do not remove line below!
21 WARNING_KEY += $(WARNING_AS_ERROR_KEY)
24 ifneq (,$(findstring s,$(MAKEFLAGS)))
28 override largs+=-r $(repeat)
30 ifneq (,$(largs)$(run_prefix))
31 override run_cmd:=$(run_cmd) $(TEST_LAUNCHER)
33 ifeq (,$(strip $(run_cmd)))
34 $(warning Test launcher is not defined for the platform, ignoring launcher arguments)
42 INCLUDES += $(INCLUDE_KEY)$(tbb_root)/src $(INCLUDE_KEY)$(tbb_root)/src/rml/include $(INCLUDE_KEY)$(tbb_root)/include
44 CPLUS_FLAGS += $(WARNING_KEY) $(CXXFLAGS)
46 CPLUS_FLAGS += $(DEFINE_KEY)__TBB_CPF_BUILD=1
48 ifeq (0,$(exceptions))
49 CPLUS_FLAGS += $(DEFINE_KEY)TBB_USE_EXCEPTIONS=0
51 LINK_FLAGS += $(LDFLAGS)
52 LIB_LINK_FLAGS += $(LDFLAGS)
54 LIB_LINK_CMD ?= $(CPLUS) $(PIC_KEY)
55 ifeq ($(origin LIB_OUTPUT_KEY), undefined)
56 LIB_OUTPUT_KEY = $(OUTPUT_KEY)
58 ifeq ($(origin LIB_LINK_LIBS), undefined)
59 LIB_LINK_LIBS = $(LIBDL) $(LIBS)
62 # some platforms do not provide separate C-only compiler
65 # The most generic rules
66 #$(1) - is the target pattern
69 $$(CPLUS) $$(OUTPUTOBJ_KEY)$$@ $$(COMPILE_ONLY) $$(CPLUS_FLAGS) $$(CXX_ONLY_FLAGS) $$(CXX_WARN_SUPPRESS) $$(INCLUDES) $$<
72 TEST_AFFIXES_OBJS=$(addsuffix .$(OBJ),$(addprefix %_,$(TEST_SUFFIXES)) $(addsuffix _%,$(TEST_PREFIXES)))
74 # Make will not process the same recipe for each test pattern (since the dependency on the same %.cpp)
75 # thus the separated recipes should be provided
76 $(foreach t,%.$(OBJ) $(TEST_AFFIXES_OBJS),$(eval $(call make-cxx-obj,$(t))))
78 .PRECIOUS: %.$(OBJ) %.$(TEST_EXT) %.res $(TEST_AFFIXES_OBJS)
80 # Rules for generating a test DLL
82 $(CPLUS) $(COMPILE_ONLY) $(OUTPUTOBJ_KEY)$@ $(CPLUS_FLAGS) $(PIC_KEY) $(DEFINE_KEY)_USRDLL $(INCLUDES) $<
84 #$(1) - is the binary name
85 #$(2) - is the input obj files and libraries
86 define make-test-binary
87 $(CPLUS) $(OUTPUT_KEY)$(strip $1) $(CPLUS_FLAGS) $(2) $(LIBS) $(LINK_FLAGS)
90 # LINK_FILES the list of options to link test specific files (libraries and object files)
91 LINK_FILES+=$(TEST_LIBS)
92 # Rule for generating executable test
93 %.$(TEST_EXT): %.$(OBJ) $(TEST_LIBS) $(TEST_PREREQUISITE) $(if $(use_proxy),$(PROXY.LIB))
94 $(call make-test-binary,$@,$< $(LINK_FILES) $(PIE_FLAG))
96 # Rules for generating a test DLL
97 %_dll.$(DLL): LINK_FLAGS += $(PIC_KEY) $(DYLIB_KEY)
98 %_dll.$(DLL): TEST_LIBS := $(subst %_dll.$(DLL),,$(TEST_LIBS))
99 %_dll.$(DLL): %_dll.$(OBJ)
100 $(call make-test-binary,$@,$< $(LINK_FILES))
101 .PRECIOUS: %_dll.$(OBJ) %_dll.$(DLL)
104 $(CONLY) $(COMPILE_ONLY) $(OUTPUTOBJ_KEY)$@ $(C_FLAGS) $(INCLUDES) $<
107 $(ASM) $(ASM_FLAGS) $<
110 cpp <$< | grep -v '^#' >$*.tmp
111 $(ASM) $(ASM_FLAGS) -o $@ $*.tmp
113 # Rule for generating .E file if needed for visual inspection
114 # Note that ICL treats an argument after PREPROC_ONLY as a file to open,
115 # so all uses of PREPROC_ONLY should be immediately followed by a file name
117 $(CPLUS) $(CPLUS_FLAGS) $(CXX_ONLY_FLAGS) $(INCLUDES) $(PREPROC_ONLY) $< >$@
119 # TODO Rule for generating .asm file if needed for visual inspection
121 $(CPLUS) /c /FAs /Fa $(CPLUS_FLAGS) $(CXX_ONLY_FLAGS) $(INCLUDES) $<
123 # TODO Rule for generating .s file if needed for visual inspection
125 $(CPLUS) -S $(CPLUS_FLAGS) $(CXX_ONLY_FLAGS) $(INCLUDES) $<
128 $(KNOWN_WARNINGS): %.$(OBJ): %.cpp
129 $(CPLUS) $(COMPILE_ONLY) $(subst $(WARNING_KEY),,$(CPLUS_FLAGS)) $(CXX_ONLY_FLAGS) $(CXX_WARN_SUPPRESS) $(INCLUDES) $<
131 tbb_misc.$(OBJ): version_string.ver
132 tbb_misc.$(OBJ): INCLUDES+=$(INCLUDE_KEY).
134 tbb_misc.E: tbb_misc.cpp version_string.ver
135 $(CPLUS) $(CPLUS_FLAGS) $(CXX_ONLY_FLAGS) $(INCLUDE_KEY). $(INCLUDES) $(PREPROC_ONLY) $< >$@
137 %.res: %.rc version_string.ver $(TBB.MANIFEST)
138 rc /Fo$@ $(INCLUDES) $(filter /D%,$(CPLUS_FLAGS)) $<
140 # TODO: add $(LIB_LINK_LIBS) $(LIB_LINK_FLAGS) (in a separate line?) and remove useless $(INCLUDES)
141 VERSION_FLAGS=$(CPLUS) $(CPLUS_FLAGS) $(CXX_ONLY_FLAGS) $(INCLUDES)
143 ifneq (,$(TBB.MANIFEST))
145 cmd /C "echo #include ^<stdio.h^> >tbbmanifest.c"
146 cmd /C "echo int main(){return 0;} >>tbbmanifest.c"
147 cl /nologo $(C_FLAGS) tbbmanifest.c
149 version_string.ver: $(TBB.MANIFEST)
151 cmd /C "echo #define TBB_MANIFEST 1 >> version_string.ver"
152 # TODO: fix parallel build by writing to a temporary file and rename it when complete
154 # TODO: make version strings directly representative for all the libraries
159 test_% debug_%: test_%.$(TEST_EXT) $(TEST_PREREQUISITE)
160 $(run_cmd) ./$< $(args)
163 codecov $(if $(findstring -,$(codecov)),$(codecov),) -demang -comp $(tbb_root)/build/codecov.txt