From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/8] Implement autoconf header file
Date: Sun, 10 Nov 2013 20:47:17 +0100 [thread overview]
Message-ID: <201311102047.17874.marex@denx.de> (raw)
In-Reply-To: <1382800457-26608-2-git-send-email-sjg@chromium.org>
Dear Simon Glass,
> Add support for generating an autoconf.h header file that can be used in
> the source instead of #ifdef.
>
> For example, instead of:
>
> #ifdef CONFIG_VERSION_VARIABLE
> setenv("ver", version_string); /* set version variable */
> #endif
I hope this has nothing to do with autoconf(1) .
[...]
> +# The file is regenerated when any U-Boot header file changes.
> +$(obj)include/generated/autoconf.h: $(obj)include/config.h
> + @$(XECHO) Generating $@ ; \
> + set -e ; \
> + : Extract the config macros to a C header file ; \
> + $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
> + sed -n -f tools/scripts/define2value.sed > $@.tmp; \
> + : Regenerate our list of all config macros if neeed ; \
> + if [ ! -f $@-all.tmp ] || \
> + find $(src) -name '*.h' -type f -newer $@-all.tmp | \
> + egrep -qv 'include/(autoconf.h|generated|config.h)'; \
> + then \
> + : Extract all config macros from all C header files ; \
> + : We can grep for CONFIG since the value will be dropped ; \
> + ( \
> + find ${src} -name "*.h" -type f | xargs \
> + cat | grep CONFIG | \
> + sed -n -f tools/scripts/define2zero.sed \
Won't "find ... -exec grep CONFIG \; | sed ..." work here and drop some extra
overhead ?
> + ) | sort | uniq > $@-all.tmp; \
"sort -u" maybe ?
> + fi; \
> + : Extract the enabled config macros to a C header file ; \
> + $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
> + sed -n -f tools/scripts/define2zero.sed | \
> + sort > $@-enabled.tmp; \
> + set -e ; \
> + : Find CONFIGs that are not enabled ; \
> + comm -13 $@-enabled.tmp $@-all.tmp >>$@.tmp && \
> + mv $@.tmp $@
[...]
> diff --git a/tools/scripts/define2value.sed
> b/tools/scripts/define2value.sed new file mode 100644
> index 0000000..205f9fe
> --- /dev/null
> +++ b/tools/scripts/define2value.sed
> @@ -0,0 +1,37 @@
> +#
> +# Sed script to parse CPP macros and generate a list of CONFIG macros
> +#
> +# This converts:
> +# #define CONFIG_XXX value
> +#into:
> +# #define autoconf_xxx() value
> +# #define autoconf_has_xxx() 1
> +
> +# Macros with parameters are ignored.
> +# (Note we avoid + since it doesn't appear to work)
> +/^#define CONFIG_[A-Za-z0-9_][A-Za-z0-9_]*(/ {
> + d
> +}
> +
> +# Only process values prefixed with #define CONFIG_
> +/^#define CONFIG_[A-Za-z0-9_][A-Za-z0-9_]*/ {
You might want to adjust it this way:
/^[[:blank:]]\+#define[[:blank:]]\+[[:alnum:]_]\+/
This will pick "#define"s prefixed and suffixed with arbitrary amount of
whitespace.
> + # Strip the #define prefix
> + s/#define[ \t]*CONFIG_/autoconf_/;
This will pick #defineCONFIG . Maybe "#define[[:blank:]]\+"
> + # Change to form CONFIG_*=VALUE
> + s/[\t ][\t ]*/=/;
> + # Handle lines with no value
> + s/^\([^=]*\)$/\1=/;
I wonder, how will this handle lines like:
include/configs/yucca.h:#define CONFIG_SYS_FLASH_WORD_SIZE unsigned char
or
include/configs/at91sam9m10g45ek.h:#define CONFIG_SYS_PROMPT "U-Boot>
"
or
#define CONFIG_FOO \
value_is_bar \
another_value_quux
?
> + # Drop trailing spaces
> + s/ *$//;
> + # Change empty values to '1'
> + s/=$/=1/;
> + # Add #define at the start
> + s/^\([^=]*\)=/#define \L\1() /
> + # print the line
> + p
> + # Create autoconf_has_...(), value 1
> + s/().*/() 1/
> + s/\(autoconf_\)/\1has_/
> + # print the line
> + p
> +}
I'm tempted to rework this as a one-liner, but please stop me if you consider
that worthless.
[...]
next prev parent reply other threads:[~2013-11-10 19:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-26 15:14 [U-Boot] [PATCH v4 0/8] Provide a mechanism to avoid using #ifdef everywhere Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 1/8] Implement autoconf header file Simon Glass
2013-11-10 19:47 ` Marek Vasut [this message]
2013-10-26 15:14 ` [U-Boot] [PATCH v4 2/8] main: Use autoconf for boot retry feature Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 3/8] main: Remove CONFIG #ifdefs from the abortboot() code Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 4/8] main: Use autoconf to remove #ifdefs around process_boot_delay() Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 5/8] main: Use autoconf for boot_delay code Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 6/8] main: Use autoconf for parser selection Simon Glass
2013-10-28 14:21 ` Michal Simek
2013-10-26 15:14 ` [U-Boot] [PATCH v4 7/8] main: Use autoconf in command line reading Simon Glass
2013-10-26 15:14 ` [U-Boot] [PATCH v4 8/8] main: Use autoconf in main_loop() Simon Glass
2013-10-28 14:44 ` [U-Boot] [PATCH v4 0/8] Provide a mechanism to avoid using #ifdef everywhere Wolfgang Denk
2013-10-28 15:32 ` Tom Rini
2013-10-28 20:31 ` Simon Glass
2013-11-06 7:24 ` Wolfgang Denk
2013-11-06 8:30 ` Stefan Roese
2013-11-07 9:20 ` Albert ARIBAUD
2013-11-10 4:24 ` Simon Glass
2013-11-10 12:58 ` Wolfgang Denk
2014-01-14 10:11 ` Detlev Zundel
2014-01-15 18:11 ` Simon Glass
2014-01-17 15:13 ` Detlev Zundel
2014-01-26 20:58 ` Simon Glass
-- strict thread matches above, loose matches on Subject: below --
2013-06-17 14:44 Simon Glass
2013-06-17 14:44 ` [U-Boot] [PATCH v4 1/8] Implement autoconf header file Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201311102047.17874.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.