The output in the top-level makefile

I set the variable in makefile as follows:

 SOMEVAR = foo 

This makefile includes another makefile in which the actual creation of the programs takes place:

 include generic/Makefile.common 

Thus, no assembly targets are defined in the first makefile , they only set variables, which are then used by a common common makefile to actually build the package.

Now I know that I have to be careful when using foo , so to remind myself of this, I want to print a warning message whenever this makefile is used to configure the make process. The problem is that I cannot just insert the echo command after the variable is defined, because we have not built anything there yet.

Is there a solution (more elegant than adding a fake target where the message is printed, which will break the separation of installation and building variables)?

+6
warnings makefile
source share
2 answers
 SOMEVAR = foo $(warning be careful with foo) 
+13
source share

According to the official documentation, there are three ways to make top level output in a makefile

  • $ (error text)
  • $ (warning text)
  • $ (information text)

Just in case, you want to do it differently.

I hope this helps.

+6
source share

All Articles