mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] make: Add bbenv-y target to generate default environment files
Date: Tue, 25 Feb 2014 15:18:01 +0100	[thread overview]
Message-ID: <1393337884-17282-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1393337884-17282-1-git-send-email-s.hauer@pengutronix.de>

This adds a target to generate environment files from directories.
These are compiled into the barebox binary.

use it as:

bbenv-$(CONFIG_SOMETHING) += my-environment

The directory containing the files to compile into the binary
should be named my-environment.

This can be accessed in C code later as:

extern unsigned char __bbenv_my_environment_start[];
extern unsigned char __bbenv_my_environment_end[];

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Makefile             |  2 +-
 scripts/Makefile.lib | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index b48240a..779ad74 100644
--- a/Makefile
+++ b/Makefile
@@ -1022,7 +1022,7 @@ clean: archclean $(clean-dirs)
 	@find . $(RCS_FIND_IGNORE) \
 		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-		-o -name '*.symtypes' \) \
+		-o -name '*.symtypes' -o -name '*.bbenv.S' -o -name "*.bbenv" \) \
 		-type f -print | xargs rm -f
 
 # mrproper - Delete all generated files, including .config
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e87e401..f71c3b7 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -98,6 +98,7 @@ multi-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
 multi-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
 obj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
+bbenv-y		:= $(addprefix $(obj)/,$(bbenv-y))
 
 # These flags are needed for modversions and compiling, so we define them here
 # already
@@ -229,6 +230,34 @@ $(obj)/%.dtb: $(src)/%.dts FORCE
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
 
+obj-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX),$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S,$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
+
+quiet_cmd_env_S = ENV.S   $@
+cmd_env_S =							\
+(								\
+	echo '\#include <asm-generic/barebox.lds.h>';		\
+	echo '.section .bbenv.rodata.$(subst -,_,$(*F)),"a"';	\
+	echo '.balign STRUCT_ALIGNMENT';			\
+	echo '.global __bbenv_$(subst -,_,$(*F))_start';	\
+	echo '__bbenv_$(subst -,_,$(*F))_start:';		\
+	echo '.incbin "$<" ';					\
+	echo '__bbenv_$(subst -,_,$(*F))_end:';			\
+	echo '.global __bbenv_$(subst -,_,$(*F))_end';		\
+	echo '.balign STRUCT_ALIGNMENT';			\
+) > $@
+
+$(obj)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S: $(src)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX) FORCE
+	$(call if_changed,env_S)
+
+quiet_cmd_env = ENV     $@
+cmd_env=$(srctree)/scripts/genenv $(srctree) $(objtree) $@ $<
+
+%.bbenv$(DEFAULT_COMPRESSION_SUFFIX): % FORCE
+	$(call cmd,env)
+
 # Bzip2
 # ---------------------------------------------------------------------------
 
-- 
1.8.5.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-02-25 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25 14:18 Add bbenv-y support Sascha Hauer
2014-02-25 14:18 ` Sascha Hauer [this message]
2014-02-25 14:18 ` [PATCH 2/4] move defaultenv-1 to defaultenv/defaultenv-1 Sascha Hauer
2014-02-25 14:18 ` [PATCH 3/4] move defaultenv-2 to defaultenv/defaultenv-2-* Sascha Hauer
2014-02-25 14:18 ` [PATCH 4/4] defaultenv: Allow multiple defaultenvironment overlays Sascha Hauer

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=1393337884-17282-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox