gnu make dependency checking with directories and symbolic links

Note: The googlefood category is just for things that I needed to know but couldn’t find on google. This will probably be uninteresting for 99.9% of the world, so feel free to skip this.

When using gnu make:

  1. file dependency checks that involve symbolic links check only the modification time of the file the symlink points to. The creation time of the symbolic link itself is irrelevant.
  2. File dependency checks that involve directories as pre-requisites will trigger if either:
    • the directory itself is newer
    • any file within the top level of the directory is newer
  3. Directories within directories or files within non-toplevel subdirectories will not trigger.

Example in a Makefile

2 Responses to “gnu make dependency checking with directories and symbolic links”

  1. Reed Says:

    The reason for #2 is that a directories modification time is reset by the OS whenever its contents change. This makes sense if you think of a directory as a special file that contains a listing of other files.

  2. Nic Watson Says:

    Passing -L to make will cause make to look at the modification time of the symbolic link itself.

Leave a Reply