1*2c3632d1SSimon J. Gerraty# $NetBSD: archive.mk,v 1.5 2020/08/23 17:51:24 rillig Exp $ 2*2c3632d1SSimon J. Gerraty# 3*2c3632d1SSimon J. Gerraty# Very basic demonstration of handling archives, based on the description 4*2c3632d1SSimon J. Gerraty# in PSD.doc/tutorial.ms. 5*2c3632d1SSimon J. Gerraty 6*2c3632d1SSimon J. GerratyARCHIVE= libprog.${EXT.a} 7*2c3632d1SSimon J. GerratyFILES= archive.${EXT.mk} modmisc.${EXT.mk} varmisc.mk 8*2c3632d1SSimon J. Gerraty 9*2c3632d1SSimon J. GerratyEXT.a= a 10*2c3632d1SSimon J. GerratyEXT.mk= mk 11*2c3632d1SSimon J. Gerraty 12*2c3632d1SSimon J. GerratyMAKE_CMD= ${.MAKE} -f ${MAKEFILE} 13*2c3632d1SSimon J. GerratyRUN?= @set -eu; 14*2c3632d1SSimon J. Gerraty 15*2c3632d1SSimon J. Gerratyall: 16*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} remove-archive 17*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} create-archive 18*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} list-archive 19*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} list-archive-wildcard 20*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} depend-on-existing-member 21*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} depend-on-nonexistent-member 22*2c3632d1SSimon J. Gerraty ${RUN} ${MAKE_CMD} remove-archive 23*2c3632d1SSimon J. Gerraty 24*2c3632d1SSimon J. Gerratycreate-archive: ${ARCHIVE} 25*2c3632d1SSimon J. Gerraty${ARCHIVE}: ${ARCHIVE}(${FILES}) 26*2c3632d1SSimon J. Gerraty ar cru ${.TARGET} ${.OODATE} 27*2c3632d1SSimon J. Gerraty ranlib ${.TARGET} 28*2c3632d1SSimon J. Gerraty 29*2c3632d1SSimon J. Gerratylist-archive: ${ARCHIVE} 30*2c3632d1SSimon J. Gerraty ar t ${.ALLSRC} 31*2c3632d1SSimon J. Gerraty 32*2c3632d1SSimon J. Gerraty# XXX: I had expected that this dependency would select all *.mk files from 33*2c3632d1SSimon J. Gerraty# the archive. Instead, the globbing is done in the current directory. 34*2c3632d1SSimon J. Gerraty# To prevent an overly long file list, the pattern is restricted to [at]*.mk. 35*2c3632d1SSimon J. Gerratylist-archive-wildcard: ${ARCHIVE}([at]*.mk) 36*2c3632d1SSimon J. Gerraty ${RUN} printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} 37*2c3632d1SSimon J. Gerraty 38*2c3632d1SSimon J. Gerratydepend-on-existing-member: ${ARCHIVE}(archive.mk) 39*2c3632d1SSimon J. Gerraty ${RUN} echo $@ 40*2c3632d1SSimon J. Gerraty 41*2c3632d1SSimon J. Gerratydepend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) 42*2c3632d1SSimon J. Gerraty ${RUN} echo $@ 43*2c3632d1SSimon J. Gerraty 44*2c3632d1SSimon J. Gerratyremove-archive: 45*2c3632d1SSimon J. Gerraty rm -f ${ARCHIVE} 46