How can I strip leading whitespace from parameters passed to user defined functions with gnu-make?
For example:
define FOO
# --- some build rules
# run the built target
/home/user/dir/bin/$(1)
endef
The following call works correctly, since there is no leading whitespace:
$(eval $(call FOO,my_test ) )
Unfortunately the following fails, because $(1) has a leadning space
$(eval $(call FOO, my_test ) )
^
Additional space to 'prettier' formatting
this ends up expanding to:
/home/user/dir/bin/ $(1)
^
Leading whitespace
How can I strip leading whitespace from arguments passed to user defined functions?
Is it bad form to do this or should I simply assume that arguments are passed without leading whitespace?
Use the
stripfunction:For details, see Text Functions. Because of this, and to avoid using
stripeverywhere, it is best to avoid spaces after commas when passing arguments to functions.