How to view commands executed by make

When you run make to build a project, sometimes not all the commands or internal workings are visible at the shell. This is especially common if your Makefile is generated by CMake. It hides all the commands that are actually being executed to compile the files of the project. Here are some methods to print what make is doing:

  • For Makefile generated by CMake, try this when you build using make:
$ make VERBOSE=1
  • For normal Makefile, try this:
$ make SHELL='sh -x'

This prints out all the commands executed by make preceded by a plus.

  • With newer versions of make, tracing is available as an option:
$ make --trace

Tried with: GNU Make 4.1 and Ubuntu 16.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s