You can use a rule that is just a pattern to redirect to some other rule. So it will capture anything that comes from the command line. Note:
%: arquivo_%.pdf
@# empty line
arquivo_%.pdf: arquivo_%.tex
@echo Produce $@ from $^
Having this, run make 003
will display: "Produce arquivo_003.pdf from arquivo_003.tex".
You can also call in chain, for example: make 003 004 005
.
Note, however, that it is necessary have at least one command line in the rule used to redirect, otherwise it is ignored. I used a comment there with deleted output, equivalent to a noop.
Still another option is to use a variable whose default value is to produce everything. This solution is much cleaner in reality. First define a variable whose value is the numbers to be produced. Thus:
PRODUCE = $(patsubst arquivo_%.tex,%,$(wildcard arquivo_*.tex))
If you have the files arquivo_001.tex
and arquivo_003.tex
in your directory, then PRODUCE=001 003
.
Without next, given a variable PRODUCE
, calculate the name of the target files, pdfs:
PRODUCE_PDF = $(addprefix arquivo_,$(addsuffix .pdf,$(PRODUCE)))
If PRODUCE=001 003
, then PRODUCE_PDR=arquivo_001.pdf arquivo_003.pdf
.
Now it is a mere matter of making the default rule produce the pdfs. So:
all: $(PRODUCE_PDF)
arquivo_%.pdf: arquivo_%.tex
@echo Produce $@ from $^
If you invoke make
without arguments, will produce all pdfs. You can specify so: make PRODUCE=005
. Or else: make PRODUCE="005 006 002"
.
It seems to me that make considers everything that is not an attribute like Goal. What if you used attributes like
make GDK="004"
, for example, and${GDK}
?– Bacco
I do not know if it is a real problem or canonical question, however here must have some good reference for those who answer: http://stackoverflow.com/questions/2214575/
– Bacco
@Bacco I had seen around that maybe the way was to do something like
make file="004"
but it seemed more complicated than it could be.– Gabe