I use a makefile to automate the creation of some documents. I have several documents in a directory, and one of my makefile rules will generate an index page for these files. The list of the files themselves is loaded on the fly using list := $(shell ls documents/*.txt), so I don’t need to manually edit the makefile every time I add, delete or rename a document. Naturally, I want the index generation rule to be triggered when the number / headers of files in the document directory change, but I don’t know how to set up prerequisites for working this way.
I could use .PHONYor something similar to make index generation work all the time, but I would prefer not to waste these loops. I tried piping lsto a file list.txtand used this as a prerequisite for my index generation rule, but for this you will need to either edit it list.txtmanually (trying to avoid it) or auto-generate it in a makefile (this changes the creation time, so I cannot use it list.txtin the prerequisite because it runs the rule every time).
source
share