rmyorston / pdpmake

Public domain POSIX make
https://frippery.org/make
Other
105 stars 11 forks source link

Substitution doesn't work if variables are nested; Is this intended behaviour? #1

Closed ScoreUnder closed 2 years ago

ScoreUnder commented 2 years ago

Makefile

BACKEND_SRC = backend.c
FRONTEND_SRC = frontend.c
FULL_SRC = $(BACKEND_SRC) $(FRONTEND_SRC) extra.c
OBJS = $(FULL_SRC:.c=.o)

clean:
    @echo want to remove $(OBJS)

.PHONY: clean
score@kirisame ~ % make
want to remove backend.o frontend.o extra.o
score@kirisame ~ % bmake
--- clean ---
want to remove backend.o frontend.o extra.o
score@kirisame ~ % pdpmake
want to remove backend.c frontend.c extra.o

It doesn't seem to be able to perform substitutions in positions where text has been inserted with a variable substitution. Or in other words, the .c=.o operation can't "see inside" the included variables like BACKEND_SRC.

rmyorston commented 2 years ago

No, FULL_SRC should be expanded before the suffixes are changed. That's definitely wrong.

I'm still considering what else might be wrong...

rmyorston commented 2 years ago

OK, I've rearranged the sequence of events when macros are expanded. Your makefile should now give the expected result.

ScoreUnder commented 2 years ago

The fix is working for me, thanks