1168317Skan# $FreeBSD$
2168317Skan
3168317Skan.if !target(__<bsd.symver.mk>__)
4168317Skan__<bsd.symver.mk>__:
5168317Skan
6168317Skan.include <bsd.init.mk>
7168317Skan
8168317Skan# Generate the version map given the version definitions
9168317Skan# and symbol maps.
10169822Sru.if ${MK_SYMVER} == "yes" && !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
11168317Skan# Find the awk script that generates the version map.
12168317SkanVERSION_GEN?=	version_gen.awk
13168317SkanVERSION_MAP?=	Version.map
14168317Skan
15168317SkanCLEANFILES+=	${VERSION_MAP}
16168317Skan
17168317Skan# Compute the make's -m path.
18168317Skan_mpath=
19168317Skan_oarg=
20168317Skan.for _arg in ${.MAKEFLAGS}
21168317Skan.if ${_oarg} == "-m"
22168317Skan_mpath+= ${_arg}
23168317Skan.endif
24168317Skan_oarg=  ${_arg}
25168317Skan.endfor
26168317Skan_mpath+= /usr/share/mk
27168317Skan
28168317Skan# Look up ${VERSION_GEN} in ${_mpath}.
29168317Skan_vgen=
30168317Skan.for path in ${_mpath}
31168317Skan.if empty(_vgen)
32168317Skan.if exists(${path}/${VERSION_GEN})
33168317Skan_vgen=  ${path}/${VERSION_GEN}
34168317Skan.endif
35168317Skan.endif
36168317Skan.endfor
37172755Syar.if empty(_vgen)
38172755Syar.error ${VERSION_GEN} not found in the search path.
39172755Syar.endif
40168317Skan
41169089Sdeischen# Run the symbol maps through the C preprocessor before passing
42169089Sdeischen# them to the symbol version generator.
43168317Skan${VERSION_MAP}: ${VERSION_DEF} ${_vgen} ${SYMBOL_MAPS}
44169089Sdeischen	cat ${SYMBOL_MAPS} | ${CPP} - - \
45169089Sdeischen	    | awk -v vfile=${VERSION_DEF} -f ${_vgen} > ${.TARGET}
46168317Skan.endif	# !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
47168317Skan.endif  # !target(__<bsd.symver.mk>__)
48