-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (42 loc) · 1.46 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
INCLUDES=./include
CXX=clang++
CXXFLAGS=-std=c++11 -stdlib=libc++ -O3 -I$(INCLUDES)
CC=clang
CFLAGS=-lm -O3 -I$(INCLUDES)
EMCC=../emscripten/emcc
EMCCFLAGS=--jcache -O2 -I$(INCLUDES) --llvm-lto 1
EMCCCXXFLAGS=-std=c++11
EMCCCFLAGS=
JSFLAGS=--closure 1 -s ASM_JS=0 -s TOTAL_MEMORY=536870912
ASMJSFLAGS=-s ASM_JS=1 -s TOTAL_MEMORY=536870912
SOURCES=$(wildcard *-generic/*.cpp) $(wildcard *-generic/*.c)
PROGRAMS=$(basename $(SOURCES))
SUFFIXES=-js.html -asmjs.html .js -asm.js
HTMLS=$(foreach SUFFIX, $(SUFFIXES), $(addsuffix $(SUFFIX), $(PROGRAMS)))
%-asmjs.html: %.cpp
$(EMCC) $(EMCCFLAGS) $(EMCCCXXFLAGS) $(ASMJSFLAGS) $< -o $@
%-js.html: %.cpp
$(EMCC) $(EMCCFLAGS) $(EMCCCXXFLAGS) $(JSFLAGS) $< -o $@
%-asmjs.html: %.c
$(EMCC) $(EMCCFLAGS) $(EMCCCFLAGS) $(ASMJSFLAGS) $< -o $@
%-js.html: %.c
$(EMCC) $(EMCCFLAGS) $(EMCCCFLAGS) $(JSFLAGS) $< -o $@
%-asm.js: %.cpp
$(EMCC) $(EMCCFLAGS) $(EMCCCXXFLAGS) $(ASMJSFLAGS) $< -o $@
%.js: %.cpp
$(EMCC) $(EMCCFLAGS) $(EMCCCXXFLAGS) $(JSFLAGS) $< -o $@
%-asm.js: %.c
$(EMCC) $(EMCCFLAGS) $(EMCCCFLAGS) $(ASMJSFLAGS) $< -o $@
%.js: %.c
$(EMCC) $(EMCCFLAGS) $(EMCCCFLAGS) $(JSFLAGS) $< -o $@
define PROGRAM_template
$(1)-all: $(1) $(1)-js.html $(1)-asmjs.html $(1).js $(1)-asm.js
endef
$(foreach prog, $(PROGRAMS), $(eval $(call PROGRAM_template, $(prog))))
clean:
rm -f $(PROGRAMS)
rm -f $(HTMLS)
rm -f ~/public_html/benches/*.html
all: $(addsuffix -all, $(PROGRAMS))
cp $(HTMLS) ~/public_html/benches/
.PHONY: all clean