Simon J. Gerraty 2c3632d14f Update to bmake-20200902
Lots of code refactoring, simplification and cleanup.
Lots of new unit-tests providing much higher code coverage.
All courtesy of rillig at netbsd.

Other significant changes:

o new read-only variable .SHELL which provides the path of the shell
  used to run scripts (as defined by  the .SHELL target).

o variable parsing detects more errors.

o new debug option -dl: LINT mode, does the equivalent of := for all
  variable assignments so that file and line number are reported for
  variable parse errors.
2020-09-05 19:29:42 +00:00

46 lines
1.2 KiB
Makefile

# $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}