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