[U-Boot] Nested Makefiles

Rod Boyce rod at teamboyce.co.uk
Sat Jun 18 17:43:56 CEST 2011


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 at 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



More information about the U-Boot mailing list