7

I am setting a variable in a makefile like this:

SOMEVAR = foo

This makefile later includes some other makefile in which the actual building of programs takes place:

include generic/Makefile.common

So no build targets are defined in the first makefile, it's only setting up variables which are then used by the common generic makefile to do the actual package building.

Now I know that I should be careful when using foo, so to remind myself of this, I want to print a warning message whenever this makefile is used to setup the make process. The problem is that I cannot just insert an echo command after the variable definition, because we are not yet building something there.

Is there a solution (more elegant than adding a fake target where the message is printed which would destroy the separation of setting variables and building)?

tshepang
  • 12,111
  • 21
  • 91
  • 136
fuenfundachtzig
  • 7,952
  • 13
  • 62
  • 87

2 Answers2

18
SOMEVAR = foo
$(warning be careful with foo)
Beta
  • 96,650
  • 16
  • 149
  • 150
  • @fuenfundachtzig: No? What version of Make are you using? – Beta Dec 22 '10 at 18:17
  • @fuenfundachtzig: I am using GNUMAKE 3.81 also. I don't know how to diagnose the problem. – Beta Dec 23 '10 at 12:10
  • @fuenfundachtzig: Wait-- are you getting an error message, that Make does not know what `warning` means, or does it do nothing? – Beta Dec 23 '10 at 15:17
9

According with official documentation there is three ways to do a top-level output in a makefile

  1. $(error text)
  2. $(warning text)
  3. $(info text)

Just in case you want do that in another way.

I hope helps.

Paulo Alexandre
  • 764
  • 1
  • 9
  • 20