xref: /freebsd/share/mk/bsd.symver.mk (revision 7ef62cebc2f965b0f640263e179276928885e33d)
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.if ${MAKE_VERSION} >= 20230123
18_mpath= ${.SYSPATH}
19.else
20# Compute the make's -m path.
21_mpath=
22_oarg=
23.for _arg in ${.MAKEFLAGS}
24.if ${_oarg} == "-m"
25_mpath+= ${_arg}
26.endif
27_oarg=  ${_arg}
28.endfor
29_mpath+= /usr/share/mk
30.endif
31
32# Look up ${VERSION_GEN} in ${_mpath}.
33_vgen=
34.for path in ${_mpath}
35.if empty(_vgen)
36.if exists(${path}/${VERSION_GEN})
37_vgen=  ${path}/${VERSION_GEN}
38.endif
39.endif
40.endfor
41.if empty(_vgen)
42.error ${VERSION_GEN} not found in the search path.
43.endif
44
45# Run the symbol maps through the C preprocessor before passing
46# them to the symbol version generator.
47${VERSION_MAP}: ${VERSION_DEF} ${_vgen} ${SYMBOL_MAPS}
48	cat ${SYMBOL_MAPS} | ${CPP} - - \
49	    | awk -v vfile=${VERSION_DEF} -f ${_vgen} > ${.TARGET}
50.endif	# !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
51.endif  # !target(__<bsd.symver.mk>__)
52