-
Notifications
You must be signed in to change notification settings - Fork 375
/
Makefile
73 lines (54 loc) · 1.81 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
LUADIR=deps/luajit
UVDIR=deps/uv
HTTPDIR=deps/http-parser
BUILDDIR=build
GENDIR=${BUILDDIR}/generated
LUALIBS=${GENDIR}/http.o \
${GENDIR}/tcp.o \
${GENDIR}/luvit.o \
${GENDIR}/utils.o
LUVLIBS=${BUILDDIR}/utils.o \
${BUILDDIR}/luv_fs.o \
${BUILDDIR}/luv_handle.o \
${BUILDDIR}/luv_udp.o \
${BUILDDIR}/luv_stream.o \
${BUILDDIR}/luv_tcp.o \
${BUILDDIR}/luv_pipe.o \
${BUILDDIR}/luv_tty.o \
${BUILDDIR}/lhttp_parser.o
ALLLIBS=${BUILDDIR}/luvit.o \
${LUVLIBS} \
${BUILDDIR}/luv.o \
${LUADIR}/src/libluajit.a \
${UVDIR}/uv.a \
${HTTPDIR}/http_parser.o \
${LUALIBS}
all: ${BUILDDIR}/luvit
${GENDIR}:
mkdir -p ${GENDIR}
webserver: ${BUILDDIR}/webserver
luvit: ${BUILDDIR}/luvit
${LUADIR}/src/libluajit.a:
$(MAKE) -C ${LUADIR}
${UVDIR}/uv.a:
$(MAKE) -C ${UVDIR} uv.a
${HTTPDIR}/http_parser.o:
make -C ${HTTPDIR} http_parser.o
${GENDIR}/%.c: lib/%.lua ${LUADIR}/src/libluajit.a
${LUADIR}/src/luajit -b $< $@
${GENDIR}/%.o: ${GENDIR}/%.c
$(CC) -Wall -c $< -o $@
${BUILDDIR}/%.o: src/%.c src/%.h
mkdir -p ${BUILDDIR}
$(CC) -Wall -c $< -o $@ -I${HTTPDIR} -I${UVDIR}/include -I${LUADIR}/src -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
${BUILDDIR}/luvit: ${GENDIR} ${ALLLIBS}
$(CC) -o ${BUILDDIR}/luvit ${ALLLIBS} -Wall -lm -ldl -lrt -Wl,-E
clean:
make -C ${LUADIR} clean
make -C ${HTTPDIR} clean
make -C ${UVDIR} distclean
rm -rf build
install: ${BUILDDIR}/luvit
install ${BUILDDIR}/luvit -s -v /usr/local/bin/luvit
${BUILDDIR}/webserver: src/webserver.c ${UVDIR}/uv.a ${HTTPDIR}/http_parser.o
$(CC) -Wall -o ${BUILDDIR}/webserver src/webserver.c ${UVDIR}/uv.a ${HTTPDIR}/http_parser.o -I${HTTPDIR} -I${UVDIR}/include -lrt -lm