1763
|
1 #
|
|
2 # Copyright (c) 2007, Jonathan Schleifer <js@h3c.de>
|
|
3 #
|
|
4 # Permission to use, copy, modify, and/or distribute this software for any
|
|
5 # purpose with or without fee is hereby granted, provided that the above
|
|
6 # copyright notice and this permission notice is present in all copies.
|
|
7 #
|
|
8 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
9 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
10 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
11 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
12 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
13 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
14 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
15 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
16 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
17 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
18 # POSSIBILITY OF SUCH DAMAGE.
|
|
19 #
|
|
20
|
|
21 PACKAGE = @PACKAGE@
|
|
22 CC = @CC@
|
|
23 CXX = @CXX@
|
|
24 CPP = @CPP@
|
|
25 DC = @DC@
|
|
26 ERLC = @ERLC@
|
|
27 OBJC = @OBJC@
|
|
28 AR = @AR@
|
|
29 LD = ${CC}
|
|
30 CFLAGS = @CFLAGS@
|
|
31 CXXFLAGS = @CXXFLAGS@
|
|
32 CPPFLAGS = @CPPFLAGS@
|
|
33 DFLAGS = @DFLAGS@
|
|
34 ERLCFLAGS = @ERLCFLAGS@
|
|
35 OBJCFLAGS = @OBJCFLAGS@
|
|
36 LDFLAGS = @LDFLAGS@
|
|
37 LIBS = @LIBS@
|
|
38 LIB_CPPFLAGS = @LIB_CPPFLAGS@
|
|
39 LIB_CFLAGS = @LIB_CFLAGS@
|
|
40 LIB_LDFLAGS = @LIB_LDFLAGS@
|
|
41 LIB_PREFIX = @LIB_PREFIX@
|
|
42 LIB_SUFFIX = @LIB_SUFFIX@
|
|
43 PLUGIN_CPPFLAGS = @PLUGIN_CPPFLAGS@
|
|
44 PLUGIN_CFLAGS = @PLUGIN_CFLAGS@
|
|
45 PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
|
|
46 PLUGIN_SUFFIX = @PLUGIN_SUFFIX@
|
|
47 INSTALL_LIB = @INSTALL_LIB@
|
|
48 UNINSTALL_LIB = @UNINSTALL_LIB@
|
|
49 CLEAN_LIB = @CLEAN_LIB@
|
|
50 LN_S = @LN_S@
|
|
51 MKDIR_P = mkdir -p
|
|
52 INSTALL = @INSTALL@
|
|
53 SHELL = @SHELL@
|
|
54 prefix = @prefix@
|
|
55 exec_prefix = @exec_prefix@
|
|
56 bindir = @bindir@
|
|
57 libdir = @libdir@
|
|
58 plugindir ?= ${PACKAGE}
|
|
59 datarootdir = @datarootdir@
|
|
60 datadir = @datadir@
|
|
61 includedir = @includedir@
|
|
62 includesubdir ?= ${PACKAGE}
|
|
63 mandir = @mandir@
|
|
64 mansubdir ?= man1
|
|
65
|
|
66 OBJS1 = ${SRCS:.c=.o}
|
|
67 OBJS2 = ${OBJS1:.cc=.o}
|
|
68 OBJS3 = ${OBJS2:.cxx=.o}
|
|
69 OBJS4 = ${OBJS3:.d=.o}
|
|
70 OBJS5 = ${OBJS4:.erl=.beam}
|
|
71 OBJS += ${OBJS5:.m=.o}
|
|
72
|
|
73 .SILENT:
|
|
74 .SUFFIXES: .beam .c .cc .cxx .d .erl .m
|
|
75 .PHONY: all subdirs depend install uninstall clean distclean
|
|
76
|
|
77 all: subdirs depend ${OBJS} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${LIB} ${LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${PROG} ${PROG_NOINST}
|
|
78
|
|
79 subdirs:
|
|
80 for i in ${SUBDIRS}; do \
|
|
81 ${DIR_ENTER}; \
|
|
82 ${MAKE} ${MFLAGS} || exit 1; \
|
|
83 ${DIR_LEAVE}; \
|
|
84 done
|
|
85
|
|
86 depend: pre-depend ${SRCS}
|
|
87 regen=0; \
|
|
88 for i in ${SRCS}; do [ $$i -nt .deps ] && regen=1; done; \
|
|
89 if [ $$regen = 1 ]; then \
|
|
90 rm -f .deps; \
|
|
91 for i in ${SRCS}; do \
|
|
92 case $${i##*.} in \
|
|
93 c|cc|cxx|m) \
|
|
94 ${CPP} ${CPPFLAGS} -M $$i >>.deps; \
|
|
95 esac; \
|
|
96 done; \
|
|
97 fi
|
|
98
|
|
99 pre-depend:
|
|
100
|
|
101 ${PROG} ${PROG_NOINST}: ${EXT_DEPS} ${OBJS} ${LIB_DEPS}
|
|
102 ${LINK_STATUS}
|
|
103 if ${LD} -o $@ ${OBJS} ${LDFLAGS} ${LIBS}; then \
|
|
104 ${LINK_OK}; \
|
|
105 else \
|
|
106 ${LINK_FAILED}; \
|
|
107 fi
|
|
108
|
|
109 ${LIB} ${LIB_NOINST}: ${EXT_DEPS} ${OBJS}
|
|
110 ${LINK_STATUS}
|
|
111 if ${LD} -o $@ ${OBJS} ${LIB_LDFLAGS} ${LDFLAGS} ${LIBS}; then \
|
|
112 ${LINK_OK}; \
|
|
113 else \
|
|
114 ${LINK_FAILED}; \
|
|
115 fi
|
|
116
|
|
117 ${PLUGIN} ${PLUGIN_NONST}: ${EXT_DEPS} ${OBJS}
|
|
118 ${LINK_STATUS}
|
|
119 if ${LD} -o $@ ${OBJS} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}; then \
|
|
120 ${LINK_OK}; \
|
|
121 else \
|
|
122 ${LINK_FAILED}; \
|
|
123 fi
|
|
124
|
|
125 ${STATIC_LIB} ${STATIC_LIB_NOINST}: ${EXT_DEPS} ${OBJS}
|
|
126 ${LINK_STATUS}
|
|
127 if ${AR} cr $@ ${OBJS}; then \
|
|
128 ${LINK_OK}; \
|
|
129 else \
|
|
130 ${LINK_FAILED}; \
|
|
131 fi
|
|
132
|
|
133 ${EXT_DEPS}: subdirs
|
|
134
|
|
135 .c.o:
|
|
136 ${COMPILE_STATUS}
|
|
137 if ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
|
|
138 ${COMPILE_OK}; \
|
|
139 else \
|
|
140 ${COMPILE_FAILED}; \
|
|
141 fi
|
|
142
|
|
143 .cc.o .cxx.o:
|
|
144 ${COMPILE_STATUS}
|
|
145 if ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
|
|
146 ${COMPILE_OK}; \
|
|
147 else \
|
|
148 ${COMPILE_FAILED}; \
|
|
149 fi
|
|
150
|
|
151 .d.o:
|
|
152 ${COMPILE_STATUS}
|
|
153 if test x"$(basename ${DC})" = x"dmd"; then \
|
|
154 if ${DC} ${DFLAGS} -c -of$@ $<; then \
|
|
155 ${COMPILE_OK}; \
|
|
156 else \
|
|
157 ${COMPILE_FAILED}; \
|
|
158 fi \
|
|
159 else \
|
|
160 if ${DC} ${DFLAGS} -c -o $@ $<; then \
|
|
161 ${COMPILE_OK}; \
|
|
162 else \
|
|
163 ${COMPILE_FAILED}; \
|
|
164 fi \
|
|
165 fi
|
|
166
|
|
167 .erl.beam:
|
|
168 ${COMPILE_STATUS}
|
|
169 if ${ERLC} ${ERLCFLAGS} -o $@ $<; then \
|
|
170 ${COMPILE_OK}; \
|
|
171 else \
|
|
172 ${COMPILE_FAILED}; \
|
|
173 fi
|
|
174
|
|
175 .m.o:
|
|
176 ${COMPILE_STATUS}
|
|
177 if ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
|
|
178 ${COMPILE_OK}; \
|
|
179 else \
|
|
180 ${COMPILE_FAILED}; \
|
|
181 fi
|
|
182
|
|
183 install: ${LIB} ${STATIC_LIB} ${PLUGIN} ${PROG} install-extra
|
|
184 for i in ${SUBDIRS}; do \
|
|
185 ${DIR_ENTER}; \
|
|
186 ${MAKE} ${MFLAGS} install || exit 1; \
|
|
187 ${DIR_LEAVE}; \
|
|
188 done
|
|
189
|
|
190 for i in ${LIB}; do \
|
|
191 ${INSTALL_STATUS}; \
|
|
192 if ${MKDIR_P} ${DESTDIR}${libdir} && ${INSTALL_LIB}; then \
|
|
193 ${INSTALL_OK}; \
|
|
194 else \
|
|
195 ${INSTALL_FAILED}; \
|
|
196 fi \
|
|
197 done
|
|
198
|
|
199 for i in ${STATIC_LIB}; do \
|
|
200 ${INSTALL_STATUS}; \
|
|
201 if ${MKDIR_P} ${DESTDIR}${libdir} && ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i; then \
|
|
202 ${INSTALL_OK}; \
|
|
203 else \
|
|
204 ${INSTALL_FAILED}; \
|
|
205 fi \
|
|
206 done
|
|
207
|
|
208 for i in ${PLUGIN}; do \
|
|
209 ${INSTALL_STATUS}; \
|
|
210 if ${MKDIR_P} ${DESTDIR}${libdir}/${plugindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/${plugindir}/$$i; then \
|
|
211 ${INSTALL_OK}; \
|
|
212 else \
|
|
213 ${INSTALL_FAILED}; \
|
|
214 fi \
|
|
215 done
|
|
216
|
|
217 for i in ${DATA}; do \
|
|
218 ${INSTALL_STATUS}; \
|
|
219 if ${MKDIR_P} $$(dirname ${DESTDIR}${datadir}/${PACKAGE}/$$i) && ${INSTALL} -m 644 $$i ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
|
|
220 ${INSTALL_OK}; \
|
|
221 else \
|
|
222 ${INSTALL_FAILED}; \
|
|
223 fi \
|
|
224 done
|
|
225
|
|
226 for i in ${PROG}; do \
|
|
227 ${INSTALL_STATUS}; \
|
|
228 if ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 -s $$i ${DESTDIR}${bindir}/$$i; then \
|
|
229 ${INSTALL_OK}; \
|
|
230 else \
|
|
231 ${INSTALL_FAILED}; \
|
|
232 fi \
|
|
233 done
|
|
234
|
|
235 for i in ${INCLUDES}; do \
|
|
236 ${INSTALL_STATUS}; \
|
|
237 if ${MKDIR_P} ${DESTDIR}${includedir}/${includesubdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
|
|
238 ${INSTALL_OK}; \
|
|
239 else \
|
|
240 ${INSTALL_FAILED}; \
|
|
241 fi \
|
|
242 done
|
|
243
|
|
244 for i in ${MAN}; do \
|
|
245 ${INSTALL_STATUS}; \
|
|
246 if ${MKDIR_P} ${DESTDIR}${mandir}/${mansubdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
|
|
247 ${INSTALL_OK}; \
|
|
248 else \
|
|
249 ${INSTALL_FAILED}; \
|
|
250 fi \
|
|
251 done
|
|
252
|
|
253 install-extra:
|
|
254
|
|
255 uninstall: uninstall-extra
|
|
256 for i in ${SUBDIRS}; do \
|
|
257 ${DIR_ENTER}; \
|
|
258 ${MAKE} ${MFLAGS} uninstall || exit 1; \
|
|
259 ${DIR_LEAVE}; \
|
|
260 done
|
|
261
|
|
262 for i in ${LIB}; do \
|
|
263 if [ -f ${DESTDIR}${libdir}/$$i ]; then \
|
|
264 if ${UNINSTALL_LIB}; then \
|
|
265 ${DELETE_OK}; \
|
|
266 else \
|
|
267 ${DELETE_FAILED}; \
|
|
268 fi \
|
|
269 fi; \
|
|
270 done
|
|
271
|
|
272 for i in ${STATIC_LIB}; do \
|
|
273 if [ -f ${DESTDIR}${libdir}/$$i ]; then \
|
|
274 if rm -f ${DESTDIR}${libdir}/$$i; then \
|
|
275 ${DELETE_OK}; \
|
|
276 else \
|
|
277 ${DELETE_FAILED}; \
|
|
278 fi \
|
|
279 fi \
|
|
280 done
|
|
281
|
|
282 for i in ${PLUGIN}; do \
|
|
283 if [ -f ${DESTDIR}${libdir}/${plugindir}/$$i ]; then \
|
|
284 if rm -f ${DESTDIR}${libdir}/${plugindir}/$$i; then \
|
|
285 ${DELETE_OK}; \
|
|
286 else \
|
|
287 ${DELETE_FAILED}; \
|
|
288 fi \
|
|
289 fi \
|
|
290 done
|
|
291 -rmdir ${DESTDIR}${libdir}/${plugindir} >/dev/null 2>&1
|
|
292
|
|
293 for i in ${DATA}; do \
|
|
294 if [ -f ${DESTDIR}${datadir}/${PACKAGE}/$$i ]; then \
|
|
295 if rm -f ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
|
|
296 ${DELETE_OK}; \
|
|
297 else \
|
|
298 ${DELETE_FAILED}; \
|
|
299 fi \
|
|
300 fi \
|
|
301 done
|
|
302
|
|
303 for i in ${PROG}; do \
|
|
304 if [ -f ${DESTDIR}${bindir}/$$i ]; then \
|
|
305 if rm -f ${DESTDIR}${bindir}/$$i; then \
|
|
306 ${DELETE_OK}; \
|
|
307 else \
|
|
308 ${DELETE_FAILED}; \
|
|
309 fi \
|
|
310 fi \
|
|
311 done
|
|
312
|
|
313 for i in ${INCLUDES}; do \
|
|
314 if [ -f ${DESTDIR}${includedir}/${includesubdir}/$$i ]; then \
|
|
315 if rm -f ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
|
|
316 ${DELETE_OK}; \
|
|
317 else \
|
|
318 ${DELETE_FAILED}; \
|
|
319 fi \
|
|
320 fi \
|
|
321 done
|
|
322 -rmdir ${DESTDIR}${includedir}/${includesubdir} >/dev/null 2>&1
|
|
323
|
|
324 for i in ${MAN}; do \
|
|
325 if [ -f ${DESTDIR}${mandir}/${mansubdir}/$$i ]; then \
|
|
326 if rm -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
|
|
327 ${DELETE_OK}; \
|
|
328 else \
|
|
329 ${DELETE_FAILED}; \
|
|
330 fi \
|
|
331 fi \
|
|
332 done
|
|
333
|
|
334 uninstall-extra:
|
|
335
|
|
336 clean:
|
|
337 for i in ${SUBDIRS}; do \
|
|
338 ${DIR_ENTER}; \
|
|
339 ${MAKE} ${MFLAGS} clean || exit 1; \
|
|
340 ${DIR_LEAVE}; \
|
|
341 done
|
|
342
|
|
343 for i in ${OBJS} ${CLEAN} ${CLEAN_LIB} .deps *~; do \
|
|
344 if [ -f $$i -o -d $$i ]; then \
|
|
345 if rm -fr $$i; then \
|
|
346 ${DELETE_OK}; \
|
|
347 else \
|
|
348 ${DELETE_FAILED}; \
|
|
349 fi \
|
|
350 fi \
|
|
351 done
|
|
352
|
|
353 distclean: clean
|
|
354 for i in ${SUBDIRS}; do \
|
|
355 ${DIR_ENTER}; \
|
|
356 ${MAKE} ${MFLAGS} distclean || exit 1; \
|
|
357 ${DIR_LEAVE}; \
|
|
358 done
|
|
359
|
|
360 for i in ${PROG} ${PROG_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${DISTCLEAN}; do \
|
|
361 if [ -f $$i -o -d $$i ]; then \
|
|
362 if rm -fr $$i; then \
|
|
363 ${DELETE_OK}; \
|
|
364 else \
|
|
365 ${DELETE_FAILED}; \
|
|
366 fi \
|
|
367 fi \
|
|
368 done
|
|
369
|
|
370 DIR_ENTER = printf "\033[0;36mEntering directory \033[1;36m$$i\033[0;36m.\033[0m\n"; cd $$i || exit 1
|
|
371 DIR_LEAVE = printf "\033[0;36mLeaving directory \033[1;36m$$i\033[0;36m.\033[0m\n"; cd .. || exit 1
|
|
372 LINK_STATUS = printf "\033[0;33mLinking \033[1;33m$@\033[0;33m...\033[0m\r"
|
|
373 LINK_OK = printf "\033[0;32mSuccessfully linked \033[1;32m$@\033[0;32m.\033[0m\n"
|
|
374 LINK_FAILED = printf "\033[0;31mFailed to link \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
|
|
375 COMPILE_STATUS = printf "\033[0;33mCompiling \033[1;33m$<\033[0;33m...\033[0m\r"
|
|
376 COMPILE_OK = printf "\033[0;32mSuccessfully compiled \033[1;32m$<\033[0;32m.\033[0m\n"
|
|
377 COMPILE_FAILED = printf "\033[0;31mFailed to compile \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
|
|
378 INSTALL_STATUS = printf "\033[0;33mInstalling \033[1;33m$$i\033[0;33m...\033[0m\r"
|
|
379 INSTALL_OK = printf "\033[0;32mSuccessfully installed \033[1;32m$$i\033[0;32m.\033[0m\n"
|
|
380 INSTALL_FAILED = printf "\033[0;31mFailed to install \033[1;31m$$i\033[0;31m!\033[0m\n"; exit 1
|
|
381 DELETE_OK = printf "\033[0;34mDeleted \033[1;34m$$i\033[0;34m.\033[0m\n"
|
|
382 DELETE_FAILED = printf "\033[0;31mFailed to delete \033[1;31m$$i\033[0;31m!\033[0m\n"; exit 1
|
|
383
|
|
384 -include .deps
|