-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
105 lines (81 loc) · 1.93 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
#
# DSTC top-level makefile.
# Builds code and examples
#
.PHONY: all clean distclean install uninstall examples install_examples
EXT_HDR=dstc.h
HDR=${EXT_HDR} dstc_internal.h
INCLUDES=-I/usr/local/include
#
# Poll build
#
#
# Epoll build
#
SRC=dstc.c poll.c epoll.c
OBJ=${patsubst %.c, %.o, ${SRC}}
LIB_TARGET=libdstc.a
LIB_SO_TARGET=libdstc.so
DESTDIR ?= /usr/local
export DESTDIR
ifeq (${POLL}, 1)
USE_POLL=-DUSE_POLL=1
export USE_POLL
endif
CFLAGS ?=-fPIC -O2 ${INCLUDES} -Wall -pthread -D_GNU_SOURCE ${USE_POLL} #-DDSTC_PTHREAD_DEBUG
#
# Build the entire project.
#
all: ${LIB_TARGET} ${LIB_SO_TARGET}
#
# Rebuild the static target library.
#
${LIB_TARGET}: ${OBJ}
ar r ${LIB_TARGET} ${OBJ}
#
# Rebuild the shared object target library.b
#
${LIB_SO_TARGET}: ${OBJ}
${CC} -shared ${CFLAGS} ${OBJ} -o ${LIB_SO_TARGET}
${OBJ}: ${SRC} ${HDR}
${CC} -c ${CFLAGS} ${patsubst %.o,%.c, $@} -o $@
#
# Remove all the generated files in this project. Note that this does NOT
# remove the generated files in the submodules. Use "make distclean" to
# clean up the submodules.
#
clean:
rm -f ${OBJ} *~ ${LIB_TARGET} ${LIB_SO_TARGET}
@${MAKE} -C examples clean;
#
# Remove all of the generated files including any in the submodules.
#
distclean: clean
@${MAKE} clean
#
# Install the generated files.
#
install: ${LIB_SO_TARGET} ${LIB_TARGET}
install -d ${DESTDIR}/lib; \
install -d ${DESTDIR}/include; \
install -m 0644 ${LIB_TARGET} ${DESTDIR}/lib; \
install -m 0644 ${EXT_HDR} ${DESTDIR}/include; \
install -m 0644 ${LIB_SO_TARGET} ${DESTDIR}/lib;
#
# Uninstall the generated files.
#
uninstall:
@${MAKE} DESTDIR=${DESTDIR} -C examples uninstall; \
rm -f ${DESTDIR}/lib/${LIB_TARGET}; \
rm -f ${DESTDIR}/include/${EXT_HDR}; \
rm -f ${DESTDIR}/lib/${LIB_SO_TARGET};
#
# Build the examples only.
#
examples: all
${MAKE} -C examples
#
# Install the generated example files.
#
install_examples:
${MAKE} DESTDIR=${DESTDIR} -C examples install