diff mbox

[cbootimage-configs,v2] post.mk: Create dependency makefile by makefile rule

Message ID 20170331150153.14606-2-nikolaus.schulz@avionic-design.de
State Accepted
Headers show

Commit Message

Nikolaus Schulz March 31, 2017, 3:01 p.m. UTC
Creating the emmc image requires creating the bct file and the
bootloader image first.  These dependencies are written to a makefile
snippet that is created by the gen-image-deps.sh script.  But that
script is only invoked when the rule that creates the emmc image is run,
which is too late for creating the dependencies makefile.

Add a rule to post.mk that tells make how to create the dependencies
makefile; with that in place, make automatically makes the dependency
makefile before executing any other rules.

Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
---
 build/post.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Warren March 31, 2017, 3:46 p.m. UTC | #1
On 03/31/2017 09:01 AM, Nikolaus Schulz wrote:
> Creating the emmc image requires creating the bct file and the
> bootloader image first.  These dependencies are written to a makefile
> snippet that is created by the gen-image-deps.sh script.  But that
> script is only invoked when the rule that creates the emmc image is run,
> which is too late for creating the dependencies makefile.
>
> Add a rule to post.mk that tells make how to create the dependencies
> makefile; with that in place, make automatically makes the dependency
> makefile before executing any other rules.

I don't think this change is correct, or at least necessary.

The concept here is that:

- If an output file does not exist at all, it will be built for the 
first time, and a dependency file will be generated for the next time.

- If an output file does exist, the related dependency file is also 
expected to exist, and specify the dependencies, so that if they change, 
a rebuild will occur.

In particular, the dependency file is/should-no-be necessary in the case 
where an output file is to be generated for the first time.

If a known dependency specification is missing, we should specify it 
directly in the makefile itself. The generated dependency files are 
intended to represent unknown/unknowable dependencies.

Is it possible to fix this problem that way instead?
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nikolaus Schulz April 3, 2017, 12:22 p.m. UTC | #2
On Fri, Mar 31, 2017 at 09:46:19AM -0600, Stephen Warren wrote:
> On 03/31/2017 09:01 AM, Nikolaus Schulz wrote:
> > Creating the emmc image requires creating the bct file and the
> > bootloader image first.  These dependencies are written to a makefile
> > snippet that is created by the gen-image-deps.sh script.  But that
> > script is only invoked when the rule that creates the emmc image is run,
> > which is too late for creating the dependencies makefile.
> > 
> > Add a rule to post.mk that tells make how to create the dependencies
> > makefile; with that in place, make automatically makes the dependency
> > makefile before executing any other rules.
> 
> I don't think this change is correct, or at least necessary.
> 
> The concept here is that:
> 
> - If an output file does not exist at all, it will be built for the first
> time, and a dependency file will be generated for the next time.
> 
> - If an output file does exist, the related dependency file is also expected
> to exist, and specify the dependencies, so that if they change, a rebuild
> will occur.
> 
> In particular, the dependency file is/should-no-be necessary in the case
> where an output file is to be generated for the first time.
> 
> If a known dependency specification is missing, we should specify it
> directly in the makefile itself. The generated dependency files are intended
> to represent unknown/unknowable dependencies.
> 
> Is it possible to fix this problem that way instead?

Well, the dependencies in question are hard dependencies: creating the
emmc image has the bct file and the bootloader image as prerequisites.

I just noticed though that specifying the dependency on the bct file
need not use gen-image-deps.sh at all, since the bct filename is already
known to make.  I'll send an alternate, trivial patch.

Note that the dependency on the bootloader image can be added to the
makefiles in a similar way by simply adding a variable for the filename
to the per-soc Makefiles and make that a prerequisite of the emmc image.
With that there is no need for a dynamically generated dependency file
at all, at the slight expense of some (more) duplication of filenames.

I'll send a separate patch doing that as an RFC.

Regards,
Nikolaus
Stephen Warren April 5, 2017, 3:26 p.m. UTC | #3
On 04/03/2017 06:22 AM, Nikolaus Schulz wrote:
> On Fri, Mar 31, 2017 at 09:46:19AM -0600, Stephen Warren wrote:
>> On 03/31/2017 09:01 AM, Nikolaus Schulz wrote:
>>> Creating the emmc image requires creating the bct file and the
>>> bootloader image first.  These dependencies are written to a makefile
>>> snippet that is created by the gen-image-deps.sh script.  But that
>>> script is only invoked when the rule that creates the emmc image is run,
>>> which is too late for creating the dependencies makefile.
>>>
>>> Add a rule to post.mk that tells make how to create the dependencies
>>> makefile; with that in place, make automatically makes the dependency
>>> makefile before executing any other rules.
>>
>> I don't think this change is correct, or at least necessary.
>>
>> The concept here is that:
>>
>> - If an output file does not exist at all, it will be built for the first
>> time, and a dependency file will be generated for the next time.
>>
>> - If an output file does exist, the related dependency file is also expected
>> to exist, and specify the dependencies, so that if they change, a rebuild
>> will occur.
>>
>> In particular, the dependency file is/should-no-be necessary in the case
>> where an output file is to be generated for the first time.
>>
>> If a known dependency specification is missing, we should specify it
>> directly in the makefile itself. The generated dependency files are intended
>> to represent unknown/unknowable dependencies.
>>
>> Is it possible to fix this problem that way instead?
>
> Well, the dependencies in question are hard dependencies: creating the
> emmc image has the bct file and the bootloader image as prerequisites.
>
> I just noticed though that specifying the dependency on the bct file
> need not use gen-image-deps.sh at all, since the bct filename is already
> known to make.  I'll send an alternate, trivial patch.
>
> Note that the dependency on the bootloader image can be added to the
> makefiles in a similar way by simply adding a variable for the filename
> to the per-soc Makefiles and make that a prerequisite of the emmc image.
> With that there is no need for a dynamically generated dependency file
> at all, at the slight expense of some (more) duplication of filenames.
>
> I'll send a separate patch doing that as an RFC.

As mentioned in response to the followup patches you sent, I've decided 
to apply this patch instead. It's now applied. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/build/post.mk b/build/post.mk
index 979d8ce..a647c81 100644
--- a/build/post.mk
+++ b/build/post.mk
@@ -21,11 +21,12 @@  bcts: $(bcts)
 images: $(images)
 
 image_deps := $(addprefix .,$(addsuffix .d,$(images)))
+$(image_deps): .%.d : %.cfg
+	../../../build/gen-image-deps.sh $< $(@:.%.d=%) $@
 -include $(image_deps)
 
 %.bct: %.bct.cfg
 	cbootimage -gbct -$(soc) $< $@
 
 %.img: %.img.cfg
-	../../../build/gen-image-deps.sh $< $@ .$@.d
 	cbootimage -$(soc) $< $@