[U-Boot] [PATCH] Add support to mkconfig for setting simple #defines in config.h

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

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

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

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

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

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

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

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

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

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
participants (4)
-
Kumar Gala
-
Mike Frysinger
-
Scott Wood
-
Wolfgang Denk