Notes on Make

Posted on November 11, 2019 | make

This is a collection of notes I have accumulated while working with make. The make manual is a good place to start looking for answers.

Debugging makefiles #

gmake info command #

The info command can be used to dump information from makefile.

$(info CFLAGS=$(CFLAGS))

Similarly one can use the error and warning commands can be used for debugging.

Remake #

Remake is a enhanced version of GNUMake with enhanced tracing and a builtin debugger. I have been using remake as a replacement for make on my development machine and am yet to run into any issues.

alias make=remake

Now you can use

make --trace

to get better information on why a target is being built/rebuilt.

The -B option of remake triggers an unconditional rebuild of a specified target.

  1. Debugging makefiles with remake -
  2. Remake home page -
  3. Remake GitHub repository -

Parallelizing recursive make #

To ensure the -j N flag is used when doing recursive make, use $(MAKE) when invoking the submake. This ensures that the gmake jobserver is used correctly. Otherwise you might see warnings such as

make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  1. How the make variable works -
  2. GNUMake Jobserver Implementation -
  3. Recursive make considered harmful -

Miscellaneous #

When one of the dependencies is a symbolic link, make checks the modification time of the file referenced by the link. This is sensible behaviour and probably the reason it is not called out in the gnu make manual.

There is also the “-L” option which causes make to consider the modification time of the symlink as well. This is option is useful when one wants to “touch symlink” and run make.


    On systems that support symbolic links, this option causes make to consider the timestamps
    on any symbolic links in addition to the timestamp on the file referenced by those links.
    When this option is provided, the most recent timestamp among the file and the symbolic
    links is taken as the modification time for this target file.