-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
56 lines (40 loc) · 1.54 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
CC = gcc
CFLAGS = -std=gnu99 -pthread -Wall -g
BASE_SRC_C = src/xnet.c src/xnet_socket.c src/xnet_timeheap.c \
src/xnet_util.c src/malloc_ref.c src/xnet_packer.c \
src/xnet_string.c
SUFFIX=.exe
LUA_INC ?= 3rd/lua/src
LUA_STATICLIB := 3rd/lua/src/liblua.a
win : CFLAGS += -lws2_32
win : all
linux : CFLAGS += -ldl
linux : all
alltest = test$(SUFFIX) test_packer$(SUFFIX) test_udp_client$(SUFFIX) \
test_udp_server$(SUFFIX) test_client$(SUFFIX) test_server$(SUFFIX)
allexample = http_server$(SUFFIX) control_server$(SUFFIX)
all : $(allexample) $(alltest) xnet$(SUFFIX)
#test
test_server$(SUFFIX) : $(BASE_SRC_C) test/test_server.c src/xnet_config.c
$(CC) -o $@ $^ $(CFLAGS)
test_client$(SUFFIX) : $(BASE_SRC_C) test/test_client.c
$(CC) -o $@ $^ $(CFLAGS)
test_udp_client$(SUFFIX) : $(BASE_SRC_C) test/test_udp_client.c
$(CC) -o $@ $^ $(CFLAGS)
test_udp_server$(SUFFIX) : $(BASE_SRC_C) test/test_udp_server.c
$(CC) -o $@ $^ $(CFLAGS)
test$(SUFFIX) : test/test.c src/xnet_timeheap.c src/xnet_config.c src/xnet_util.c
$(CC) -o $@ $^ $(CFLAGS)
test_packer$(SUFFIX) : test/test_packer.c src/xnet_packer.c src/xnet_string.c
$(CC) -o $@ $^ $(CFLAGS)
#main
xnet$(SUFFIX) : $(BASE_SRC_C) src/xnet_main.c src/xnet_config.c $(LUA_STATICLIB)
$(CC) -o $@ $^ $(CFLAGS) -I$(LUA_INC) -lm
#example
http_server$(SUFFIX) : $(BASE_SRC_C) example/http_server.c
$(CC) -o $@ $^ $(CFLAGS)
control_server$(SUFFIX) : $(BASE_SRC_C) example/control_server.c
$(CC) -o $@ $^ $(CFLAGS)
.PHONY: clear
clear :
rm -rf *$(SUFFIX)