xref: /freebsd/contrib/bmake/mk/libs.mk (revision 71e8eac4fd89dedbcb4130379add151d3ed942fa)
1# $Id: libs.mk,v 1.3 2013/08/02 18:28:48 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# In meta mode, we can capture dependenices for _one_ of the progs.
21# if makefile doesn't nominate one, we use the first.
22.ifndef UPDATE_DEPENDFILE_LIB
23UPDATE_DEPENDFILE_LIB = ${LIBS:[1]}
24.export UPDATE_DEPENDFILE_LIB
25.endif
26
27.ifndef LIB
28# They may have asked us to build just one
29.for t in ${LIBS:R:T:S,^lib,,}
30.if make(lib$t)
31LIB?= $t
32lib$t: all
33.endif
34.endfor
35.endif
36
37.if defined(LIB)
38# just one of many
39LIB_VARS += \
40	LIBDIR \
41	CFLAGS \
42	COPTS \
43	CPPFLAGS \
44	CXXFLAGS \
45	DPADD \
46	DPLIBS \
47	LDADD \
48	LDFLAGS \
49	MAN \
50	SRCS
51
52.for v in ${LIB_VARS:O:u}
53.if defined(${v}.${LIB}) || defined(${v}_${LIB})
54$v += ${${v}_${LIB}:U${${v}.${LIB}}}
55.endif
56.endfor
57
58# for meta mode, there can be only one!
59.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
60UPDATE_DEPENDFILE ?= yes
61.endif
62UPDATE_DEPENDFILE ?= NO
63
64# ensure that we don't clobber each other's dependencies
65DEPENDFILE?= .depend.${LIB}
66# lib.mk will do the rest
67.else
68all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
69
70# We cannot capture dependencies for meta mode here
71UPDATE_DEPENDFILE = NO
72# nor can we safely run in parallel.
73.NOTPARALLEL:
74.endif
75.endif
76
77# handle being called [bsd.]libs.mk
78.include <${.PARSEFILE:S,libs,lib,}>
79
80.ifndef LIB
81# tell libs.mk we might want to install things
82LIBS_TARGETS+= cleandepend cleandir cleanobj depend install
83
84.for b in ${LIBS:R:T:S,^lib,,}
85lib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b}
86	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b)
87
88.for t in ${LIBS_TARGETS:O:u}
89$b.$t: .PHONY .MAKE
90	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E})
91.endfor
92.endfor
93.endif
94