2

I've seen the question "How does “make” app know default target to build if no target is specified?", which explains that the default target is the first target that doesn't being with a '.'.

How do I get make to tell me what that target is?

Context: I've got a recursive make system, with a variety of included makefiles. If I add a new target to my top level Makefile (or to my common include), that becomes the default target. I want to add .DEFAULT_GOAL: original-default-target, but I don't know what original-default-target is.

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380

1 Answers1

3

Running make -d results in a lot of debug output. If you search this for the first occurrence of 'Updating goal targets', and look at the next target mentioned, this appears to be the default target.

For example:

$ make -d | grep -A2 -m1 'goal targets'
Updating goal targets....
Considering target file 'all'.
 File 'all' does not exist.

This implies that, for this Makefile at least, the current default target is all. This can then be enforced by adding .DEFAULT_GOAL: all to the top-level Makefile.

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380