Makefile
2.2 KB
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
#--------------------------------------------------------------------
CC = gcc
AR = ar cru
CFLAGS = -Wall -D_REENTRANT -D_GNU_SOURCE -g -fPIC
SOFLAGS = -shared
LDFLAGS = -lstdc++ -lpthread
LINKER = $(CC)
LINT = lint -c
RM = /bin/rm -f
LIBEVENT_INCL = -I$(HOME)/libevent/
LIBEVENT_LIB = -L$(HOME)/libevent -levent -lrt
CFLAGS += $(LIBEVENT_INCL)
LDFLAGS += $(LIBEVENT_LIB)
#--------------------------------------------------------------------
LIBOBJS = sputils.o spioutils.o spiochannel.o \
spthreadpool.o event_msgqueue.o spbuffer.o sphandler.o \
spmsgblock.o spmsgdecoder.o spresponse.o sprequest.o \
spexecutor.o spsession.o speventcb.o spserver.o \
spdispatcher.o splfserver.o \
sphttpmsg.o sphttp.o spsmtp.o
TARGET = libspserver.so libspserver.a \
testecho testthreadpool testsmtp testchat teststress testhttp \
testhttp_d testhttpmsg testdispatcher testchat_d testunp
#--------------------------------------------------------------------
all: $(TARGET)
libspserver.so: $(LIBOBJS)
$(LINKER) $(SOFLAGS) $^ -o $@
libspserver.a: $(LIBOBJS)
$(AR) $@ $^
testthreadpool: testthreadpool.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testsmtp: testsmtp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testchat: testchat.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
teststress: teststress.o
$(LINKER) $^ -L. -levent $(LDFLAGS) -o $@
testecho: testecho.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttp: testhttp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttp_d: testhttp_d.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttpmsg: sputils.o sphttpmsg.o testhttpmsg.o
$(LINKER) $^ $(LDFLAGS) -o $@
testdispatcher: testdispatcher.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testchat_d: testchat_d.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testunp: testunp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
clean:
@( $(RM) *.o vgcore.* core core.* $(TARGET) )
#--------------------------------------------------------------------
# make rule
%.o : %.c
$(CC) $(CFLAGS) -c $^ -o $@
%.o : %.cpp
$(CC) $(CFLAGS) -c $^ -o $@