Reputation: 1016
I was trying to execute the following code.
LIST = 0 1 3 4 5
targets = $(addprefix rambo, $(LIST))
all: $(targets)
$(targets): rambo%: rambo%.sh
@echo "" > tests/runners/$<
The error I am getting is as follows,
make[1]:*** No rule to make target `rambo0.sh', needed by `rambo0'. Stop.
I'm not sure what is wrong with the code. Basically, I'm trying to create a file dynamically by executing a makefile.
Thanks in advance.
Upvotes: 0
Views: 27
Reputation: 80992
That error means you don't have a rambo0.sh
file in the current directory.
The syntax for a static pattern rule is targets ...: target-pattern: prereq-patterns ...
.
Where targets
are the literal target names, and
[e]ach target is matched against the target-pattern to extract a part of the target name, called the stem. This stem is substituted into each of the prereq-patterns to make the prerequisite names (one from each prereq-pattern).
Since that seems to be what you are trying to create with that rule I believe you want:
targets = $(addsuffix .sh,$(addprefix rambo,$(LIST)))
# Alternatively
# targets = $(patsubst %,rambo%.sh,$(LIST))
$(targets): rambo%.sh :
possibly
$(targets): rambo%.sh : rambo%
if rambo%
is a file or directory that already exists and is a prerequisite of the shell script file you are trying to create.
Upvotes: 1