| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: archive.mk,v 1.9 2020/10/08 18:37:26 rillig Exp $ | | 1 | # $NetBSD: archive.mk,v 1.10 2020/10/09 06:44:42 rillig Exp $ |
2 | # | | 2 | # |
3 | # Very basic demonstration of handling archives, based on the description | | 3 | # Very basic demonstration of handling archives, based on the description |
4 | # in PSD.doc/tutorial.ms. | | 4 | # in PSD.doc/tutorial.ms. |
5 | # | | 5 | # |
6 | # This test aims at covering the code, not at being an introduction to | | 6 | # This test aims at covering the code, not at being an introduction to |
7 | # archive handling. That's why it is more complicated and detailed than | | 7 | # archive handling. That's why it is more complicated and detailed than |
8 | # strictly necessary. | | 8 | # strictly necessary. |
9 | | | 9 | |
10 | ARCHIVE= libprog.a | | 10 | ARCHIVE= libprog.a |
11 | FILES= archive.mk modmisc.mk varmisc.mk | | 11 | FILES= archive.mk modmisc.mk varmisc.mk |
12 | | | 12 | |
13 | MAKE_CMD= ${.MAKE} -f ${MAKEFILE} | | 13 | MAKE_CMD= ${.MAKE} -f ${MAKEFILE} |
14 | RUN?= @set -eu; | | 14 | RUN?= @set -eu; |
| @@ -25,38 +25,38 @@ all: | | | @@ -25,38 +25,38 @@ all: |
25 | ${RUN} ${MAKE_CMD} list-archive | | 25 | ${RUN} ${MAKE_CMD} list-archive |
26 | ${RUN} ${MAKE_CMD} list-archive-wildcard | | 26 | ${RUN} ${MAKE_CMD} list-archive-wildcard |
27 | ${RUN} ${MAKE_CMD} depend-on-existing-member | | 27 | ${RUN} ${MAKE_CMD} depend-on-existing-member |
28 | ${RUN} ${MAKE_CMD} depend-on-nonexistent-member | | 28 | ${RUN} ${MAKE_CMD} depend-on-nonexistent-member |
29 | ${RUN} ${MAKE_CMD} remove-archive | | 29 | ${RUN} ${MAKE_CMD} remove-archive |
30 | | | 30 | |
31 | create-archive: ${ARCHIVE} pre post | | 31 | create-archive: ${ARCHIVE} pre post |
32 | | | 32 | |
33 | # The indirect references with the $$ cover the code in Arch_ParseArchive | | 33 | # The indirect references with the $$ cover the code in Arch_ParseArchive |
34 | # that calls Var_Parse. It's an esoteric scenario since at the point where | | 34 | # that calls Var_Parse. It's an esoteric scenario since at the point where |
35 | # Arch_ParseArchive is called, the dependency line is already fully expanded. | | 35 | # Arch_ParseArchive is called, the dependency line is already fully expanded. |
36 | # | | 36 | # |
37 | ${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post | | 37 | ${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post |
38 | ar cru ${.TARGET} ${.OODATE} | | 38 | ar cru ${.TARGET} ${.OODATE:O} |
39 | ranlib ${.TARGET} | | 39 | ranlib ${.TARGET} |
40 | | | 40 | |
41 | list-archive: ${ARCHIVE} pre post | | 41 | list-archive: ${ARCHIVE} pre post |
42 | ar t ${.ALLSRC} | | 42 | ar t ${.ALLSRC} |
43 | | | 43 | |
44 | # XXX: I had expected that this dependency would select all *.mk files from | | 44 | # XXX: I had expected that this dependency would select all *.mk files from |
45 | # the archive. Instead, the globbing is done in the current directory. | | 45 | # the archive. Instead, the globbing is done in the current directory. |
46 | # To prevent an overly long file list, the pattern is restricted to [at]*.mk. | | 46 | # To prevent an overly long file list, the pattern is restricted to [at]*.mk. |
47 | list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post | | 47 | list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post |
48 | ${RUN} printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} | | 48 | ${RUN} printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} |
49 | | | 49 | |
50 | depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post | | 50 | depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post |
51 | ${RUN} echo $@ | | 51 | ${RUN} echo $@ |
52 | | | 52 | |
53 | depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) pre post | | 53 | depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) pre post |
54 | ${RUN} echo $@ | | 54 | ${RUN} echo $@ |
55 | | | 55 | |
56 | remove-archive: pre post | | 56 | remove-archive: pre post |
57 | rm -f ${ARCHIVE} | | 57 | rm -f ${ARCHIVE} |
58 | | | 58 | |
59 | pre: .USEBEFORE | | 59 | pre: .USEBEFORE |
60 | @echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE} | | 60 | @echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE:O} |
61 | post: .USE | | 61 | post: .USE |
62 | @echo | | 62 | @echo |