diff options
Diffstat (limited to 'unit-tests/archive.mk')
-rw-r--r-- | unit-tests/archive.mk | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/unit-tests/archive.mk b/unit-tests/archive.mk new file mode 100644 index 000000000000..c3b7e919eab2 --- /dev/null +++ b/unit-tests/archive.mk @@ -0,0 +1,45 @@ +# $NetBSD: archive.mk,v 1.5 2020/08/23 17:51:24 rillig Exp $ +# +# Very basic demonstration of handling archives, based on the description +# in PSD.doc/tutorial.ms. + +ARCHIVE= libprog.${EXT.a} +FILES= archive.${EXT.mk} modmisc.${EXT.mk} varmisc.mk + +EXT.a= a +EXT.mk= mk + +MAKE_CMD= ${.MAKE} -f ${MAKEFILE} +RUN?= @set -eu; + +all: + ${RUN} ${MAKE_CMD} remove-archive + ${RUN} ${MAKE_CMD} create-archive + ${RUN} ${MAKE_CMD} list-archive + ${RUN} ${MAKE_CMD} list-archive-wildcard + ${RUN} ${MAKE_CMD} depend-on-existing-member + ${RUN} ${MAKE_CMD} depend-on-nonexistent-member + ${RUN} ${MAKE_CMD} remove-archive + +create-archive: ${ARCHIVE} +${ARCHIVE}: ${ARCHIVE}(${FILES}) + ar cru ${.TARGET} ${.OODATE} + ranlib ${.TARGET} + +list-archive: ${ARCHIVE} + ar t ${.ALLSRC} + +# XXX: I had expected that this dependency would select all *.mk files from +# the archive. Instead, the globbing is done in the current directory. +# To prevent an overly long file list, the pattern is restricted to [at]*.mk. +list-archive-wildcard: ${ARCHIVE}([at]*.mk) + ${RUN} printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} + +depend-on-existing-member: ${ARCHIVE}(archive.mk) + ${RUN} echo $@ + +depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) + ${RUN} echo $@ + +remove-archive: + rm -f ${ARCHIVE} |