Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do variadic macros with $(call ...) in GNU Make

I created a macro for use in makefiles along the lines of:

TODO_MSG = $(warning TODO: $(1))
$(call TODO_MSG, This part of the msg displays fine, but this part does not)

I can get around it with something like the following:

BLAH := $(shell perl -e 'print join( " ", 2..200 )'
COMMA := ,
TODO_MSG = $(warning TODO:$(1)$(strip $(foreach x,${BLAH},$(if $(${x}),${COMMA}$(${x}))))

... but I'm curious whether there is anything offering more explicit support for variadic macros.

like image 733
Brian Vandenberg Avatar asked Aug 28 '12 23:08

Brian Vandenberg


1 Answers

Here is a remix on Beta's solution:

TODO_MSG = $(warning TODO: $(1))

test:
        $(call TODO_MSG, $(strip This part displays fine, and this does too))

If there was an $(identity ...) function for Make, I'd use that; $(strip ...) was the closest I could find.

like image 128
Clayton Stanley Avatar answered Nov 02 '22 23:11

Clayton Stanley