-
Notifications
You must be signed in to change notification settings - Fork 84
/
Makefile
executable file
·120 lines (109 loc) · 3.62 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
########
## Turbo.lua Makefile for installation.
## Copyright (C) 2013 John Abrahamsen.
## See LICENSE file for license information.
########
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
CC = gcc
RM= rm -f
UNINSTALL= rm -rf
MKDIR= mkdir -p
RMDIR= rmdir 2>/dev/null
SYMLINK= ln -sf
INSTALL_X= install -m 0755
INSTALL_F= install -m 0644
CP_R= cp -r
LDCONFIG= ldconfig -n
PREFIX ?= /usr/local
MAJVER= 1
MINVER= 1
MICVER= 0
TVERSION= $(MAJVER).$(MINVER).$(MICVER)
TDEPS= deps
HTTP_PARSERDIR = $(TDEPS)/http-parser
INSTALL_LIB= $(PREFIX)/lib
INSTALL_BIN= $(PREFIX)/bin
INSTALL_TFFI_WRAP_SOSHORT= libtffi_wrap.so
INSTALL_TFFI_WRAP_SONAME= $(INSTALL_TFFI_WRAP_SOSHORT).$(TVERSION)
INSTALL_TFFI_WRAP_DYN= $(INSTALL_LIB)/$(INSTALL_TFFI_WRAP_SONAME)
INSTALL_TFFI_WRAP_SHORT= $(INSTALL_LIB)/$(INSTALL_TFFI_WRAP_SOSHORT)
TEST_DIR = tests
LUA_MODULEDIR = $(PREFIX)/share/lua/5.1
LUA_LIBRARYDIR = $(PREFIX)/lib/lua/5.1
INC = -I$(HTTP_PARSERDIR)/
CFLAGS= -g
ifeq ($(uname_S),Darwin)
CFLAGS += -I/usr/include/malloc
endif
ifeq ($(SSL), axTLS)
# axTLS only uses axtls lib from luajit
# Don't link with crypto or ssl if using axTLS
# C wrapper needs TURBO_NO_SSL set in order
# to not include any of the OpenSSL wrapper
CFLAGS += -DTURBO_NO_SSL=1
endif
ifeq ($(SSL), none)
# No SSL option.
CFLAGS += -DTURBO_NO_SSL=1
endif
ifeq ($(SSL),)
# Default to OpenSSL
SSL=openssl
endif
ifeq ($(SSL), openssl)
# Link OpenSSL
LDFLAGS += -lcrypto -lssl
endif
LUAJIT_VERSION?=2.0.2
LUAJIT_LIBRARYDIR = $(PREFIX)/lib/lua/5.1
LUAJIT_MODULEDIR = $(PREFIX)/share/luajit-$(LUAJIT_VERSION)
all:
make -C deps/http-parser library
$(CC) $(INC) -shared -O3 -Wall $(CFLAGS) $(HTTP_PARSERDIR)/libhttp_parser.o $(TDEPS)/turbo_ffi_wrap.c -o $(INSTALL_TFFI_WRAP_SOSHORT) $(LDFLAGS)
clean:
make -C deps/http-parser clean
$(RM) $(INSTALL_TFFI_WRAP_SOSHORT)
uninstall:
@echo "==== Uninstalling Turbo.lua ===="
$(UNINSTALL) $(INSTALL_TFFI_WRAP_SHORT) $(INSTALL_TFFI_WRAP_DYN)
$(LDCONFIG) $(INSTALL_LIB)
$(UNINSTALL) $(LUA_MODULEDIR)/turbo/
$(UNINSTALL) $(LUAJIT_MODULEDIR)/turbo/
$(UNINSTALL) $(INSTALL_BIN)/turbovisor
$(RM) $(LUA_MODULEDIR)/turbo.lua
$(RM) $(LUAJIT_MODULEDIR)/turbo.lua
$(RM) $(LUAJIT_MODULEDIR)/turbovisor.lua
@echo "==== Turbo.lua uinstalled. Welcome back. ===="
install:
@echo "==== Installing Turbo.lua v$(TVERSION) to: ===="
@echo "==== $(LUAJIT_LIBRARYDIR) and ===="
@echo "==== $(LUAJIT_MODULEDIR) ===="
$(MKDIR) $(INSTALL_LIB)
$(MKDIR) $(LUA_MODULEDIR)/turbo
$(MKDIR) $(LUAJIT_MODULEDIR)/turbo
$(CP_R) turbo/* $(LUA_MODULEDIR)/turbo
$(CP_R) turbo.lua $(LUA_MODULEDIR)
$(CP_R) turbovisor.lua $(LUA_MODULEDIR)
$(CP_R) -R turbo/* $(LUAJIT_MODULEDIR)/turbo
$(CP_R) turbo.lua $(LUAJIT_MODULEDIR)
$(CP_R) turbovisor.lua $(LUAJIT_MODULEDIR)
$(INSTALL_X) bin/turbovisor $(INSTALL_BIN)
@echo "==== Building 3rdparty modules ===="
make -C deps/http-parser library
$(CC) $(INC) -shared -O3 -Wall $(CFLAGS) $(HTTP_PARSERDIR)/libhttp_parser.o $(TDEPS)/turbo_ffi_wrap.c -o $(INSTALL_TFFI_WRAP_SOSHORT) $(LDFLAGS)
@echo "==== Installing libturbo_parser ===="
test -f $(INSTALL_TFFI_WRAP_SOSHORT) && \
$(INSTALL_X) $(INSTALL_TFFI_WRAP_SOSHORT) $(INSTALL_TFFI_WRAP_DYN) && \
$(LDCONFIG) $(INSTALL_LIB) && \
$(SYMLINK) $(INSTALL_TFFI_WRAP_SONAME) $(INSTALL_TFFI_WRAP_SHORT)
@echo "==== Successfully installed Turbo.lua $(TVERSION) to $(PREFIX) ===="
test:
@echo "==== Running tests for Turbo.lua. NOTICE: busted module is required ===="
cd $(TEST_DIR) && busted run_all_test.lua
luajit examples/helloworld.lua &
sleep 1
wget http://127.0.0.1:8888/
test -f index.html
rm -f index.html
pkill luajit
@echo "==== Successfully ran all tests for Turbo.lua $(TVERSION) ===="