On Mon, 2021-05-17 at 15:20 -0800, Britton Kerin wrote: > I'd like to use eval to emit some boilerplate vars and everything > short of the prereq list for a static pattern rule. Is it possible?
No. There are a number of problems with what you're doing. First, an eval'd string is treated the same way as an included makefile: it must be a complete makefile and any uncompleted rule will be forcibly completed at the end of the eval before it returns. Second, the reason you are seeing weird behavior is that a backslash/newline is removed from the variable before it's passed to eval, it's not preserved and somehow converted back into a newline by eval. If you want to eval a variable containing actual newlines you have to define the variable using define/endef. If you want to debug eval operations, replace the eval function with an info function. make will print out the exact string that the eval will evaluate and it must be a valid makefile. In your situation if you add: $(info $(call PSTHT, parts_ordered)) you'll see the output is: parts_ordered_STAMPS = $(PBT:.pcb=. parts_ordered.stamp) PRODUCTION_STAMPS += $( parts_ordered_STAMPS) vpath %. parts_ordered.stamp $(STD) $( parts_ordered_STAMPS): %. parts_ordered.stamp all on one line... in other words, it's not a syntax error because you're not actually defining any of these rules, you're just creating a variable named "parts_ordered_STAMPS" that contains the entire very long value.