简体   繁体   中英

Get makefile command evaluation as text

I have a following problem. Basically I have a really long Makefile which calls many complex commands. It uses environment variables, methods included from other Makefiles, really hard to read bash magic. So for example I have a command (cannot put the real one here, sorry) like this:

foo ${bar} (sort ...) [...]

I am analysing this Makefile and I want to know what exactly gets executed when I run it. The thing I want to achieve is this command in a text representation, so all the stuff gets evaluated and I can actually see what exactly is being executed like gcc something -Isomethingmore (so the command foo ${bar} (sort ...) [...] actually means gcc something -Isomethingmore ) etc. Is there a way to do that? So I can for example echo it and see what am I dealing with?

By default make prints the recipes it executes. So you should see the exact command in the standard output. Use grep maybe to isolate the one you are interested in. If make does not print the recipes it may be:

  1. because the recipe is prefixed by @ , which tells make to be silent for this recipe,
  2. because the Makefile contains the .SILENT special target that silences all recipes.

Remove one or the other and you should see the recipe when it is executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM