diff mbox series

Makefile: Use implict rules for .xz and .stb

Message ID 20190717051123.24610-1-oohall@gmail.com
State New
Headers show
Series Makefile: Use implict rules for .xz and .stb | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (3a6fdede6ce117facec0108afe716cf5d0472c3f)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Oliver O'Halloran July 17, 2019, 5:11 a.m. UTC
Currently we use explicit rules to make:

	skiboot.lid.xz
	skiboot.lid.xz.stb
	skiboot.lid.stb

There's no real need to use an explicit rule here and converting them
to use an implicit rule allows you to do this:

$ touch /tmp/test
$ make /tmp/test.stb
        [STB-DEVELOPMENT-SIGNED-CONTAINER] /tmp/test.stb

Or slightly more usefully:

$ make zImage.epapr.stb
        [STB-DEVELOPMENT-SIGNED-CONTAINER] zImage.epapr.stb

Do it for the .xz rule too since it's the same and I always forget that
embedded XZ chokes unless you use the 32bit crc.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 Makefile.main  | 9 ---------
 Makefile.rules | 6 ++++++
 2 files changed, 6 insertions(+), 9 deletions(-)

Comments

Stewart Smith July 17, 2019, 5:23 a.m. UTC | #1
"Oliver O'Halloran" <oohall@gmail.com> writes:
> Currently we use explicit rules to make:
>
> 	skiboot.lid.xz
> 	skiboot.lid.xz.stb
> 	skiboot.lid.stb
>
> There's no real need to use an explicit rule here and converting them
> to use an implicit rule allows you to do this:
>
> $ touch /tmp/test
> $ make /tmp/test.stb
>         [STB-DEVELOPMENT-SIGNED-CONTAINER] /tmp/test.stb
>
> Or slightly more usefully:
>
> $ make zImage.epapr.stb
>         [STB-DEVELOPMENT-SIGNED-CONTAINER] zImage.epapr.stb
>
> Do it for the .xz rule too since it's the same and I always forget that
> embedded XZ chokes unless you use the 32bit crc.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  Makefile.main  | 9 ---------
>  Makefile.rules | 6 ++++++
>  2 files changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/Makefile.main b/Makefile.main
> index fac6e4487460..2997b6ebc305 100644
> --- a/Makefile.main
> +++ b/Makefile.main
> @@ -258,18 +258,9 @@ ALL_OBJS = $(OBJS) version.o
>  ALL_OBJS_1 = $(TARGET).tmp.a asm/dummy_map.o
>  ALL_OBJS_2 = $(TARGET).tmp.a asm/real_map.o
>  
> -$(TARGET).lid.xz: $(TARGET).lid
> -	$(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
> -
>  $(TARGET).lid: $(TARGET).elf
>  	$(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@)
>  
> -$(TARGET).lid.stb: $(TARGET).lid libstb/create-container
> -	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
> -
> -$(TARGET).lid.xz.stb: $(TARGET).lid.xz libstb/create-container
> -	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
> -
>  $(TARGET).tmp.a: $(ALL_OBJS)
>  	@rm -f $(TARGET).tmp.a
>  	$(call Q,AR, $(AR) rcsTPD $@ $(ALL_OBJS), $@)
> diff --git a/Makefile.rules b/Makefile.rules
> index 11b0e5ee8a19..6b35dbafbd9e 100644
> --- a/Makefile.rules
> +++ b/Makefile.rules
> @@ -76,3 +76,9 @@ endif
>  
>  %.map: %.elf
>  	$(call Q,NM, $(NM) --synthetic -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@)
> +
> +%.xz: %
> +	$(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
> +
> +%.stb: % libstb/create-container
> +	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)

Note that some firmware components do care about that PAYLOAD there as
it's passed through as a Label to be stored in the secure boot wrapper.

Note that they also just suddenly started caring about it one day and
didn't like, tell anybody or anything.

Anyway,

Reviewed-by: Stewart Smith <stewart@linux.ibm.com>
Oliver O'Halloran July 17, 2019, 5:35 a.m. UTC | #2
On Wed, Jul 17, 2019 at 3:23 PM Stewart Smith <stewart@linux.ibm.com> wrote:
>
> "Oliver O'Halloran" <oohall@gmail.com> writes:
> > +%.xz: %
> > +     $(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
> > +
> > +%.stb: % libstb/create-container
> > +     $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
>
> Note that some firmware components do care about that PAYLOAD there as
> it's passed through as a Label to be stored in the secure boot wrapper.
>
> Note that they also just suddenly started caring about it one day and
> didn't like, tell anybody or anything.

Which components?
Stewart Smith July 17, 2019, 7:50 a.m. UTC | #3
"Oliver O'Halloran" <oohall@gmail.com> writes:
> On Wed, Jul 17, 2019 at 3:23 PM Stewart Smith <stewart@linux.ibm.com> wrote:
>>
>> "Oliver O'Halloran" <oohall@gmail.com> writes:
>> > +%.xz: %
>> > +     $(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
>> > +
>> > +%.stb: % libstb/create-container
>> > +     $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
>>
>> Note that some firmware components do care about that PAYLOAD there as
>> it's passed through as a Label to be stored in the secure boot wrapper.
>>
>> Note that they also just suddenly started caring about it one day and
>> didn't like, tell anybody or anything.
>
> Which components?

At least Hostboot, and I have some memory of SBE but I could look at
that code *or* pour myself a glass of wine, and I think you know what's
about to win that fight :)
diff mbox series

Patch

diff --git a/Makefile.main b/Makefile.main
index fac6e4487460..2997b6ebc305 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -258,18 +258,9 @@  ALL_OBJS = $(OBJS) version.o
 ALL_OBJS_1 = $(TARGET).tmp.a asm/dummy_map.o
 ALL_OBJS_2 = $(TARGET).tmp.a asm/real_map.o
 
-$(TARGET).lid.xz: $(TARGET).lid
-	$(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
-
 $(TARGET).lid: $(TARGET).elf
 	$(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@)
 
-$(TARGET).lid.stb: $(TARGET).lid libstb/create-container
-	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
-
-$(TARGET).lid.xz.stb: $(TARGET).lid.xz libstb/create-container
-	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
-
 $(TARGET).tmp.a: $(ALL_OBJS)
 	@rm -f $(TARGET).tmp.a
 	$(call Q,AR, $(AR) rcsTPD $@ $(ALL_OBJS), $@)
diff --git a/Makefile.rules b/Makefile.rules
index 11b0e5ee8a19..6b35dbafbd9e 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -76,3 +76,9 @@  endif
 
 %.map: %.elf
 	$(call Q,NM, $(NM) --synthetic -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@)
+
+%.xz: %
+	$(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
+
+%.stb: % libstb/create-container
+	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)