eDeviser
eDeviser

Reputation: 1873

How to comment a line in a Makefile?

Within a makefile I have a some variables. For a better understanding I added some comments:

variable1 = value1     #A comment
variable2 = true       #can be set true or false
variable3 = foo        #can be foo or bar

The problem is now, that the variables contain the given text and all spaces between the text and the #. The output of a simple echo shows the problem:

echo "$(variable1) $(variable2) endOfEcho"
value1      true       endOfEcho

How to avoid the spaces to be interpreted as variable's text?

Upvotes: 1

Views: 2348

Answers (1)

Tero Kauppinen
Tero Kauppinen

Reputation: 26

With GNU make:

@echo "$(strip $(variable1)) $(strip $(variable2)) endOfEcho"
value1 true endOfEcho

@echo "$(variable1) $(variable2) endOfEcho"
value1      true        endOfEcho

@echo $(variable1) $(variable2) endOfEcho
value1 true endOfEcho

Upvotes: 1

Related Questions