1# Copyright (c) 2005-2020 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.
16NAME=pover
17ARGS=
18LIGHT_ARGS= --polys 10 --size 5x5
19
20# The C++ compiler
21ifneq (,$(shell which icc 2>/dev/null))
22CXX=icc
23endif # icc
24
25include ../../common/gui/Makefile.gmake
26
27ifeq ($(UI),x)
28UI_CXXFLAGS += -DX_FULLSYNC
29endif # X
30
31override CXXFLAGS += $(UI_CXXFLAGS)
32
33SRCFILES = ../../common/gui/$(UI)video.cpp pover_video.cpp polymain.cpp polyover.cpp
34
35ifeq ($(shell uname), Linux)
36LIBS+= -lrt
37else ifeq ($(shell uname), Darwin)
38override CXXFLAGS += -Wl,-rpath,$(TBBROOT)/lib
39endif
40
41# autodetect C++11 support
42include ../../common/examples-common.inc
43
44all:	release test
45
46resources:
47ifeq ($(UI),mac)
48	mkdir -p $(APPRES)/en.lproj $(NAME).app/Contents/MacOS
49	cp ../../common/gui/xcode/tbbExample/tbbExample-Info.plist $(NAME).app/Contents/Info.plist
50	cp ../../common/gui/xcode/tbbExample/PkgInfo $(NAME).app/Contents
51	cp ../../common/gui/xcode/tbbExample/en.lproj/* $(APPRES)/en.lproj
52endif # macOS*
53
54release: $(SRCFILES) resources
55ifeq ($(compiler),xl)
56	# Avoiding "1586-346 (U) An error occurred during code generation.  The code generation return code was 40." with -O3.
57	$(CXX) -O2 -DNDEBUG $(CXXFLAGS) -o $(EXE) $(SRCFILES) -ltbb -ltbbmalloc $(LIBS) $(CXX0XFLAGS)
58else
59ifeq ($(UI),mac)
60	$(CXX_UI) -O3 -DNDEBUG $(CXXFLAGS) -c $(MACUISOURCES) $(CXX0XFLAGS)
61endif # macOS
62	$(CXX) -O3 -DNDEBUG $(CXXFLAGS) -o $(EXE) $(SRCFILES) $(MACUIOBJS) -ltbb -ltbbmalloc $(LIBS) $(CXX0XFLAGS)
63endif
64
65debug:  $(SRCFILES) resources
66ifeq ($(UI),mac)
67	$(CXX_UI) -g -O0 -DTBB_USE_DEBUG -D_DEBUG $(CXXFLAGS) -c $(MACUISOURCES) $(CXX0XFLAGS)
68endif # macOS
69	$(CXX) -g -O0 -DTBB_USE_DEBUG -D_DEBUG $(CXXFLAGS) -o $(EXE) $(SRCFILES) $(MACUIOBJS) -ltbb_debug -ltbbmalloc_debug $(LIBS) $(CXX0XFLAGS)
70
71clean:
72	$(RM) $(EXE) *.o *.d
73ifeq ($(UI),mac)
74	rm -rf $(NAME).app
75endif
76
77test:
78ifeq ($(UI),mac)
79	export DYLD_LIBRARY_PATH="$(DYLD_LIBRARY_PATH):$(TBBLIBSPATH)"; $(run_cmd) ./$(EXE) $(ARGS)
80else
81	$(run_cmd) ./$(EXE) $(ARGS)
82endif
83
84light_test:
85ifeq ($(UI),mac)
86	export DYLD_LIBRARY_PATH="$(DYLD_LIBRARY_PATH):$(TBBLIBSPATH)"; $(run_cmd) ./$(EXE) $(LIGHT_ARGS)
87else
88	$(run_cmd) ./$(EXE) $(LIGHT_ARGS)
89endif
90