-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
132 lines (94 loc) · 3.4 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
LUA = ./luajit
LUA_DIR=/usr/local
LUA_LIBDIR=$(LUA_DIR)/lib/lua/5.1
LUA_SHAREDIR=$(LUA_DIR)/share/lua/5.1
EXT ?= so
ifeq ($(shell uname -s), Darwin)
EXT = dylib
endif
FILES=src/uv/lib/libuv.$(EXT) \
src/uv/lib/libuv.min.h \
src/uv/lib/libuv2.$(EXT) \
src/uv/lib/libuv2.min.h \
src/uv/lib/libhttp_parser.$(EXT) \
src/uv/lib/libhttp_parser.min.h
all: $(FILES)
################################################################################
# libuv
################################################################################
deps/libuv-v0.11.28.zip:
wget https://github.com/joyent/libuv/archive/v0.11.28.zip -O $@
deps/libuv-0.11.28: deps/libuv-v0.11.28.zip
rm -rf $@
unzip $< -d deps
touch $@
deps/libuv: deps/libuv-0.11.28
cd deps && ln -fs libuv-0.11.28 libuv
deps/libuv/include/uv.h: deps/libuv
deps/libuv/autogen.sh: deps/libuv
deps/libuv/configure: deps/libuv/autogen.sh
cd deps/libuv && sh autogen.sh
deps/libuv/Makefile: deps/libuv/configure
cd deps/libuv && ./configure
deps/libuv/.libs/libuv.a: deps/libuv/Makefile
cd deps/libuv && make
deps/libuv/.libs/libuv.$(EXT): deps/libuv/.libs/libuv.a
src/uv/lib/libuv.$(EXT): deps/libuv/.libs/libuv.$(EXT)
cp $+ $@
src/uv/lib/libuv.min.h: deps/libuv/include/uv.h
gcc -E $+ | grep -v '^ *#' > $@
src/uv/lib/libuv2.dylib: deps/libuv/.libs/libuv.a src/uv/libuv2.c
gcc -dynamiclib $+ -o $@
src/uv/lib/libuv2.so: src/uv/libuv2.c deps/libuv/.libs/libuv.so
gcc -g -fPIC -shared $+ -o $@
src/uv/lib/libuv2.min.h: src/uv/libuv2.h
gcc -E $+ | grep -v '^ *#' > $@
################################################################################
# http-parser
################################################################################
deps/http-parser-v2.3.zip:
wget https://github.com/joyent/http-parser/archive/v2.3.zip -O $@
deps/http-parser-2.3: deps/http-parser-v2.3.zip
rm -rf $@
unzip $< -d deps
touch $@
deps/http-parser: deps/http-parser-2.3
cd deps && ln -fs http-parser-2.3 http-parser
deps/http-parser/http_parser.h: deps/http-parser
deps/http-parser/libhttp_parser.so.2.3: deps/http-parser
cd deps/http-parser && make library
src/uv/lib/libhttp_parser.$(EXT): deps/http-parser/libhttp_parser.so.2.3
cp $+ $@
src/uv/lib/libhttp_parser.min.h: deps/http-parser/http_parser.h
gcc -E $+ | grep -v '^ *#' > $@
################################################################################
# luajit
################################################################################
deps/LuaJIT-2.0.3.tar.gz:
cd deps && wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz
deps/LuaJIT-2.0.3: deps/LuaJIT-2.0.3.tar.gz
rm -rf $@
cd deps && tar zxf LuaJIT-2.0.3.tar.gz
touch $@
deps/LuaJIT-2.0.3/Makefile: deps/LuaJIT-2.0.3
deps/LuaJIT-2.0.3/src/luajit: deps/LuaJIT-2.0.3/Makefile
cd deps/LuaJIT-2.0.3 && make
luajit: deps/LuaJIT-2.0.3/src/luajit
cp $+ $@
################################################################################
# etc...
################################################################################
install: all uninstall
cp -R src/uv ${LUA_SHAREDIR}/
uninstall:
rm -rf ${LUA_SHAREDIR}/uv
clean:
rm -rf deps/* src/uv/lib/*
test: run-tests
run-tests: $(LUA)
LUA_PATH="src/?.lua;;" find test -name "*_test.lua" -exec luajit "{}" ";"
@echo All tests passing
benchmark: run-benchmarks
run-benchmarks: $(LUA)
LUA_PATH="src/?.lua;;" find benchmark -name "*_benchmark.lua" -exec luajit "{}" ";"
@echo All tests passing