Assume doc.pdf is the target.
The following rule triggers a regeneration of doc.pdf whenever doc.refer is updated, but is also happy when doc.refer does not exist at all:
doc.pdf: doc.mom $(wildcard doc.refer)
pdfmom -e -k < $< > $@
However the following pattern rule does not accomplish the same (the PDF is generated correctly, but a rebuild is not triggered when changing doc.refer):
%.pdf: %.mom Makefile $(wildcard %.refer)
pdfmom -e -k < $< > $@
I suspect that the wildcard command is executed before the % character is expanded. How can I work around this?