-
Notifications
You must be signed in to change notification settings - Fork 5
/
.Makefile
121 lines (94 loc) · 3.49 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
121
.PHONY:all LIBS clean distclean install uninstall
include complier.mk features.mk
INCLUDE =-I. -Ipool -Ipool/core -Ipool/com -Ipool/gp -Ipool/rt
CFLAGS += $(INCLUDE)
VPATH =.:pool:pool/core:pool/com:pool/gp:pool/rt:examples
OBJS_DIR :=.obj
ALL_LIBS :=libmsglog.a libmsglog.so libstpool.a libstpool.so
OBJS_stpool := ospx.o ospx_error.o timer.o\
sm_cache.o objpool.o cpool_core.o cpool_core_gc.o \
cpool_factory.o cpool_wait.o cpool_com_method.o \
cpool_rt_factory.o cpool_rt_core_method.o cpool_rt_method.o cpool_rt_internal.o\
cpool_rt_scheduler_dump.o \
cpool_gp_factory.o cpool_gp_core_method.o cpool_gp_method.o cpool_gp_advance_method.o\
cpool_gp_internal.o cpool_gp_entry.o cpool_gp_wait.o \
stpool.o stpool_group.o
OBJS_msglog := msglog.o
all: LIBS demos
LIBS:PREPARE $(ALL_LIBS)
PREPARE:
@for d in $(OBJS_DIR) $(OBJS_DEMO_DIR); do \
[ -d $$d ] || mkdir -p $$d; \
done
libmsglog.a:$(addprefix $(OBJS_DIR)/, $(OBJS_msglog))
$(AR) $(ARFLAGS) $@ $^
chmod +x $@
ifeq ($(STRIP_LIB), yes)
$(STRIP) $(STRIPFLAGS) $@
endif
libmsglog.so:$(addprefix $(OBJS_DIR)/, $(OBJS_msglog))
$(CC) --shared -o $@ $^
chmod +x $@
ifeq ($(STRIP_LIB), yes)
$(STRIP) $(STRIPFLAGS) $@
endif
libstpool.a:$(addprefix $(OBJS_DIR)/, $(OBJS_stpool)) libmsglog.a
$(AR) $(ARFLAGS) $@ $(filter-out ligmsglog.a, $^)
chmod +x $@
ifeq ($(STRIP_LIB), yes)
$(STRIP) $(STRIPFLAGS) $@
endif
libstpool.so:$(addprefix $(OBJS_DIR)/, $(OBJS_stpool)) libmsglog.so
$(CC) --shared -o $@ $^
chmod +x $@
ifeq ($(STRIP_LIB), yes)
$(STRIP) $(STRIPFLAGS) $@
endif
EXAMPLE := $(addprefix examples/, demo demo-pri demo-sche demo-group)
demos: $(EXAMPLE)
LDFLAGS +=-lpthread -lm
ifneq ($(filter -DHAVE_CLOCK_GETTIME, $(CFLAGS)), )
LDFLAGS += -lrt
endif
%demo:$(OBJS_DIR)/demo.o libstpool.a libmsglog.a
$(CC) $^ $(LDFLAGS) -o $@
%demo-pri:$(OBJS_DIR)/demo-pri.o libstpool.a libmsglog.a
$(CC) $^ $(LDFLAGS) -o $@
%demo-sche:$(OBJS_DIR)/demo-sche.o libstpool.a libmsglog.a
$(CC) $^ $(LDFLAGS) -o $@
%demo-group:$(OBJS_DIR)/demo-group.o libstpool.a libmsglog.a
$(CC) $^ $(LDFLAGS) -o $@
$(OBJS_DIR)/%.o:%.c
$(CC) -c $(CFLAGS) -c $^ -o $@
$(OBJS_DIR)/%.o:%.cpp
$(CPP) -c $(CPPFLAGS) -c $^ -o $@
demos-clean:
-@rm $(EXAMPLE)
clean:
-@rm $(OBJS_DIR)/*.o $(ALL_LIBS) $(EXAMPLE) *.o -fr
distclean: clean
-@rm features.mk complier.mk Makefile
install:LIBS
@if [ ! -z $(INSTALL_DIR) ]; then \
if [ ! -d $(INSTALL_DIR)/include ]; then mkdir -p $(INSTALL_DIR)/include || exit 1; fi; \
if [ ! -d $(INSTALL_DIR)/lib ]; then mkdir -p $(INSTALL_DIR)/lib || exit 1; fi; \
echo "cp stpool.h stpool_group.h stpool_caps.h msglog.h $(INSTALL_DIR)/include"; \
cp stpool.h stpool_group.h stpool_caps.h msglog.h $(INSTALL_DIR)/include; \
echo "cp libmsglog.a libmsglog.so libstpool.a libstpool.so $(INSTALL_DIR)/lib"; \
cp libmsglog.a libmsglog.so libstpool.a libstpool.so $(INSTALL_DIR)/lib; \
fi;
uninstall:
@if [ -d $(INSTALL_DIR) ]; then \
if [ -d $(INSTALL_DIR)/include ]; then \
echo "cd $(INSTALL_DIR)/include && rm stpool.h stpool_group.h stpool_caps.h msglog.h"; \
cd $(INSTALL_DIR)/include && rm -fr stpool.h stpool_group.h stpool_caps.h msglog.h 2>/dev/null; \
cd .. && rm -d include; \
cd ..; \
fi; \
if [ -d $(INSTALL_DIR)/lib ]; then \
echo "cd $(INSTALL_DIR)/lib && rm libmsglog.a libmsglog.so libstpool.a libstpool.so"; \
cd $(INSTALL_DIR)/lib && `rm -fr libmsglog.a libmsglog.so libstpool.a libstpool.so 2>/dev/null`; \
cd .. && rm -d lib && cd ..; \
fi;\
rm -d $(INSTALL_DIR); \
fi;