Makefile rule depending on change of number of files instead of change in content of files.
Posted
by goathens
on Stack Overflow
See other posts from Stack Overflow
or by goathens
Published on 2010-03-16T07:11:06Z
Indexed on
2010/03/16
7:16 UTC
Read the original article
Hit count: 177
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 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).
© Stack Overflow or respective owner