Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass comma character in makefile function

Tags:

shell

makefile

In Makefile there is defined a print function, which takes print text as argument and then print it. My question is that how to pass comma character as a text part to print it ? For example below is relevant makefile section where comma is not printable.

print = echo '$(1)'

help:
        @$(call print, He lives in Paris, does not he?)

Now if run makefile like:

$ make help 

It prints

$  He lives in Paris

instead of

$  He lives in Paris, does not he?

I know in makefile comma uses as argument separate, but how I can make it as printable. I used different escape character combination to pass comma as text message like \, /, $$, ',' "," but nothing works

like image 846
Equation Solver Avatar asked Apr 23 '19 06:04

Equation Solver


1 Answers

The manual says:

Commas and unmatched parentheses or braces cannot appear in the text of an argument as written; leading spaces cannot appear in the text of the first argument as written. These characters can be put into the argument value by variable substitution.

So, you need to put comma into a variable, and use it in the argument. E.g:

print = echo '$(1)'
comma:= ,

help:
        @$(call print,He lives in Paris$(comma) does not he?)
like image 153
oguz ismail Avatar answered Sep 30 '22 04:09

oguz ismail