bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion: new make function


From: Tim Murphy
Subject: Re: suggestion: new make function
Date: Sun, 25 Sep 2011 19:36:26 +0100

My apologies to Luke for forgetting "reply to all" and for forgetting
my manners by using the word "sucks" when I should not have.

> I vote 'no'. This can easily be implemented in your
> Makefile. (assuming no single list item breaks the limit)
>
> dumpOneLine = $(foreach item,$(2),echo -n '$(item) ' >> '$(1)')
> dumpOnePerLine = $(foreach item,$(2),echo '$(item)' >> '$(1)')
>
> then use
>  $(call dumpOnePerLine filename, $(list))
>

I use the foreach "trick" and I dislike it. It's complicated and
tends to execute the shell 10x more than it needs to.  For small
makefiles it doesn't matter but doing this for compiles (e.g. the ARM
RVCT's multifile compilation option) in a large makefile is very
unfortunate.

I have wanted this feature in other situations too e.g.
one which involved being able to create a persistent list of files
across multiple builds
for a named component no matter what platform it was
built for and no matter whether any recipe actions happened or not.
The only way to get what was needed turned out to be
much more mindbending thanks to not having a function that appends to
a file I find the code hard to understand every time I look at it and
I know that anyone else who does is at risk of breaking it.

There are obviously a multitude of other uses like keeping debug
information out of the main log - you name it.

Although you can try using  $(shell), you simply introduce a
performance hit again which adds an hour onto some of my builds.

 I second the original poster of the message except I'd prefer
something more like:

$(writefile filename,xxxxxxxxxxxxx)
$(appendfile filename,xxxxxxxxxxxxx)

I'd get the one-item-per-line effect by inserting '\n' into the spaces
in advance.

or perhaps:

$(withfile filename,w,$(info some stuff))
$(withfile filename,a,$(foreach item,$(stuff),$(info $(item))))
$(withfile filename,r+,$(info GET /)$(read RESPONSE))

... acting as a redirector for stdout to the file and allowing one to
perform quite complicated actions such as writing and reading from
sockets although it is perhaps not all that "functional."

Regards,

Tim
- Show quoted text -
--
You could help some brave and decent people to have access to
uncensored news by making a donation at:

http://www.thezimbabwean.co.uk/friends/


> I vote 'no'. This can easily be implemented in your
> Makefile. (assuming no single list item breaks the limit)
>
> dumpOneLine = $(foreach item,$(2),echo -n '$(item) ' >> '$(1)')
> dumpOnePerLine = $(foreach item,$(2),echo '$(item)' >> '$(1)')
>
> then use
>  $(call dumpOnePerLine filename, $(list))
>
> I don't know if '>>' works the same in CMD.EXE as it does in Bash
> (concatentate stdout of the command on the left to the file on the
> right), or if echo behaves similarly ('-n' to make it ommit the
> trailing newline), but something like it should work.
>
> Further, this is frequently the WRONG way to do it. The example on the
> page you linked to is terrible (surprising, I've come to expect better
> from O'Reilly). The proper way to do that in make is:
>
> java_source_files = $(wildcard $(addsuffix /*.java,$(source_dirs)))
> java_class_files = $(patsubst %.java,%.class,$(java_source_files))
> compile_all: $(java_class_files)
> %.class: %.java
>         $(JAVAC) $<
>
> I'm sure someone can find an example of when the command length is an
> actuall problem, but generally, it means that you're doing it wrong.
> You're trying to write your makefile like a scripting language,
> defining functions for doing tasks.  Make is about defining
> relationships between files.
>
> ~ Luke Shumaker
> http://lukeshu.ath.cx
>
> _______________________________________________
> Bug-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-make
>



-- 
You could help some brave and decent people to have access to
uncensored news by making a donation at:

http://www.thezimbabwean.co.uk/friends/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]