[U-Boot] [PATCH V3 17/32] imximage.cfg: run files through C preprocessor

Stefano Babic sbabic at denx.de
Thu Oct 11 13:11:09 CEST 2012


Am 10/10/2012 04:03, schrieb Troy Kisky:
> On 10/8/2012 6:38 AM, Stefano Babic wrote:
>> On 04/10/2012 03:47, Troy Kisky wrote:
>>> The '#' used as comments in the files cause the preprocessor
>>> trouble, so change to /* */.
>>>
>>> Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>
>>> ---
>> Hi Troy,
>>
>>>   Makefile                                     |    3 +-
>>>   board/esg/ima3-mx53/imximage.cfg             |  120 ++++++-----
>>>   board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg |   90 ++++----
>>>   board/freescale/mx25pdk/imximage.cfg         |   77 +++----
>>>   board/freescale/mx51evk/imximage.cfg         |  114 +++++-----
>>>   board/freescale/mx53ard/imximage_dd3.cfg     |   83 ++++----
>>>   board/freescale/mx53evk/imximage.cfg         |   86 ++++----
>>>   board/freescale/mx53loco/imximage.cfg        |   83 ++++----
>>>   board/freescale/mx53smd/imximage.cfg         |   83 ++++----
>>>   board/freescale/mx6qarm2/imximage.cfg        |   88 ++++----
>>>   board/genesi/mx51_efikamx/imximage_mx.cfg    |  132 ++++++------
>>>   board/genesi/mx51_efikamx/imximage_sb.cfg    |  126 +++++------
>>>   board/ttcontrol/vision2/imximage_hynix.cfg   |  295
>>> ++++++++++++++------------
>>>   13 files changed, 727 insertions(+), 653 deletions(-)
>>>
>> I see the C preprocessor as an optional feature, instead of a rule
>> everybody must follow.
>>
>>> diff --git a/Makefile b/Makefile
>>> index a40d4cc..64ff1b8 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -431,7 +431,8 @@ $(obj)u-boot.img:    $(obj)u-boot.bin
>>>           -d $< $@
>>>     $(obj)u-boot.imx:       $(obj)u-boot.bin
>>> -        $(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
>>> +        $(CC) -E -x c $(CONFIG_IMX_CONFIG) -I./include -o
>>> $(obj)imxcfg.imx
>>> +        $(obj)tools/mkimage -n  $(obj)imxcfg.imx -T imximage \
>>>           -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
>> In fact, adding this rule here requires that each board configuration
>> must be changed. And for all of them, running the preprocessor is
>> unnnecessary.
>>
>> What about to add this rule only to the Makefile of the boards that
>> require preprocessing ?
>>
>> Best regards,
>> Stefano Babic
>>
> How about this to do the job....
> 
> 
> 
> 
> 
> Subject: [PATCH 17/32] boards.cfg: run mx6q_4x_mt41j128.pcfg through C
>  preprocessor
> 
> The '#' used as comments in the cfg file cause the preprocessor
> trouble, so change to /* */. Also, rename mx6q_4x_mt41j128.cfg
> to mx6q_4x_mt41j128.pcfg.
> 
> Files with extension of .pcfg are run through the preprocessor
> before being given to mkimage.
> 
> Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>
> 
> ---
> v4: Don't run every file through preprocessor, only .pcfg files
> ---
>  .gitignore                                         |    1 +
>  Makefile                                           |   16 +++-
>  ...{mx6q_4x_mt41j128.cfg => mx6q_4x_mt41j128.pcfg} |   90
> ++++++++++----------
>  boards.cfg                                         |    4 +-
>  4 files changed, 63 insertions(+), 48 deletions(-)
>  rename board/freescale/imx/ddr/{mx6q_4x_mt41j128.cfg =>
> mx6q_4x_mt41j128.pcfg} (65%)
> 
> diff --git a/.gitignore b/.gitignore
> index d91e91b..e5273bd 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -15,6 +15,7 @@
>  *.swp
>  *.patch
>  *.bin
> +*.pcfgtmp
> 
>  # Build tree
>  /build-*
> diff --git a/Makefile b/Makefile
> index a40d4cc..99666b9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -430,8 +430,17 @@ $(obj)u-boot.img:  $(obj)u-boot.bin
>                         sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
>                 -d $< $@
> 
> -$(obj)u-boot.imx:       $(obj)u-boot.bin
> -               $(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
> +ifeq ($(suffix $(patsubst "%",%,$(CONFIG_IMX_CONFIG))),.pcfg)
> +$(obj)$(patsubst "%",%,$(CONFIG_IMX_CONFIG))tmp: %.pcfgtmp : %.pcfg
> +               $(CC) -E -x c $< -I./include -o $@
> +
> +$(obj)u-boot.imx: %.imx : %.bin $(obj)$(patsubst
> "%",%,$(CONFIG_IMX_CONFIG))tmp
> +else
> +$(obj)u-boot.imx: %.imx : %.bin $(patsubst "%",%,$(CONFIG_IMX_CONFIG))
> +endif
> +
> +$(obj)u-boot.imx:
> +               $(obj)tools/mkimage -n  $(filter-out %.bin,$^) -T
> imximage \
>                 -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
> 

Does it work something more direct (I have not tested, really...) ?

In board Makefile, for example board/freescale/mx6qsabrelite, a rule for
the imximage file:

$(CONFIG_IMX_CONFIG): <your base file, mx6q_4x_mt41j128.cfg maybe>
	$(CC) -E -x c $< -I./include -o $@

And let unchanged in the main Makefile. So CONFIG_IMX_CONFIG is produced
and you do not need to change logic in the main Makefile.

Regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list