I want to extract the name of a prerequisite from the target.
TARS= zabc zbcd zcde zdef
# and I want abc.o to be a prerequisite for zabc
$(TARS): $(patsubst z%,%.o,$@) z.c
gcc -c -o $@ $^
However, this is not working. Consider the following:
TARS= zabc zbcd zcde zdef
# and I want abc.o to be a prerequisite for zabc
$(TARS): $(patsubst z%,%.o,zabc) z.c
gcc -c -o $@ $^
Ignore the TARS
in above code but this works for make zabc
.
So I want to know how to use $@
as an argument in the function for getting the prerequisite name.