[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A function to print instead of $(warning ) or $(error )
From: |
John Graham-Cumming |
Subject: |
Re: A function to print instead of $(warning ) or $(error ) |
Date: |
Wed, 23 Feb 2005 11:03:33 -0500 |
On Wed, 2005-02-23 at 07:00 -0800, Pete Johnson wrote:
> The irony in all of this is that adding a function say "print" to make
> to do this would only take a few lines of code in function.c, but I
> just can't figure out how to do it within make.
This works for me in GNU Make 3.80:
define foo
multi
line message
output
endef
define newline
endef
space :=
space += #
safe-char := |
make-list-at-newline = $(subst $(newline),$(space),$(subst
$(space),$(safe-char),$1))
output-message = $(foreach m,$(call make-list-at-newline,$1),
$(shell echo $(subst $(safe-char),$(space),$m) 1>&2))
$(call output-message,$(foo))
$(call output-message,single line)
The newline variable contains a newline, which is created by making a
define with _two_ blank lines in it. space contains a space. safe-char
contains a character that will be guaranteed not to appear in the text
to be output; I picked the pipe character, but you can choose anything
(or could be a sequence of characters).
make-list-at-newline converts all spaces to the safe-char and then
splits the resulting string into a list (space separated) at the
newlines.
output-message converts the safe-char back to space and calls echo for
each part of its input that ends with a newline (or is the last string).
John.
--
John Graham-Cumming
Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/
- A function to print instead of $(warning ) or $(error ), Pete Johnson, 2005/02/22
- Re: A function to print instead of $(warning ) or $(error ), Noel Yap, 2005/02/23
- Re: A function to print instead of $(warning ) or $(error ), Pete Johnson, 2005/02/23
- Re: A function to print instead of $(warning ) or $(error ), Pete Johnson, 2005/02/23
- Re: A function to print instead of $(warning ) or $(error ), Boris Kolpackov, 2005/02/24
- Re: A function to print instead of $(warning ) or $(error ), Pete Johnson, 2005/02/25