2005-05-06 15:23:43

by Kumar Gala

[permalink] [raw]
Subject: PPC uImage build not reporting correctly

Sam,

Tom pointed me at you to look at a makefile issue with
arch/ppc/boot/images/Makefile. When I do the following:

$ make uImage
CHK include/linux/version.h
make[1]: `arch/ppc/kernel/asm-offsets.s' is up to date.
CHK include/linux/compile.h
CHK usr/initramfs_list
UIMAGE arch/ppc/boot/images/uImage
Image Name: Linux-2.6.12-rc3
Created: Fri May 6 10:19:28 2005
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 993322 Bytes = 970.04 kB = 0.95 MB
Load Address: 0x00000000
Entry Point: 0x00000000
Image: arch/ppc/boot/images/uImage not made

The issue is that the file arch/ppc/boot/images/uImage does exit (the
'not made' is not correct).

$(obj)/uImage: $(obj)/vmlinux.gz
$(Q)rm -f $@
$(call if_changed,uimage)
@echo ' Image: $@' $(if $(wildcard $@),'is ready','not made')

It seems the $(wildcard $@) expands at the start of the rule. Any
ideas?

- kumar


2005-05-06 21:45:30

by Sam Ravnborg

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly

> Sam,
>
> Tom pointed me at you to look at a makefile issue with
> arch/ppc/boot/images/Makefile. When I do the following:
>
> $ make uImage
> CHK include/linux/version.h
> make[1]: `arch/ppc/kernel/asm-offsets.s' is up to date.
> CHK include/linux/compile.h
> CHK usr/initramfs_list
> UIMAGE arch/ppc/boot/images/uImage
> Image Name: Linux-2.6.12-rc3
> Created: Fri May 6 10:19:28 2005
> Image Type: PowerPC Linux Kernel Image (gzip compressed)
> Data Size: 993322 Bytes = 970.04 kB = 0.95 MB
> Load Address: 0x00000000
> Entry Point: 0x00000000
> Image: arch/ppc/boot/images/uImage not made
>
> The issue is that the file arch/ppc/boot/images/uImage does exit (the
> 'not made' is not correct).
>
> $(obj)/uImage: $(obj)/vmlinux.gz
> $(Q)rm -f $@
> $(call if_changed,uimage)
> @echo ' Image: $@' $(if $(wildcard $@),'is ready','not made')
>
> It seems the $(wildcard $@) expands at the start of the rule. Any
> ideas?

It probarly uses the build-in cache in make - and I see no easy way to
tell make not to use the cache in this case.
Could you try to replace "$(wildcard $@)" with something like:
$(shell if -f $@ echo Y; fi)

Untested - I'm not on a Linux box right now.

Sam


2005-05-06 21:57:28

by Kumar Gala

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly


On May 6, 2005, at 4:45 PM, Sam Ravnborg wrote:

> > Sam,
> >
> > Tom pointed me at you to look at a makefile issue with
> > arch/ppc/boot/images/Makefile.? When I do the following:
> >
> > $ make uImage
> >??? CHK???? include/linux/version.h
> > make[1]: `arch/ppc/kernel/asm-offsets.s' is up to date.
> >??? CHK???? include/linux/compile.h
> >??? CHK???? usr/initramfs_list
> >??? UIMAGE? arch/ppc/boot/images/uImage
> > Image Name:?? Linux-2.6.12-rc3
> > Created:????? Fri May? 6 10:19:28 2005
> > Image Type:?? PowerPC Linux Kernel Image (gzip compressed)
> > Data Size:??? 993322 Bytes = 970.04 kB = 0.95 MB
> > Load Address: 0x00000000
> > Entry Point:? 0x00000000
> >??? Image: arch/ppc/boot/images/uImage not made
> >
> > The issue is that the file arch/ppc/boot/images/uImage does exit
> (the
> > 'not made' is not correct).
> >
> > $(obj)/uImage: $(obj)/vmlinux.gz
> >????????? $(Q)rm -f $@
> >????????? $(call if_changed,uimage)
> >????????? @echo '? Image: $@' $(if $(wildcard $@),'is ready','not
> made')
> >
> > It seems the $(wildcard $@) expands at the start of the rule.? Any
> > ideas?
>
> It probarly uses the build-in cache in make - and I see no easy way to
> tell make not to use the cache in this case.
> Could you try to replace "$(wildcard $@)" with something like:
> $(shell if -f $@ echo Y; fi)
>
> Untested - I'm not on a Linux box right now.

I tried the following w/o success:

$(obj)/uImage: $(obj)/vmlinux.gz
$(Q)rm -f $@
$(call if_changed,uimage)
@echo ' Image: $@' $(shell if [ -f $@ ]; then echo 'is ready';
else echo 'not made'; fi)

- kumar

2005-05-09 15:19:20

by Kumar Gala

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly


On May 6, 2005, at 6:22 PM, <[email protected]> wrote:

> On Fri, 6 May 2005, Kumar Gala wrote:
> > I tried the following w/o success:
> >
> > $(obj)/uImage: $(obj)/vmlinux.gz
> >???????? $(Q)rm -f $@
> >???????? $(call if_changed,uimage)
> >???????? @echo '? Image: $@' $(shell if [ -f $@ ]; then echo 'is
> ready'; else
> > echo 'not made'; fi)
>
> Couldn't you eliminate the ($shell ..) construct altogether, like
> this?:
>
> $(obj)/uImage: $(obj)/vmlinux.gz
> ??????? $(Q)rm -f $@
> ??????? $(call if_changed,uimage)
> ??????? @echo -n '? Image: $@'
> ??????? @if [ -f $@ ]; then echo 'is ready' ; else echo 'not made'; fi

Yes, and this seems to actually work.

Sam, does this look reasonable to you. If so I will work up a patch.

thanks

- kumar

2005-05-10 04:27:22

by Sam Ravnborg

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly

On Mon, May 09, 2005 at 10:19:01AM -0500, Kumar Gala wrote:
>
> On May 6, 2005, at 6:22 PM, <[email protected]> wrote:
>
> >On Fri, 6 May 2005, Kumar Gala wrote:
> > > I tried the following w/o success:
> > >
> >> $(obj)/uImage: $(obj)/vmlinux.gz
> >>???????? $(Q)rm -f $@
> > >???????? $(call if_changed,uimage)
> >>???????? @echo '? Image: $@' $(shell if [ -f $@ ]; then echo 'is
> >ready'; else
> > > echo 'not made'; fi)
> >
> >Couldn't you eliminate the ($shell ..) construct altogether, like
> >this?:
> >
> >$(obj)/uImage: $(obj)/vmlinux.gz
> >??????? $(Q)rm -f $@
> > ??????? $(call if_changed,uimage)
> >??????? @echo -n '? Image: $@'
> > ??????? @if [ -f $@ ]; then echo 'is ready' ; else echo 'not made'; fi
>
> Yes, and this seems to actually work.
>
> Sam, does this look reasonable to you. If so I will work up a patch.
Looks ok - but I do not see why use of $(shell ...) did not work out.
Please bring your working version forward.

Sam

2005-05-10 10:34:24

by cpclark

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly

On Tue, 10 May 2005, Sam Ravnborg wrote:

> On Mon, May 09, 2005 at 10:19:01AM -0500, Kumar Gala wrote:
> >
> > On May 6, 2005, at 6:22 PM, <[email protected]> wrote:
> >
> > >On Fri, 6 May 2005, Kumar Gala wrote:
> > > > I tried the following w/o success:
> > > >
> > > > $(obj)/uImage: $(obj)/vmlinux.gz
> > > > $(Q)rm -f $@
> > > > $(call if_changed,uimage)
> > > > @echo ' Image: $@' $(shell if [ -f $@ ]; then echo 'is ready'; else echo 'not made'; fi)
> > >
> > >Couldn't you eliminate the ($shell ..) construct altogether, like this?:
> > >
> > >$(obj)/uImage: $(obj)/vmlinux.gz
> > > $(Q)rm -f $@
> > > $(call if_changed,uimage)
> > > @echo -n '? Image: $@'
> > > @if [ -f $@ ]; then echo 'is ready' ; else echo 'not made'; fi
> >
> > Yes, and this seems to actually work.
> >
> > Sam, does this look reasonable to you. If so I will work up a patch.
>
> Looks ok - but I do not see why use of $(shell ...) did not work out.

As I understand it, the $(shell ...) construct doesn't "work" in the case
cited above because make evaluates/expands the $(shell ...) stuff while it
is parsing the makefile and building the command list--i.e. before it has
issued any commands to build anything. What seems to be desired in this
case is a file-existence test which runs "inline" with respect to the
preceding commands. The use of $(shell ...) inside a command
subverts/preempts that natural sequence. I think. :-)

Chris

2005-05-10 15:20:49

by Stephen Warren

[permalink] [raw]
Subject: RE: PPC uImage build not reporting correctly

From: [email protected]
[mailto:[email protected]] On Behalf Of Sam Ravnborg
> On Mon, May 09, 2005 at 10:19:01AM -0500, Kumar Gala wrote:
> > On May 6, 2005, at 6:22 PM, <[email protected]> wrote:
> > > Couldn't you eliminate the ($shell ..) construct altogether, like
> > > this?:
> > >
> > > $(obj)/uImage: $(obj)/vmlinux.gz
> > > ??????? $(Q)rm -f $@
> > > ??????? $(call if_changed,uimage)
> > > ??????? @echo -n '? Image: $@'
> > > ??????? @if [ -f $@ ]; then echo 'is ready' ; else echo 'not
made'; fi
> >
> > Yes, and this seems to actually work.
> >
> > Sam, does this look reasonable to you. If so I will work up a
patch.
>
> Looks ok - but I do not see why use of $(shell ...) did not work out.
> Please bring your working version forward.

It's because both any $(xxx) in the command will be expanded prior to
the command being executed ("command" meaning all lines in the complete
command script for the target in question - not on a line-by-line
basis).

Thus, the original $(wildcard), and also the $(shell) above are
evaluated/expanded by gmake prior to running any of the the "rm -rf",
"if_changed", and "echo" commands, and hence run before the uImage file
is created, and hence always think that it doesn't exist.

The only solution is to get the shell to do the evaluation of whether
uImage exists - that way, the evaluation is guaranteed to happen after
the uImage is (hopefully) created.

--
Stephen Warren, Software Engineer, NVIDIA, Fort Collins, CO
[email protected] http://www.nvidia.com/
[email protected] http://www.wwwdotorg.org/pgp.html

2005-05-11 04:59:57

by Sam Ravnborg

[permalink] [raw]
Subject: Re: PPC uImage build not reporting correctly

>
> > Looks ok - but I do not see why use of $(shell ...) did not work out.
>
> As I understand it, the $(shell ...) construct doesn't "work" in the case
> cited above because make evaluates/expands the $(shell ...) stuff while it
> is parsing the makefile and building the command list--i.e. before it has
> issued any commands to build anything. What seems to be desired in this
> case is a file-existence test which runs "inline" with respect to the
> preceding commands. The use of $(shell ...) inside a command
> subverts/preempts that natural sequence. I think. :-)

That explains it - thanks!

Sam