Suppose I have a make
rule like this:
SOURCES := $(wildcard ./text/*.txt)
$(INDEX) : $(SOURCES)
$(COMPILER) $(SOURCES)
And then one of the text files, ./text/foo.txt
, is deleted. The target $(INDEX)
does not seem to be rebuilt. How do I make make
rebuild in this case?
If your ./text
directory contains only your sources and all of them, you can add it as a pre-requisite of your target:
$(INDEX) : $(SOURCES) ./text
Directories are not like regular files: their last modification date is updated when you add, delete or rename a file (or subdirectory) in them, not when an existing file is modified. Think of it as a file containing the list of contained files.