> Date: Thu, 30 Apr 2026 22:30:48 +0000
> From: Heime <[email protected]>
> 
> 
> I have a problem understanding the utility of order-only dependencies 
> in make.
> 
> For example, consider
> 
> obj/main.o: main.c | obj/
>     gcc -c main.c -o obj/main.o
>  
> obj/:
>     mkdir -p obj
> 
> obj/ is built before obj/main.o, but updates to obj/ (e.g., adding 
> files) won't trigger a rebuild of obj/main.o.

You CANNOT trust time stamps of directories.  Not every change to
files in a directory will result in a change of the directory's time
stamp, at least not on all types of filesystems we have out there.
The filesystem decides when it updates the time stamp of a directory,
and that decision is not something you can control or know in advance,
at least not portably.

So your Makefile must NOT depend on time stamps of directories if you
want it to be reliable.  You should find other ways of triggering
rebuild when files are added/deleted/modified, as others suggested.

Reply via email to