busybox-w32 icon indicating copy to clipboard operation
busybox-w32 copied to clipboard

`make` - automatic variables `$<` and `$*` works inside suffixes rules only

Open naksyl opened this issue 10 months ago • 3 comments

Test makefile:

all:
	@echo "Automatic variables from suffixes rule"
	@make -n AUTO=1 main.o
	@echo
	@echo "Automatic variables from regular rule"
	@make -n main.o

.c.o:
	$$< = "$<"
	$$? = "$?"
	$$@ = "$@"
	$$* = "$*"
	$$^ = "$^"

main.o: main.c common.h
ifndef AUTO
	$$< = "$<"
	$$? = "$?"
	$$@ = "$@"
	$$* = "$*"
	$$^ = "$^"
endif

main.c:
common.h:

Output:

$ make
Automatic variables from suffixes rule
$< = "main.c"
$? = "main.c common.h"
$@ = "main.o"
$* = "main"
$^ = "main.c common.h"

Automatic variables from regular rule
$< = ""
$? = "main.c common.h"
$@ = "main.o"
$* = ""
$^ = "main.c common.h"

naksyl avatar Apr 19 '24 11:04 naksyl