Make (and GMake) ignore spaces in many constructs, making it difficult to use a single space as a search string or a replacement string, for example. This trick works around the problem by assigning the space to a variable named SPACE and using that instead. So given this makefile:
NOTHING:= SPACE:=$(NOTHING) $(NOTHING) NAME_WITH_UNDERSCORES:=$(subst $(SPACE),_,$(NAME)) print : ; @echo $(NAME_WITH_UNDERSCORES)
gmake NAME="Professor Hubert Farnsworth"
You need to login to post a comment.