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# The original source for this example is 16# Copyright (c) 1994-2008 John E. Stone 17# All rights reserved. 18# 19# Redistribution and use in source and binary forms, with or without 20# modification, are permitted provided that the following conditions 21# are met: 22# 1. Redistributions of source code must retain the above copyright 23# notice, this list of conditions and the following disclaimer. 24# 2. Redistributions in binary form must reproduce the above copyright 25# notice, this list of conditions and the following disclaimer in the 26# documentation and/or other materials provided with the distribution. 27# 3. The name of the author may not be used to endorse or promote products 28# derived from this software without specific prior written permission. 29# 30# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 31# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 34# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40# SUCH DAMAGE. 41 42# GNU Makefile that builds and runs example. 43NAME:=tachyon 44 45# The C++ compiler 46ifneq (,$(shell which icc 2>/dev/null)) 47CXX=icc 48endif # icc 49 50# The default runtime arguments 51DATASET = balls 52override ARGS := dat/$(DATASET).dat $(ARGS) 53PERF_RUN_ARGS = silent dat/balls3.dat 54LIGHT_ARGS = dat/model2.dat 55 56# define name suffix 57SUFFIX = .$(VERSION) 58 59LIBS ?= -lm 60 61include ../../common/gui/Makefile.gmake 62 63ifeq ($(UI),x) 64UI_CXXFLAGS += -DX_FULLSYNC 65ifneq (,$(findstring -lXext,$(LIBS))) 66UI_CXXFLAGS += -DX_NOSHMPIX 67endif 68endif # X 69 70MYCXXFLAGS = $(CXXFLAGS) $(UI_CXXFLAGS) 71 72# autodetect C++11 support 73include ../../common/examples-common.inc 74 75all: build run 76release: build 77debug: build_debug 78test: run 79 80build: build_serial build_tbb1d build_tbb 81build_debug: build_serial_debug build_tbb1d_debug build_tbb_debug 82run: run_serial run_tbb1d run_tbb 83 84serial: build_serial run_serial 85serial_debug: build_serial_debug run_serial 86tbb: build_tbb run_tbb 87tbb_debug: build_tbb_debug run_tbb 88tbb1d: build_tbb1d run_tbb1d 89tbb1d_debug: build_tbb1d_debug run_tbb1d 90 91build_serial: 92 $(MAKE) VERSION=serial build_one 93build_serial_debug: 94 $(MAKE) VERSION=serial ADD_DEBUG=1 build_one 95run_serial: 96 $(MAKE) VERSION=serial run_one 97 98build_tbb: 99 $(MAKE) VERSION=tbb ADD_TBB=1 build_one 100build_tbb_debug: 101 $(MAKE) VERSION=tbb ADD_TBB=1 ADD_DEBUG=1 build_one 102run_tbb: 103 $(MAKE) VERSION=tbb run_one 104 105build_tbb1d: 106 $(MAKE) VERSION=tbb1d ADD_TBB=1 build_one 107build_tbb1d_debug: 108 $(MAKE) VERSION=tbb1d ADD_TBB=1 ADD_DEBUG=1 build_one 109run_tbb1d: 110 $(MAKE) VERSION=tbb1d run_one 111 112 113perf_build: 114 $(MAKE) UI=con VERSION=tbb ADD_TBB=1 build_one 115perf_run: 116 $(MAKE) UI=con VERSION=tbb run_perf_one 117 118light_test: 119 $(MAKE) UI=con VERSION=tbb light_test_one 120 121 122# 123# Per-build Makefile rules (for recursive $(MAKE) calls from above) 124# 125 126SVERSION = $(VERSION) 127 128ifeq ($(ADD_DEBUG),1) 129MYCXXFLAGS += -O0 -g -D_DEBUG 130else 131MYCXXFLAGS += -O2 -DNDEBUG 132endif 133 134 135ifeq ($(ADD_TBB),1) 136MYCXXFLAGS += 137ifeq ($(ADD_DEBUG),1) 138MYCXXFLAGS += -DTBB_USE_DEBUG 139LIBS += -ltbb_debug 140else 141LIBS += -ltbb 142endif 143endif 144 145ifeq ($(shell uname), Linux) 146LIBS += -lrt 147else ifeq ($(shell uname), Darwin) 148override CXXFLAGS += -Wl,-rpath,$(TBBROOT)/lib 149endif 150 151SOURCE = ../../common/gui/$(UI)video.cpp src/trace.$(SVERSION).cpp src/main.cpp src/pthread.cpp src/tachyon_video.cpp src/api.cpp src/apigeom.cpp src/apitrigeom.cpp src/bndbox.cpp src/box.cpp src/camera.cpp src/coordsys.cpp src/cylinder.cpp src/extvol.cpp src/global.cpp src/grid.cpp src/imageio.cpp src/imap.cpp src/intersect.cpp src/jpeg.cpp src/light.cpp src/objbound.cpp src/parse.cpp src/plane.cpp src/ppm.cpp src/quadric.cpp src/render.cpp src/ring.cpp src/shade.cpp src/sphere.cpp src/texture.cpp src/tgafile.cpp src/trace_rest.cpp src/triangle.cpp src/ui.cpp src/util.cpp src/vector.cpp src/vol.cpp 152 153build_one: $(EXE) 154 155run_one: 156ifeq ($(UI),mac) 157 export DYLD_LIBRARY_PATH="$(DYLD_LIBRARY_PATH):$(TBBLIBSPATH)"; $(run_cmd) ./$(EXE) $(ARGS) 158else 159 $(run_cmd) ./$(EXE) $(ARGS) 160endif 161 162run_perf_one: 163 $(run_cmd) ./$(EXE) $(PERF_RUN_ARGS) 164 165light_test_one: 166 $(run_cmd) ./$(EXE) $(LIGHT_ARGS) 167 168$(EXE): $(SOURCE) 169ifeq ($(UI),mac) 170 mkdir -p $(APPRES)/en.lproj $(NAME)$(SUFFIX).app/Contents/MacOS 171 cp ../../common/gui/xcode/tbbExample/tbbExample-Info.plist $(NAME)$(SUFFIX).app/Contents/Info.plist 172 cp ../../common/gui/xcode/tbbExample/PkgInfo $(NAME)$(SUFFIX).app/Contents 173 cp ../../common/gui/xcode/tbbExample/en.lproj/* $(APPRES)/en.lproj 174 $(CXX_UI) $(MYCXXFLAGS) $(CXXFLAGS) -c $(MACUISOURCES) $(CXX0XFLAGS) 175endif # macOS* 176 $(CXX) $(MYCXXFLAGS) -o $@ $(SOURCE) $(MACUIOBJS) $(LIBS) $(CXX0XFLAGS) 177 $(RM) *.o 178 179clean: VERSION = * 180clean: 181ifeq ($(UI),mac) 182 rm -rf $(NAME).* 183endif 184 $(RM) $(EXE) *.o *.d 185