Home | History | Annotate | Line # | Download | only in unit-tests
      1 # $NetBSD: suff-rebuild.mk,v 1.6 2020/11/21 12:01:16 rillig Exp $
      2 #
      3 # Demonstrates what happens to transformation rules (called inference rules
      4 # by POSIX) when all suffixes are deleted.
      5 
      6 all: suff-rebuild-example
      7 
      8 .MAKEFLAGS: -dpst
      9 
     10 .SUFFIXES:
     11 
     12 .SUFFIXES: .a .b .c
     13 
     14 suff-rebuild-example.a:
     15 	: Making ${.TARGET} out of nothing.
     16 
     17 .a.b:
     18 	: Making ${.TARGET} from ${.IMPSRC}.
     19 .b.c:
     20 	: Making ${.TARGET} from ${.IMPSRC}.
     21 .c:
     22 	: Making ${.TARGET} from ${.IMPSRC}.
     23 
     24 # XXX: At a quick glance, the code in SuffUpdateTarget looks as if it were
     25 # possible to delete the suffixes in the middle of the makefile, add back
     26 # the suffixes from before, and have the transformation rules preserved.
     27 #
     28 # As of 2020-09-25, uncommenting the following line results in the error
     29 # message "don't know how to make suff-rebuild-example" though.
     30 #
     31 # If this is a bug, the actual cause is probably that when a suffix
     32 # transformation rule is defined, it is not added to the global list of
     33 # targets, see Suff_EndTransform.  Later, UpdateTargets iterates over exactly
     34 # this global list of targets though.
     35 #
     36 # If UpdateTargets were to iterate over 'transforms' as well, it still
     37 # wouldn't work because the condition 'ptr == target->name' skips these
     38 # transformation rules.
     39 
     40 #.SUFFIXES:
     41 
     42 # Add the suffixes back.  It should not matter that the order of the suffixes
     43 # is different from before.
     44 .SUFFIXES: .c .b .a
     45