-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (121 loc) · 4.7 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Atomic Kit is Copyright 2013 Evan Buswell
#
# Atomic Kit is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2.
#
# Atomic Kit is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# Atomic Kit. If not, see <http://www.gnu.org/licenses/>.
.PHONY: shared static all install-headers install-pkgconfig install-shared \
install-static install-static-strip install-shared-strip \
install-all-static install-all-shared install-all-static-strip \
install-all-shared-strip install install-strip uninstall clean \
check-shared check-static check doc
.SUFFIXES: .o .pic.o
include config.mk
VERSION=0.3
SRCS=src/rcp.c src/queue.c src/malloc.c src/array.c src/string.c src/dict.c
TESTSRCS=test/main.c test/test_array_h.c test/test_float_h.c \
test/test_atomic_h.c test/test_malloc_h.c \
test/test_queue_h.c test/test_rcp_h.c test/test.c
HEADERS=include/atomickit/atomic.h \
include/atomickit/float.h \
include/atomickit/pointer.h \
include/atomickit/rcp.h \
include/atomickit/queue.h \
include/atomickit/malloc.h \
include/atomickit/txn.h \
include/atomickit/array.h \
include/atomickit/string.h
ARCHHEADERS=include/${ARCH}/atomickit/arch/atomic.h \
include/${ARCH}/atomickit/arch/misc.h
OBJS=${SRCS:.c=.o}
PICOBJS=${SRCS:.c=.pic.o}
TESTOBJS=${TESTSRCS:.c=.o}
MAJOR=${shell echo ${VERSION}|cut -d . -f 1}
all: shared atomickit.pc
.c.o:
${CC} ${CFLAGS} -c $< -o $@
.c.pic.o:
${CC} ${CFLAGS} -fPIC -c $< -o $@
libatomickit.so: ${PICOBJS}
${CC} ${CFLAGS} -fPIC ${LDFLAGS} -shared ${PICOBJS} -o libatomickit.so
libatomickit.a: ${OBJS}
rm -f libatomickit.a
${AR} ${ARFLAGS}c libatomickit.a ${OBJS}
unittest-shared: libatomickit.so ${TESTOBJS}
${CC} ${CFLAGS} ${LDFLAGS} -L`pwd` -Wl,-rpath,`pwd` \
${TESTOBJS} -latomickit -lpthread -o unittest-shared
unittest-static: libatomickit.a ${TESTOBJS}
${CC} ${CFLAGS} ${LDFLAGS} -static -L`pwd` \
${TESTOBJS} -latomickit -lpthread -o unittest-static
atomickit.pc: atomickit.pc.in config.mk Makefile
sed -e 's!@prefix@!${PREFIX}!g' \
-e 's!@libdir@!${LIBDIR}!g' \
-e 's!@includedir@!${INCLUDEDIR}!g' \
-e 's!@version@!${VERSION}!g' \
atomickit.pc.in >atomickit.pc
shared: libatomickit.so
static: libatomickit.a
install-headers:
(umask 022; mkdir -p ${DESTDIR}${INCLUDEDIR}/atomickit/arch)
install -m 644 -t ${DESTDIR}${INCLUDEDIR}/atomickit ${HEADERS}
install -m 644 -t ${DESTDIR}${INCLUDEDIR}/atomickit/arch \
${ARCHHEADERS}
install-pkgconfig: atomickit.pc
(umask 022; mkdir -p ${DESTDIR}${PKGCONFIGDIR})
install -m 644 atomickit.pc ${DESTDIR}${PKGCONFIGDIR}/atomickit.pc
install-shared: shared
(umask 022; mkdir -p ${DESTDIR}${LIBDIR})
install -m 755 libatomickit.so \
${DESTDIR}${LIBDIR}/libatomickit.so.${VERSION}
ln -frs ${DESTDIR}${LIBDIR}/libatomickit.so.${VERSION} \
${DESTDIR}${LIBDIR}/libatomickit.so.${MAJOR}
ln -frs ${DESTDIR}${LIBDIR}/libatomickit.so.${VERSION} \
${DESTDIR}${LIBDIR}/libatomickit.so
install-static: static
(umask 022; mkdir -p ${DESTDIR}${LIBDIR})
install -m 644 libatomickit.a ${DESTDIR}${LIBDIR}/libatomickit.a
install-shared-strip: install-shared
strip --strip-unneeded ${DESTDIR}${LIBDIR}/libatomickit.so.${VERSION}
install-static-strip: install-static
strip --strip-unneeded ${DESTDIR}${LIBDIR}/libatomickit.a
install-all-static: static atomickit.pc install-static install-headers \
install-pkgconfig
install-all-shared: shared atomickit.pc install-shared install-headers \
install-pkgconfig
install-all-shared-strip: install-all-shared install-shared-strip
install-all-static-strip: install-all-static install-static-strip
install: install-all-shared
install-strip: install-all-shared-strip
uninstall:
rm -f ${DESTDIR}${LIBDIR}/libatomickit.so.${VERSION}
rm -f ${DESTDIR}${LIBDIR}/libatomickit.so.${MAJOR}
rm -f ${DESTDIR}${LIBDIR}/libatomickit.so
rm -f ${DESTDIR}${LIBDIR}/libatomickit.a
rm -f ${DESTDIR}${PKGCONFIGDIR}/atomickit.pc
rm -rf ${DESTDIR}${INCLUDEDIR}/atomickit
clean:
rm -f atomickit.pc
rm -f libatomickit.so
rm -f libatomickit.a
rm -f ${OBJS}
rm -f ${PICOBJS}
rm -f ${TESTOBJS}
rm -f unittest-shared
rm -f unittest-static
rm -rf doc/man
rm -rf doc/html
check-shared: unittest-shared
./unittest-shared
check-static: unittest-static
./unittest-static
check: check-shared
doc: doxygen
doxygen:
doxygen