-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
65 lines (50 loc) · 1.27 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
IDIR = ./src/include
SRCDIR = ./src
BUILDDIR = ./build
OBJECTDIR = ./build/object
BINDIR = ./build/bin
# create build dir
$(shell mkdir -p ${BUILDDIR})
$(shell mkdir -p ${OBJECTDIR})
$(shell mkdir -p ${BINDIR})
CC = g++
CFLAGS = -g -I${IDIR} -Wall -lpthread
_OBJECTS = \
Channel \
Poller \
EventLoop \
Socket \
TcpConnection \
TcpServer \
EchoServer \
HttpSession \
HttpServer \
EventLoopThread \
EventLoopThreadPool \
ThreadPool \
OBJECTS = $(patsubst %,${OBJECTDIR}/%.o,$(_OBJECTS))
_DEPS = *.h
DEPS = $(patsubst %,${IDIR}/%,$(_DEPS))
.PHONY: clean echomain.out httpmain.out
echomain.out: ${SRCDIR}/main.cc
$(CC) -c $< $(CFLAGS) -o $@ -D ECHOSERVER
httpmain.out: ${SRCDIR}/main.cc
$(CC) -c $< $(CFLAGS) -o $@ -D HTTPSERVER
echoserver: echomain.out ${OBJECTS}
${CC} $^ ${CFLAGS} -o ${BINDIR}/$@
${BINDIR}/$@
httpserver: httpmain.out ${OBJECTS}
${CC} $^ ${CFLAGS} -o ${BINDIR}/$@
${BINDIR}/$@
# echoserver: ${OBJECTDIR}/main.o ${OBJECTS}
# ${CC} ${CFLAGS} $^ -o ${BINDIR}/$@
# ${BINDIR}/$@
# httpserver: ${OBJECTDIR}/main.o ${OBJECTS}
# ${CC} ${CFLAGS} $^ -o ${BINDIR}/$@
# ${BINDIR}/$@
${OBJECTDIR}/%.o: ${SRCDIR}/%.cc ${DEPS}
$(CC) -c $< $(CFLAGS) -o $@
format:
find . -name *.cc -o -name *.h | xargs clang-format -style=file -i
clean:
rm -rf ./build/*