-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
47 lines (38 loc) · 1001 Bytes
/
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
EXEC = raytracing
.PHONY: all
all: $(EXEC)
CC ?= gcc
CFLAGS = \
-std=gnu99 -Wall -O0 -g
LDFLAGS = \
-lm
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