-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
142 lines (108 loc) · 2.21 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
TARGET=realist
TARGET+=raycpp
TARGET+=rayc
GO=go
ifeq (x$(shell which $(GO) > /dev/null ; echo $$?),x0)
HAVE_GO=1
endif
HAVE_V:=1
ifdef HAVE_V
TARGET+=rayv
endif
ifdef HAVE_GO
TARGET+=raygo
endif
CFLAGS=-Wall -Werror
CFLAGS+=-Wextra
CXXFLAGS=-Wall -Werror
CXXFLAGS+=-Wextra
CFLAGS+=-g
CXXFLAGS+=-g
CFLAGS+=-pipe
CXXFLAGS+=-pipe
LDFLAGS+=-pipe
CXXFLAGS+=-std=c++11
CFLAGS+=-std=gnu99
LDLIBS+=-lm
USE_OPT=1
ifdef USE_OPT
CXXFLAGS+=-O3 -flto
CFLAGS+=-O3 -flto
#CXXFLAGS+=-DUSE_OPT
else
CXXFLAGS+=-O0
CFLAGS+=-O0
endif
#USE_VEC=1
ifdef USE_VEC
CXXFLAGS+=-DUSE_VEC
endif
#USE_FLASH=1
ifdef USE_FLASH
CXXFLAGS+=-DUSE_FLASH
endif
#USE_REFL=1
ifdef USE_REFL
CXXFLAGS+=-DUSE_REFL
endif
#USE_LAMP=1
ifdef USE_LAMP
CXXFLAGS+=-DUSE_LAMP
endif
ifdef STATIC
LDFLAGS+=-static
endif
CXXFLAGS+=-I.
all: SDL_CHECK $(TARGET)
include sdl.mak
ifeq ($(SDL_VER),1)
SDL_CXXFLAGS+=-DSDL1
else
SDL_CXXFLAGS+=-DSDL2
endif
SDL_CXXFLAGS+=$(SDL_FLAGS)
SDL_LDLIBS+=$(SDL_LIBS)
realist: CXXFLAGS+=$(SDL_CXXFLAGS)
realist: LDLIBS+=$(SDL_LDLIBS)
raygo:
# GOPATH=$(shell pwd)/ray_go $(GO) build -o $@ ray_go/raygo.go
GOPATH=`pwd`/ray_go $(GO) build -o $@ ray_go/raygo.go
V:=v/v
v/v:
git clone https://github.com/vlang/v
(cd $(@D) ; $(MAKE) ; cd -)
#VFLAGS:=-debug -show_c_cmd
rayv_v.c: $(V)
cd ray_v ; ../$(V) $(VFLAGS) -o ../$@ . ; cd ..
rayv: rayv_v.c
$(CC) -w $(CFLAGS) $(LDFLAGS) $^ -lm -o $@
realist: realist.cpp vec.h CSDL.h
BENCH_SIZE:=10000
BENCH_ARGS=$(BENCH_SIZE) $(BENCH_SIZE)
BENCH_TARGETS:= rayc raycpp rayv
ifdef HAVE_GO
BENCH_TARGETS+=raygo
endif
bench: $(BENCH_TARGETS)
/usr/bin/time ./rayc $(BENCH_ARGS) rayc.ppm && md5sum rayc.ppm
/usr/bin/time ./rayv $(BENCH_ARGS) rayv.ppm && md5sum rayv.ppm
/usr/bin/time ./raycpp $(BENCH_ARGS) raycpp.ppm && md5sum raycpp.ppm
ifdef HAVE_GO
/usr/bin/time ./raygo $(BENCH_ARGS) raygo.ppm && md5sum raygo.ppm
endif
benchpy: bench
/usr/bin/time ./raypy.py $(BENCH_ARGS) > raypy.ppm && md5sum raypy.ppm
vgcheck: BENCH_SIZE=100
VGOPTS:=--leak-check=full
vgcheck: rayc rayv
valgrind $(VGOPTS) ./rayc $(BENCH_ARGS) rayc.ppm
valgrind $(VGOPTS) ./rayv $(BENCH_ARGS) rayv.ppm
clean:
@$(RM) $(TARGET)
clobber: clean
@$(RM) *~
@$(RM) *_v.c
@$(RM) *.ppm
mrproper: clobber
@$(RM) -Rf v
@$(MAKE) -C rtiow $@