forked from sysprog21/raytracing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (42 loc) · 1.08 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
EXEC = raytracing
GIT_HOOKS := .git/hooks/pre-commit
.PHONY: all
all: $(GIT_HOOKS) $(EXEC)
$(GIT_HOOKS):
@scripts/install-git-hooks
@echo
CC ?= gcc
CFLAGS = \
-std=gnu99 -Wall -O0 -g
LDFLAGS = \
-lm -pthread
ifeq ($(strip $(PROFILE)),1)
PROF_FLAGS = -pg
CFLAGS += $(PROF_FLAGS)
LDFLAGS += $(PROF_FLAGS)
endif
OBJS := \
objects.o \
raytracing.o \
main.o
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(EXEC): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
main.o: use-models.h
use-models.h: models.inc Makefile
@echo '#include "models.inc"' > use-models.h
@egrep "^(light|sphere|rectangular) " models.inc | \
sed -e 's/^light /append_light/g' \
-e 's/light[0-9]/(\&&, \&lights);/g' \
-e 's/^sphere /append_sphere/g' \
-e 's/sphere[0-9]/(\&&, \&spheres);/g' \
-e 's/^rectangular /append_rectangular/g' \
-e 's/rectangular[0-9]/(\&&, \&rectangulars);/g' \
-e 's/ = {//g' >> use-models.h
check: $(EXEC)
@./$(EXEC) && diff -u baseline.ppm out.ppm || (echo Fail; exit)
@echo "Verified OK"
clean:
$(RM) $(EXEC) $(OBJS) use-models.h \
out.ppm gmon.out