summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.lib.mk
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2006-03-16 15:12:26 +0000
committerdeischen <deischen@FreeBSD.org>2006-03-16 15:12:26 +0000
commitf015ed90ef10b6441ebea1eeea6b674292b2a409 (patch)
treea29e23af9ef6c7cb60f24ad846edcea7f30793cb /share/mk/bsd.lib.mk
parent0e5649aea42e035e59ac22a96d0c2c72328bf2f9 (diff)
downloadFreeBSD-src-f015ed90ef10b6441ebea1eeea6b674292b2a409.zip
FreeBSD-src-f015ed90ef10b6441ebea1eeea6b674292b2a409.tar.gz
Teach bsd.lib.mk to auto generate a version map file based on
a set of symbol definitions (VERSION_DEF) and symbol mappings (SYMBOL_MAPS). Add an awk script to generate the version map. Suggested by: ru Helped by: ru Reviewed by: ru
Diffstat (limited to 'share/mk/bsd.lib.mk')
-rw-r--r--share/mk/bsd.lib.mk40
1 files changed, 40 insertions, 0 deletions
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index c60c133..02f1d46 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -99,6 +99,46 @@ PO_FLAG=-pg
all: objwarn
+# Generate the version map given the version definitions
+# and symbol maps.
+.if !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
+# Find the awk script that generates the version map.
+VERSION_GEN?= version_gen.awk
+VERSION_MAP?= Version.map
+
+# Compute the make's -m path.
+_mpath=
+_oarg=
+.for _arg in ${.MAKEFLAGS}
+.if ${_oarg} == "-m"
+_mpath+= ${_arg}
+.endif
+_oarg= ${_arg}
+.endfor
+_mpath+= /usr/share/mk
+
+# Look up ${VERSION_GEN} in ${_mpath}.
+_vgen=
+.for path in ${_mpath}
+.if empty(_vgen)
+.if exists(${path}/${VERSION_GEN})
+_vgen= ${path}/${VERSION_GEN}
+.endif
+.endif
+.endfor
+
+${VERSION_MAP}:
+ awk -v vfile=${VERSION_DEF} -f ${_vgen} ${SYMBOL_MAPS} \
+ > ${.TARGET}
+.endif # !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
+
+# Allow librararies to specify their own version map or have it
+# automatically generated (see above).
+.if !empty(VERSION_MAP)
+${SHLIB_NAME}: ${VERSION_MAP}
+LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
+.endif
+
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
.endif
OpenPOWER on IntegriCloud