I think this does the trick... # Define a var containing one space character. SPACE := SPACE +=
# Define a substitute for space. SPACESUB := __SPACE__ # Define a var containing one new-line character (there are two blank lines in this). define NEWLINE endef # The multi-line var under test. define FOO foo abc bar xyz quux endef # Replace each space in FOO with a substitute, then replace each new-line with a space so # make sees each line as a word. The foreach function will then loop through all words # and it's just necessary to undo the space substitution in the body of the loop - in this # cas just a call to the info function. $(foreach line,$(subst $(NEWLINE),$(SPACE),$(subst $(SPACE),$(SPACESUB),$(FOO))),\ $(info line: '$(subst $(SPACESUB),$(SPACE),$(line))')\ ) Regards, Philip. -----Original Message----- From: J.T. Conklin [mailto:[email protected]] Sent: 28 June 2010 23:49 To: [email protected] Subject: Iterating through multi-line variable Suppose you have a multi-line variable where each line may have spaces. define FOO foo abc bar xyz quux endef Is there a way to iterate through the variable line-by-line instead of word-by-word (as with $(foreach ...)) ? --jtc -- J.T. Conklin _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
