On 02/14, Edgar Fuß wrote: > TRC> and the traditional approach is to use a dummy file in the directory: > TRC> > TRC> foo/.stamp: > TRC> touch foo/.stamp > Which a) creates a file you may have to ignore afterwards and b) updates the > directory's time stamp causing gratuitous command execution later.
Hello, Edgar! True about point a. I'm not sure about point b, though. What is the scenario you're thinking of that causes gratuitous command execution later? The use case I've come across is that there are targets to be created inside a directory, and the directory needs to exist before creating the targets in the directory, so the targets need to have the directory as a prerequisite. For example, here the target build/buffer.o is created inside the build directory: build/.dirstamp mkdir -p build touch build/.dirstamp build/buffer.o: build/.dirstamp buffer.c cc -c buffer.c -o build/buffer.o The build directory's timestamp is only changed once: the build directory is obviously first created with a timestamp, and then the .dirstamp file is created inside it thus changing the build directory's timestamp. Since the build/buffer.o target has build/.dirstamp as a prerequisite, the build directory gets created before executing the build/buffer.o target commands, but that directory creation and .dirstamp file creation only happen once. Subsequent invocations of make will not cause the timestamp of the build directory to change (unless, of course, a target is created or updated in it). Regards, Lewis