1 # $NetBSD: archive.mk,v 1.11 2020/11/15 14:07:53 rillig Exp $
3 # Very basic demonstration of handling archives, based on the description
4 # in PSD.doc/tutorial.ms.
6 # This test aims at covering the code, not at being an introduction to
7 # archive handling. That's why it deviates from the tutorial style of
11 FILES= archive.mk modmisc.mk varmisc.mk
14 .if ${.PARSEDIR:tA} != ${.CURDIR:tA}
15 @cd ${MAKEFILE:H} && cp ${FILES} [at]*.mk ${.CURDIR}
17 # The following targets create and remove files. The filesystem cache in
18 # dir.c would probably not handle this correctly, therefore each of the
19 # targets is run in its separate sub-make.
20 @${MAKE} -f ${MAKEFILE} remove-archive
21 @${MAKE} -f ${MAKEFILE} create-archive
22 @${MAKE} -f ${MAKEFILE} list-archive
23 @${MAKE} -f ${MAKEFILE} list-archive-wildcard
24 @${MAKE} -f ${MAKEFILE} depend-on-existing-member
25 @${MAKE} -f ${MAKEFILE} depend-on-nonexistent-member
26 @${MAKE} -f ${MAKEFILE} remove-archive
28 create-archive: ${ARCHIVE} pre post
30 # The indirect references with the $$ cover the code in Arch_ParseArchive
31 # that calls Var_Parse. It's an esoteric scenario since at the point where
32 # Arch_ParseArchive is called, the dependency line is already fully expanded.
34 ${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post
35 ar cru ${.TARGET} ${.OODATE:O}
38 list-archive: ${ARCHIVE} pre post
41 # XXX: I had expected that this dependency would select all *.mk files from
42 # the archive. Instead, the globbing is done in the current directory.
44 # To prevent an overly long file list, the pattern is restricted to [at]*.mk.
45 list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post
46 @printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@}
48 depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post
51 depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) pre post
54 remove-archive: pre post
58 @echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE:O}