xref: /freebsd/share/mk/bsd.symver.mk (revision 6ba2210ee039f2f12878c217bcf058e9c8b26b29)
1# $FreeBSD$
2
3.if !target(__<bsd.symver.mk>__)
4__<bsd.symver.mk>__:
5
6.include <bsd.init.mk>
7
8# Generate the version map given the version definitions
9# and symbol maps.
10.if !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
11# Find the awk script that generates the version map.
12VERSION_GEN?=	version_gen.awk
13VERSION_MAP?=	Version.map
14
15CLEANFILES+=	${VERSION_MAP}
16
17# Compute the make's -m path.
18_mpath=
19_oarg=
20.for _arg in ${.MAKEFLAGS}
21.if ${_oarg} == "-m"
22_mpath+= ${_arg}
23.endif
24_oarg=  ${_arg}
25.endfor
26_mpath+= /usr/share/mk
27
28# Look up ${VERSION_GEN} in ${_mpath}.
29_vgen=
30.for path in ${_mpath}
31.if empty(_vgen)
32.if exists(${path}/${VERSION_GEN})
33_vgen=  ${path}/${VERSION_GEN}
34.endif
35.endif
36.endfor
37.if empty(_vgen)
38.error ${VERSION_GEN} not found in the search path.
39.endif
40
41# Run the symbol maps through the C preprocessor before passing
42# them to the symbol version generator.
43${VERSION_MAP}: ${VERSION_DEF} ${_vgen} ${SYMBOL_MAPS}
44	cat ${SYMBOL_MAPS} | ${CPP} - - \
45	    | awk -v vfile=${VERSION_DEF} -f ${_vgen} > ${.TARGET}
46.endif	# !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
47.endif  # !target(__<bsd.symver.mk>__)
48