public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
@ 2009-08-07 14:03 Kumar Gala
  2009-08-07 19:22 ` Scott Wood
  0 siblings, 1 reply; 10+ messages in thread
From: Kumar Gala @ 2009-08-07 14:03 UTC (permalink / raw)
  To: u-boot

To simplify the top level makefile it useful to be able to set
some #defines in config.h to express different configurations.

Added a -D option that allows us to replace:

MPC8536DS_36BIT_config \
MPC8536DS_config:       unconfig
        @mkdir -p $(obj)include
        @echo "#define CONFIG_$(@:_config=) 1"  >$(obj)include/config.h
        @$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds freescale

with:

MPC8536DS_36BIT_config \
MPC8536DS_config:       unconfig
	@$(MKCONFIG) -D $(@:_config=)=1 MPC8536DS ppc mpc85xx mpc8536ds freescale

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 mkconfig |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mkconfig b/mkconfig
index b0bbbd1..8d778e5 100755
--- a/mkconfig
+++ b/mkconfig
@@ -10,12 +10,14 @@
 
 APPEND=no	# Default: Create new config file
 BOARD_NAME=""	# Name to print in make output
+DEFINES=""
 
 while [ $# -gt 0 ] ; do
 	case "$1" in
 	--) shift ; break ;;
 	-a) shift ; APPEND=yes ;;
 	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
+	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
 	*)  break ;;
 	esac
 done
@@ -84,5 +86,7 @@ fi
 echo "/* Automatically generated - do not edit */" >>config.h
 echo "#include <configs/$1.h>" >>config.h
 echo "#include <asm/config.h>" >>config.h
+echo -e ${DEFINES} >> config.h
+
 
 exit 0
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-07 14:03 [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h Kumar Gala
@ 2009-08-07 19:22 ` Scott Wood
  2009-08-13  5:15   ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Wood @ 2009-08-07 19:22 UTC (permalink / raw)
  To: u-boot

On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
>  while [ $# -gt 0 ] ; do
>  	case "$1" in
>  	--) shift ; break ;;
>  	-a) shift ; APPEND=yes ;;
>  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
> +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;

How about something like:

-D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;

...

for i in ${DEFINES}; do
	echo "#define CONFIG_${i}" >> config.h
done

?

This would allow multiple underscore-separated booleans in the target
name.

If we really need values on the options, we could change CONFIG_${i} to
CONFIG_${i/=/\t} similar to what you do above, and embed the "=value" in
the target name (MPC83536DS_NAND_FOO=2_36BIT_BAR=blah ends up defining
NAND, FOO as 2, 36BIT, and BAR as blah).  I think simple bools
(MPC8536DS_NAND_36BIT) will be enough until we get kconfig, though.

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-07 19:22 ` Scott Wood
@ 2009-08-13  5:15   ` Mike Frysinger
  2009-08-13 15:28     ` Scott Wood
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2009-08-13  5:15 UTC (permalink / raw)
  To: u-boot

On Friday 07 August 2009 15:22:15 Scott Wood wrote:
> On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
> >  while [ $# -gt 0 ] ; do
> >  	case "$1" in
> >  	--) shift ; break ;;
> >  	-a) shift ; APPEND=yes ;;
> >  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
> > +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
>
> How about something like:
>
> -D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;

mkconfig's interpreter is /bin/sh, so if you want to use the string replace 
bashism, you'll have to change it to /bin/bash.  or use the POSIX:
"#define ${1%%=*}\t${1#*=}\n${DEFINES}"
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/e5fb49f9/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13  5:15   ` Mike Frysinger
@ 2009-08-13 15:28     ` Scott Wood
  2009-08-13 18:26       ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Wood @ 2009-08-13 15:28 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Friday 07 August 2009 15:22:15 Scott Wood wrote:
>> On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
>>>  while [ $# -gt 0 ] ; do
>>>  	case "$1" in
>>>  	--) shift ; break ;;
>>>  	-a) shift ; APPEND=yes ;;
>>>  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
>>> +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
>> How about something like:
>>
>> -D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;
> 
> mkconfig's interpreter is /bin/sh, so if you want to use the string replace 
> bashism, you'll have to change it to /bin/bash.  or use the POSIX:
> "#define ${1%%=*}\t${1#*=}\n${DEFINES}"

Do you have a non-bash version of my alternative (which handles multiple 
symbols rather than one symbol/value pair per -D)?  Or do we need to 
invoke sed to be portable?

Or can we just use bash? :-)

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 15:28     ` Scott Wood
@ 2009-08-13 18:26       ` Mike Frysinger
  2009-08-13 18:38         ` Scott Wood
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2009-08-13 18:26 UTC (permalink / raw)
  To: u-boot

On Thursday 13 August 2009 11:28:09 Scott Wood wrote:
> Mike Frysinger wrote:
> > On Friday 07 August 2009 15:22:15 Scott Wood wrote:
> >> On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
> >>>  while [ $# -gt 0 ] ; do
> >>>  	case "$1" in
> >>>  	--) shift ; break ;;
> >>>  	-a) shift ; APPEND=yes ;;
> >>>  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
> >>> +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
> >>
> >> How about something like:
> >>
> >> -D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;
> >
> > mkconfig's interpreter is /bin/sh, so if you want to use the string
> > replace bashism, you'll have to change it to /bin/bash.  or use the
> > POSIX: "#define ${1%%=*}\t${1#*=}\n${DEFINES}"
>
> Do you have a non-bash version of my alternative (which handles multiple
> symbols rather than one symbol/value pair per -D)?

i dont know what you mean by one symbol/value pair per -D.  i assume that the 
-D option here has the exact same behavior as that of gcc.  do you have an 
example invocation of mkconfig to show what you mean ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/d961574c/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 18:26       ` Mike Frysinger
@ 2009-08-13 18:38         ` Scott Wood
  2009-08-13 20:02           ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Wood @ 2009-08-13 18:38 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Thursday 13 August 2009 11:28:09 Scott Wood wrote:
>> Mike Frysinger wrote:
>>> On Friday 07 August 2009 15:22:15 Scott Wood wrote:
>>>> On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
>>>>>  while [ $# -gt 0 ] ; do
>>>>>  	case "$1" in
>>>>>  	--) shift ; break ;;
>>>>>  	-a) shift ; APPEND=yes ;;
>>>>>  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
>>>>> +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
>>>> How about something like:
>>>>
>>>> -D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;
>>> mkconfig's interpreter is /bin/sh, so if you want to use the string
>>> replace bashism, you'll have to change it to /bin/bash.  or use the
>>> POSIX: "#define ${1%%=*}\t${1#*=}\n${DEFINES}"
>> Do you have a non-bash version of my alternative (which handles multiple
>> symbols rather than one symbol/value pair per -D)?
> 
> i dont know what you mean by one symbol/value pair per -D.  i assume that the 
> -D option here has the exact same behavior as that of gcc.

That's what Kumar's patch has it do, but I'm not sure that it's the most 
useful thing to expose to the makefile.  Maybe we should use a different 
option letter (-d?) and implement the GCC-like symbol/value semantics 
later if we end up needing it.

Hopefully kconfig is merged before then. :-)

> do you have an example invocation of mkconfig to show what you mean ?

Consider a target such as BOARDNAME_66MHz_NANDBOOT_PCISLAVE.

It could then invoke "$(MKCONFIG) -D $@ -a configname arch cpu board".
mkconfig would break up the -D argument into:

#define CONFIG_BOARDNAME
#define CONFIG_66MHz
#define CONFIG_NANDBOOT
#define CONFIG_PCISLAVE

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 18:38         ` Scott Wood
@ 2009-08-13 20:02           ` Mike Frysinger
  2009-08-13 20:15             ` Wolfgang Denk
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2009-08-13 20:02 UTC (permalink / raw)
  To: u-boot

On Thursday 13 August 2009 14:38:45 Scott Wood wrote:
> Mike Frysinger wrote:
> > On Thursday 13 August 2009 11:28:09 Scott Wood wrote:
> >> Mike Frysinger wrote:
> >>> On Friday 07 August 2009 15:22:15 Scott Wood wrote:
> >>>> On Fri, Aug 07, 2009 at 09:03:03AM -0500, Kumar Gala wrote:
> >>>>>  while [ $# -gt 0 ] ; do
> >>>>>  	case "$1" in
> >>>>>  	--) shift ; break ;;
> >>>>>  	-a) shift ; APPEND=yes ;;
> >>>>>  	-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
> >>>>> +	-D) shift ; DEFINES="#define ${1/=/\t}\n"${DEFINES} ; shift ;;
> >>>>
> >>>> How about something like:
> >>>>
> >>>> -D) shift ; DEFINES="${1//_/ } ${DEFINES}"; shift ;;
> >>>
> >>> mkconfig's interpreter is /bin/sh, so if you want to use the string
> >>> replace bashism, you'll have to change it to /bin/bash.  or use the
> >>> POSIX: "#define ${1%%=*}\t${1#*=}\n${DEFINES}"
> >>
> >> Do you have a non-bash version of my alternative (which handles multiple
> >> symbols rather than one symbol/value pair per -D)?
> >
> > i dont know what you mean by one symbol/value pair per -D.  i assume that
> > the -D option here has the exact same behavior as that of gcc.
>
> That's what Kumar's patch has it do, but I'm not sure that it's the most
> useful thing to expose to the makefile.  Maybe we should use a different
> option letter (-d?) and implement the GCC-like symbol/value semantics
> later if we end up needing it.

if the proposed mkconfig -D isnt like gcc's -D, then a new letter should be 
picked i think to avoid confusion

> > do you have an example invocation of mkconfig to show what you mean ?
>
> Consider a target such as BOARDNAME_66MHz_NANDBOOT_PCISLAVE.
>
> It could then invoke "$(MKCONFIG) -D $@ -a configname arch cpu board".
> mkconfig would break up the -D argument into:
>
> #define CONFIG_BOARDNAME
> #define CONFIG_66MHz
> #define CONFIG_NANDBOOT
> #define CONFIG_PCISLAVE

then yes, a sed would have to be used.  maybe something like:
DEFINES="`echo "_$*" | sed 's:_:\n#define CONFIG_:g'`${DEFINES}" ; shift ;;
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/61280f37/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 20:02           ` Mike Frysinger
@ 2009-08-13 20:15             ` Wolfgang Denk
  2009-08-13 20:23               ` Mike Frysinger
  2009-08-13 22:01               ` Scott Wood
  0 siblings, 2 replies; 10+ messages in thread
From: Wolfgang Denk @ 2009-08-13 20:15 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200908131602.20315.vapier@gentoo.org> you wrote:
>
> > Consider a target such as BOARDNAME_66MHz_NANDBOOT_PCISLAVE.
> >
> > It could then invoke "$(MKCONFIG) -D $@ -a configname arch cpu board".
> > mkconfig would break up the -D argument into:
> >
> > #define CONFIG_BOARDNAME
> > #define CONFIG_66MHz
> > #define CONFIG_NANDBOOT
> > #define CONFIG_PCISLAVE
>
> then yes, a sed would have to be used.  maybe something like:
> DEFINES="`echo "_$*" | sed 's:_:\n#define CONFIG_:g'`${DEFINES}" ; shift > ;;

Nope, this doesn't work.

We have many names with more than one underscore in it (all the
CONFIG_CMD_* and CONFIG_SYS_* and CONFIG_BOOTP_* and ...).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Chapter 1 -- The story so  far:
In the beginning the Universe was created. This has  made  a  lot  of
people very angry and been widely regarded as a bad move.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 20:15             ` Wolfgang Denk
@ 2009-08-13 20:23               ` Mike Frysinger
  2009-08-13 22:01               ` Scott Wood
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2009-08-13 20:23 UTC (permalink / raw)
  To: u-boot

On Thursday 13 August 2009 16:15:11 Wolfgang Denk wrote:
> Mike Frysinger wrote:
> > > Consider a target such as BOARDNAME_66MHz_NANDBOOT_PCISLAVE.
> > >
> > > It could then invoke "$(MKCONFIG) -D $@ -a configname arch cpu board".
> > > mkconfig would break up the -D argument into:
> > >
> > > #define CONFIG_BOARDNAME
> > > #define CONFIG_66MHz
> > > #define CONFIG_NANDBOOT
> > > #define CONFIG_PCISLAVE
> >
> > then yes, a sed would have to be used.  maybe something like:
> > DEFINES="`echo "_$*" | sed 's:_:\n#define CONFIG_:g'`${DEFINES}" ; shift
> > > ;;
>
> Nope, this doesn't work.
>
> We have many names with more than one underscore in it (all the
> CONFIG_CMD_* and CONFIG_SYS_* and CONFIG_BOOTP_* and ...).

i'm only giving POSIX compliant versions of proposed code.  the issue you 
raised i dont care about -- that's for the OP to handle.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/94a9ea16/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h
  2009-08-13 20:15             ` Wolfgang Denk
  2009-08-13 20:23               ` Mike Frysinger
@ 2009-08-13 22:01               ` Scott Wood
  1 sibling, 0 replies; 10+ messages in thread
From: Scott Wood @ 2009-08-13 22:01 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 13, 2009 at 10:15:11PM +0200, Wolfgang Denk wrote:
> Nope, this doesn't work.
> 
> We have many names with more than one underscore in it (all the
> CONFIG_CMD_* and CONFIG_SYS_* and CONFIG_BOOTP_* and ...).

So?  Let the board config file translate from the target names into the
real names.  We can put the former in a CONFIG_OPT_* namespace if you
prefer.  There certainly should never be any CONFIG_SYS_ being defined by
this mechanism -- it's explicitly for things the user is specifying.

This is an interim measure until we get kconfig (not a replacement for
it) and is made necessary by your refusal to accept the status quo of
target handling until then.  Kumar's version does not handle targets with
more than one orthogonal option.

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-08-13 22:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-07 14:03 [U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h Kumar Gala
2009-08-07 19:22 ` Scott Wood
2009-08-13  5:15   ` Mike Frysinger
2009-08-13 15:28     ` Scott Wood
2009-08-13 18:26       ` Mike Frysinger
2009-08-13 18:38         ` Scott Wood
2009-08-13 20:02           ` Mike Frysinger
2009-08-13 20:15             ` Wolfgang Denk
2009-08-13 20:23               ` Mike Frysinger
2009-08-13 22:01               ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox