I'm using a makefile to automate some document generation. I have several documents in a directory, and one of my makefile rules will generate an index page of those files. The list of files itself is loaded on the fly using list := $(shell ls documents/*.txt)
so I don't have to bother manually editing the makefile every time I add, delete, or rename a document. Naturally, I want the index-generation rule to trigger when number/title of files in the documents directory changes, but I don't know how to set up the prerequisites to work in this way.
I could use .PHONY
or something similar to force the index-generation to run all the time, but I'd rather not waste the cycles. I tried piping ls
to a file list.txt
and using that as a prerequisite for my index-generation rule, but that would require either editing list.txt
manually (trying to avoid it), or auto-generating it in the makefile (this changes the creation time, so I can't use list.txt
in the prerequisite because it would trigger the rule every time).