freebsd-dev/contrib/bmake/unit-tests/suff-rebuild.mk
Simon J. Gerraty 06b9b3e0ad Merge bmake-20210110
Quite a lot of churn on style, but lots of
good work refactoring complicated functions
and lots more unit-tests.
Thanks mostly to rillig at NetBSD

Some interesting entries from ChangeLog

o .MAKE.{UID,GID} represent uid and gid running make.

o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable
  checks in InitObjdir.  Explicit .OBJDIR target always allows
  read-only directory.

o add more unit tests for META MODE

Merge commit '8e11a9b4250be3c3379c45fa820bff78d99d5946' into main

Change-Id: I464fd4c013067f0915671c1ccc96d2d8090b2b9c
2021-01-13 22:21:37 -08:00

45 lines
1.4 KiB
Makefile

# $NetBSD: suff-rebuild.mk,v 1.6 2020/11/21 12:01:16 rillig Exp $
#
# Demonstrates what happens to transformation rules (called inference rules
# by POSIX) when all suffixes are deleted.
all: suff-rebuild-example
.MAKEFLAGS: -dpst
.SUFFIXES:
.SUFFIXES: .a .b .c
suff-rebuild-example.a:
: Making ${.TARGET} out of nothing.
.a.b:
: Making ${.TARGET} from ${.IMPSRC}.
.b.c:
: Making ${.TARGET} from ${.IMPSRC}.
.c:
: Making ${.TARGET} from ${.IMPSRC}.
# XXX: At a quick glance, the code in SuffUpdateTarget looks as if it were
# possible to delete the suffixes in the middle of the makefile, add back
# the suffixes from before, and have the transformation rules preserved.
#
# As of 2020-09-25, uncommenting the following line results in the error
# message "don't know how to make suff-rebuild-example" though.
#
# If this is a bug, the actual cause is probably that when a suffix
# transformation rule is defined, it is not added to the global list of
# targets, see Suff_EndTransform. Later, UpdateTargets iterates over exactly
# this global list of targets though.
#
# If UpdateTargets were to iterate over 'transforms' as well, it still
# wouldn't work because the condition 'ptr == target->name' skips these
# transformation rules.
#.SUFFIXES:
# Add the suffixes back. It should not matter that the order of the suffixes
# is different from before.
.SUFFIXES: .c .b .a