All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rod Boyce <rod@teamboyce.co.uk>
To: u-boot@lists.denx.de
Subject: [U-Boot] Nested Makefiles
Date: Sat, 18 Jun 2011 16:43:56 +0100	[thread overview]
Message-ID: <4DFCC7BC.7070509@teamboyce.co.uk> (raw)
In-Reply-To: <4DFCACF0.2010003@aribaud.net>

On 18/06/11 14:49, Albert ARIBAUD wrote:
> Le 17/06/2011 02:09, Mike Frysinger a ?crit :
>> On Thursday, June 16, 2011 18:03:07 Wolfgang Denk wrote:
>>> Simon Glass wrote:
>>>> Is it possible for U-Boot to use a system similar to Linux from 2.6
>>>> where it prints out the full pathname of each file it is building, and
>>>> doesn't change in and out of directories as it builds. Perhaps
>>>> including the subdirectory Makefiles instead using make -C? I haven't
>>>> looked at how Linux does it. Is there some reason U-Boot cannot /
>>>> should not do the same?
>>> Of course we can have that - if somebody submits patches for it.
>> this sounds ambiguous ... i think you mean "no, this isnt going into u-boot,
>> but people can submit patches to other projects like GNU make".
>> -mike
> There are two independent issues/topics here, and IIUC, one would
> require patches to U-Boot and the other, patches to make :
>
> 1) recursive vs non-recursive makefiles.
>
> These would be U-Boot patches, if any.
>
> I am in favor of 'non-recursive', i.e. the toplevel makefile includes
> makefiles from levels and then processes the resulting set of rules,
> rather than invoking itself recursively in subdirectories.
>
> The reason I am in favor of gathering all rules in a single make
> execution is because I have been heavily influenced by a release
> engineer where I worked a couple of years ago, who would insist that
> makefiles be lists of "dependency/build instruction" rules, and a build
> should simply be collecting all the rules and trying to make the target
> binary.
>
> He forced us to write component/subcomponent makefiles that would be
> included in a general makkefile that would basically collect them and
> make whatever target was specified, applying whatever rules were needed.
> Pseudo-targets were scarce and carefully thought out. Rules without
> dependencies were forbidden.
>
> The gain was that makefiles were easy to understand since all rules were
> homogeneous, and that you were sure that whatever your last build was,
> doing a make of anything (a single .o, a library, the whole binary, a
> tar.gz for a release package) would only rebuild what was needed.
>
> 2) terse vs verbose.
>
> I like terse more, and yes, I concur with Wolfgang that as far as output
> verbosity is concerned, this should be done natively in make, not in
> makefiles -- but it might be easier said than done, because the 'terse'
> output may not be easily deduced from the build command in the make rule
> that causes it.
>
> So these would be Make patches, if any.
>
> Amicalement,
All,

My comments on this are that non-recursive makefiles are much eaiser to 
understand.  There are 2 articles on the internet have have strongly 
influenced how I write makefiles.  The first is titled 'Recursive make 
considered harmful' and the second is about dependencies titled 
'Advanced auto-dependency generation'.  I am happy to send out links in 
a follow up e-mail if asked but I don't want to open old wounds on these 
here.  I agree with what Amicalement has said so far.  As an example 
from my own experience I have taken a recursive build system that took 
40-minutes to output a build and reduced this down to 4-minutes with 
about 3-times the flexibility.  Adding a new target was as simple as 
adding a line in a makefile and creating a new header file.

While I think the u-boot build system is quite flexible for what it does 
and very fast I would be happy to help out on this endeavor.

On the terse vs verbose debate make already has a feature that does this 
albeit there is no output from make in standard out when the silent (-s) 
option is enabled.

A fragment from my common makefile system is this:
# New improved verbose mode
V ?= 0
ifeq ($(V),1)
NOOUT := > /dev/null
else
MAKEFLAGS += -s
endif

This means that I switch on silent make mode unless the developer add 
V=1 to the make command line and I add to the each rule a line similar to:
@echo "Compiling : $(notdir $<)" $(NOOUT)
or
@echo "Link  app : $@" $(NOOUT)

This produces an output vaguely similar to the Linux kernel or busybox 
output but without all the extra macros.

I have written a non-recursive makefile build system that I have 
licensed under BSD.  It currently supports GCC cortex-M3, SDCC, gcc host 
for tools.  I have build the system such that it is very easy to add 
compilers, architectures, different hosts (although Linux is only 
supported@the moment).
I would be happy to donate it to u-boot if others were interested in 
adding to it as well.  I am currently the only user and developer of it  
so changing the license will not be a problem if required.
If there is interest I would be happy to put it up on one of the git 
hosting website of others to review.

Regards,
Rod Boyce

  reply	other threads:[~2011-06-18 15:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 14:32 [U-Boot] Nested Makefiles Simon Glass
2011-06-16 22:03 ` Wolfgang Denk
2011-06-16 23:03   ` Måns Rullgård
2011-06-17  0:10     ` Mike Frysinger
2011-06-17  0:09   ` Mike Frysinger
2011-06-18 13:49     ` Albert ARIBAUD
2011-06-18 15:43       ` Rod Boyce [this message]
2011-06-18 20:07         ` Wolfgang Denk
2011-06-18 17:42       ` Mike Frysinger
2011-06-18 20:09         ` Wolfgang Denk
2011-06-20 16:32       ` Scott Wood
2011-06-20 19:53   ` Mike Frysinger
2011-06-20 20:30     ` Simon Glass
2011-06-20 22:17       ` Wolfgang Denk
2011-06-20 23:52         ` Simon Glass
2011-06-21  2:01       ` Mike Frysinger
2011-06-20 22:23     ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DFCC7BC.7070509@teamboyce.co.uk \
    --to=rod@teamboyce.co.uk \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.