xref: /freebsd/contrib/bmake/mk/libs.mk (revision 6e660824a82f590542932de52f128db584029893)
1# $Id: libs.mk,v 1.2 2007/04/30 17:39:27 sjg Exp $
2#
3#	@(#) Copyright (c) 2006, Simon J. Gerraty
4#
5#	This file is provided in the hope that it will
6#	be of use.  There is absolutely NO WARRANTY.
7#	Permission to copy, redistribute or otherwise
8#	use this file is hereby granted provided that
9#	the above copyright notice and this notice are
10#	left intact.
11#
12#	Please send copies of changes and bug-fixes to:
13#	sjg@crufty.net
14#
15
16.MAIN: all
17
18.if defined(LIBS)
19
20.ifndef LIB
21.for t in ${LIBS:R:T:S,^lib,,}
22.if make(lib$t)
23LIB?= $t
24lib$t: all
25.endif
26.endfor
27.endif
28
29.if defined(LIB)
30# just one of many
31.for v in DPADD SRCS CFLAGS ${LIB_VARS}
32$v += ${${v}_lib${LIB}}
33.endfor
34# ensure that we don't clobber each other's dependencies
35DEPENDFILE?= .depend.${LIB}
36# lib.mk will do the rest
37.else
38all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
39.endif
40.endif
41
42# handle being called [bsd.]libs.mk
43.include <${.PARSEFILE:S,libs,lib,}>
44
45.ifndef LIB
46.for t in ${LIBS:R:T:S,^lib,,}
47lib$t.a: ${SRCS} ${DPADD} ${SRCS_lib$t} ${DPADD_lib$t}
48	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t)
49
50clean: $t.clean
51$t.clean:
52	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t ${@:E})
53.endfor
54.endif
55