-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Makefile
161 lines (121 loc) · 4.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
###########################################################################
# user-configurable section
###########################################################################
# 64 bit
MARCH=-m64
OPT=-O3
# change this to -g3 for debug builds
#OPT=-g3
# on some Linux systems, '-g -gdwarf-2' may be necessary if g++ is generating
# DWARF 4 debugging info but the installed gdb doesn't support DWARF 4 yet.
#OPT=-g -gdwarf-2
# comment out this line to enable assertions at runtime
DEFS += -DNDEBUG
#########################################################################
# nothing below this line should need to be changed (usually)
#########################################################################
ARCH = $(shell uname)
LEX=flex
YACC=bison -d -v -t
ifeq ($(ARCH),OpenBSD)
LEXLIB = -ll
endif
ifeq ($(ARCH),Linux)
CC=g++
CXX=g++ -std=c++11
# CXXLIB=-lc++
else
CC=/usr/bin/clang
CXX=/usr/bin/clang++ -std=c++11 -stdlib=libc++
CXXLIB=-lstdc++
endif
LD=$(CXX) $(OPT) $(MARCH)
INCLUDE=-I. -Icore
WARN=-Wall -Wno-deprecated-register
CWD=$(shell pwd)
CXXFLAGS=$(OPT) $(MARCH) $(INCLUDE) $(WARN) $(DEFS)
CCFLAGS=$(CXXFLAGS)
LIBS=$(LEXLIB) -lm $(CPPLIB) -lpthread
LIB_CXXSRCS = $(wildcard core/*.cpp) core/pbrtlex.cpp core/pbrtparse.cpp
LIB_CXXSRCS += $(wildcard ext/*.cpp)
LIB_CXXSRCS += $(wildcard accelerators/*.cpp cameras/*.cpp filters/*.cpp )
LIB_CXXSRCS += $(wildcard integrators/*.cpp lights/*.cpp materials/*.cpp )
LIB_CXXSRCS += $(wildcard samplers/*.cpp shapes/*.cpp textures/*.cpp media/*.cpp)
LIBOBJS = $(addprefix objs/, $(subst /,_,$(LIB_CXXSRCS:.cpp=.o)))
HEADERS = $(wildcard */*.h)
TOOLS = bin/hdrtoldr bin/exravg bin/exrdiff bin/obj2pbrt bin/bsdftest bin/chi2test
default: dirs bin/pbrt $(TOOLS) bin/pbrt_tests
bin/%: dirs
pbrt: bin/pbrt
dirs:
/bin/mkdir -p bin objs
$(LIBOBJS): $(HEADERS)
.PHONY: dirs tools
.SECONDARY:
objs/libpbrt.a: $(LIBOBJS)
@echo "Building the core rendering library (libpbrt.a)"
@ar rcs $@ $(LIBOBJS)
objs/accelerators_%.o: accelerators/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/cameras_%.o: cameras/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/core_%.o: core/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/ext_%.o: ext/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/filters_%.o: filters/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/integrators_%.o: integrators/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/lights_%.o: lights/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/main_%.o: main/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/materials_%.o: materials/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/samplers_%.o: samplers/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/shapes_%.o: shapes/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/textures_%.o: textures/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/media_%.o: media/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/pbrt.o: main/pbrt.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
objs/tools_%.o: tools/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<
bin/pbrt: objs/main_pbrt.o objs/libpbrt.a
@echo "Linking $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
bin/%: objs/tools_%.o objs/libpbrt.a
@echo "Linking $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
core/pbrtlex.cpp: core/pbrtlex.ll core/pbrtparse.cpp
@echo "Lex'ing pbrtlex.ll"
@$(LEX) -o$@ core/pbrtlex.ll
core/pbrtparse.cpp: core/pbrtparse.yy
@echo "YACC'ing pbrtparse.yy"
@$(YACC) -o $@ core/pbrtparse.yy
@if [ -e core/pbrtparse.cpp.h ]; then /bin/mv core/pbrtparse.cpp.h core/pbrtparse.hh; fi
@if [ -e core/pbrtparse.hpp ]; then /bin/mv core/pbrtparse.hpp core/pbrtparse.hh; fi
bin/pbrt_tests: $(wildcard tests/*cpp) objs/libpbrt.a
@echo "Building $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ -Itests tests/gtest/gtest-all.cc tests/gtest/gtest_main.cc $(LIBS)
clean:
rm -f objs/* bin/* core/pbrtlex.[ch]* core/pbrtparse.[ch]*