Committing TBB 2019 Update 9 source code
[platform/upstream/tbb.git] / examples / parallel_reduce / primes / Makefile
1 # Copyright (c) 2005-2019 Intel Corporation
2 #
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 # GNU Makefile that builds and runs example.
16 run_cmd=
17 PROG=primes
18 ARGS=
19 PERF_RUN_ARGS=silent  auto 1000000000 1000 20
20
21 # The C++ compiler
22 ifneq (,$(shell which icc 2>/dev/null))
23 CXX=icc
24 endif # icc
25
26 TBBLIB = -ltbb
27 TBBLIB_DEBUG = -ltbb_debug
28
29 ifeq ($(offload), mic)
30 override CXXFLAGS += -D__TBB_MIC_OFFLOAD=1
31 # Replace -ltbb with -tbb in the offload mode
32 TBBLIB = -tbb
33 TBBLIB_DEBUG += -offload-option,mic,ld,"-ltbb_debug"
34 endif
35
36 ifeq ($(shell uname), Linux)
37 ifeq ($(target), android)
38 LIBS+= --sysroot=$(SYSROOT)
39 run_cmd=../../common/android.linux.launcher.sh
40 else
41 LIBS+= -lrt 
42 endif
43 else ifeq ($(shell uname), Darwin)
44 override CXXFLAGS += -Wl,-rpath,$(TBBROOT)/lib
45 endif
46
47 # autodetect C++11 support
48 include ../../common/examples-common.inc
49
50 all:    release test
51
52 release: main.cpp primes.cpp 
53         $(CXX) -O2 -DNDEBUG $(CXXFLAGS) -o $(PROG) $^ $(TBBLIB) $(LIBS) $(CXX0XFLAGS)
54
55 debug: main.cpp primes.cpp
56         $(CXX) -O0 -g -DTBB_USE_DEBUG $(CXXFLAGS) -o $(PROG) $^ $(TBBLIB_DEBUG) $(LIBS) $(CXX0XFLAGS)
57
58 clean:
59         $(RM) $(PROG) *.o *.d
60
61 test: 
62         $(run_cmd) ./$(PROG) $(ARGS)
63
64 perf_build: release
65
66 perf_run:
67         $(run_cmd) ./$(PROG) $(PERF_RUN_ARGS)