forked from jonashaag/bjoern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (73 loc) · 2.39 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
SOURCE_DIR = bjoern
BUILD_DIR = build
PYTHON ?= python2
PYTHON_INCLUDE = $(shell ${PYTHON}-config --includes)
PYTHON_LDFLAGS = $(shell ${PYTHON}-config --ldflags)
HTTP_PARSER_DIR = http-parser
HTTP_PARSER_OBJ = $(HTTP_PARSER_DIR)/http_parser.o
HTTP_PARSER_SRC = $(HTTP_PARSER_DIR)/http_parser.c
objects = $(HTTP_PARSER_OBJ) \
$(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.o, \
$(wildcard $(SOURCE_DIR)/*.c))
CPPFLAGS += $(PYTHON_INCLUDE) -I . -I $(SOURCE_DIR) -I $(HTTP_PARSER_DIR)
CFLAGS += $(FEATURES) -std=c99 -fno-strict-aliasing -fcommon -fPIC -Wall
LDFLAGS += $(PYTHON_LDFLAGS) -l ev -shared -fcommon
ifneq ($(WANT_SENDFILE), no)
FEATURES += -D WANT_SENDFILE
endif
ifneq ($(WANT_SIGINT_HANDLING), no)
FEATURES += -D WANT_SIGINT_HANDLING
endif
all: prepare-build $(objects) _bjoernmodule
print-env:
@echo CFLAGS=$(CFLAGS)
@echo CPPFLAGS=$(CPPFLAGS)
@echo LDFLAGS=$(LDFLAGS)
@echo args=$(HTTP_PARSER_SRC) $(wildcard $(SOURCE_DIR)/*.c)
opt: clean
CFLAGS='-O3' make
small: clean
CFLAGS='-Os' make
_bjoernmodule:
@$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(objects) -o $(BUILD_DIR)/_bjoern.so
@PYTHONPATH=$$PYTHONPATH:$(BUILD_DIR) ${PYTHON} -c "import bjoern"
again: clean all
debug:
CFLAGS='-D DEBUG -g' make again
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c
@echo ' -> ' $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
@$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# foo.o: shortcut to $(BUILD_DIR)/foo.o
%.o: $(BUILD_DIR)/%.o
prepare-build:
@mkdir -p $(BUILD_DIR)
clean:
@rm -rf $(BUILD_DIR)/*
AB = ab -c 100 -n 10000
TEST_URL = "http://127.0.0.1:8080/a/b/c?k=v&k2=v2"
ab: ab1 ab2 ab3 ab4
ab1:
$(AB) $(TEST_URL)
ab2:
@echo 'asdfghjkl=asdfghjkl&qwerty=qwertyuiop' > /tmp/bjoern-post.tmp
$(AB) -p /tmp/bjoern-post.tmp $(TEST_URL)
ab3:
$(AB) -k $(TEST_URL)
ab4:
@echo 'asdfghjkl=asdfghjkl&qwerty=qwertyuiop' > /tmp/bjoern-post.tmp
$(AB) -k -p /tmp/bjoern-post.tmp $(TEST_URL)
wget:
wget -O - -q -S $(TEST_URL)
valgrind:
valgrind --leak-check=full --show-reachable=yes ${PYTHON} tests/empty.py
callgrind:
valgrind --tool=callgrind ${PYTHON} tests/wsgitest-round-robin.py
memwatch:
watch -n 0.5 \
'cat /proc/$$(pgrep -n ${PYTHON})/cmdline | tr "\0" " " | head -c -1; \
echo; echo; \
tail -n +25 /proc/$$(pgrep -n ${PYTHON})/smaps'
upload:
${PYTHON} setup.py sdist upload
$(HTTP_PARSER_OBJ):
$(MAKE) -C $(HTTP_PARSER_DIR) http_parser.o CFLAGS_DEBUG_EXTRA=-fPIC CFLAGS_FAST_EXTRA=-fPIC