mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 10:19:04 +00:00
![Simon J. Gerraty](/assets/img/avatar_default.png)
Lots more unit tests and code cleanup Relevant changes from ChangeLog o job.c: Print -de error information when running multiple jobs o var.c: only report error for unmatched regex subexpression when linting (-dL) since we cannot tell when an unmatched subexpression is an expected result. reduce memory allocations in the modifiers ':D' and ':U' reduce memory allocation and strlen calls in modifier ':from=to' in the ':Q' modifier, only allocate memory if necessary improve performance for LazyBuf reduce debug logging and memory allocation for ${:U...} reduce verbosity of the -dv debug logging for standard cases fix double varname expansion in the variable modifier '::=' o var.c: avoid evaluating many modifiers in parse only mode in strict mode (-dL) many variable references are parsed twice, the first time just to report parse errors early, so we want to avoid side effects and wasted effort to the extent possible.
61 lines
2.1 KiB
Makefile
61 lines
2.1 KiB
Makefile
# $NetBSD: archive.mk,v 1.12 2021/04/09 14:42:00 christos Exp $
|
|
#
|
|
# Very basic demonstration of handling archives, based on the description
|
|
# in PSD.doc/tutorial.ms.
|
|
#
|
|
# This test aims at covering the code, not at being an introduction to
|
|
# archive handling. That's why it deviates from the tutorial style of
|
|
# several other tests.
|
|
|
|
ARCHIVE= libprog.a
|
|
FILES= archive.mk archive-suffix.mk modmisc.mk ternary.mk varmisc.mk
|
|
|
|
all:
|
|
.if ${.PARSEDIR:tA} != ${.CURDIR:tA}
|
|
@cd ${MAKEFILE:H} && cp ${FILES} ${.CURDIR}
|
|
.endif
|
|
# The following targets create and remove files. The filesystem cache in
|
|
# dir.c would probably not handle this correctly, therefore each of the
|
|
# targets is run in its separate sub-make.
|
|
@${MAKE} -f ${MAKEFILE} remove-archive
|
|
@${MAKE} -f ${MAKEFILE} create-archive
|
|
@${MAKE} -f ${MAKEFILE} list-archive
|
|
@${MAKE} -f ${MAKEFILE} list-archive-wildcard
|
|
@${MAKE} -f ${MAKEFILE} depend-on-existing-member
|
|
@${MAKE} -f ${MAKEFILE} depend-on-nonexistent-member
|
|
@${MAKE} -f ${MAKEFILE} remove-archive
|
|
|
|
create-archive: ${ARCHIVE} pre post
|
|
|
|
# The indirect references with the $$ cover the code in Arch_ParseArchive
|
|
# that calls Var_Parse. It's an esoteric scenario since at the point where
|
|
# Arch_ParseArchive is called, the dependency line is already fully expanded.
|
|
#
|
|
${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post
|
|
ar cru ${.TARGET} ${.OODATE:O}
|
|
ranlib ${.TARGET}
|
|
|
|
list-archive: ${ARCHIVE} pre post
|
|
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) pre post
|
|
@printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@}
|
|
|
|
depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post
|
|
@echo $@
|
|
|
|
depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) pre post
|
|
@echo $@
|
|
|
|
remove-archive: pre post
|
|
rm -f ${ARCHIVE}
|
|
|
|
pre: .USEBEFORE
|
|
@echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE:O}
|
|
post: .USE
|
|
@echo
|