9
0
Fork 0

Kconfig: Select default compression type

Instead of asking explicitly for the default environment compression
type ask for the in-barebox default compression type. This also adds
a DEFAULT_COMPRESSION_SUFFIX make variable which can be used together
with the wildcard rules for compressed files to generate compressed
files without explicitly support each compression type.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-02-17 19:09:03 +01:00
parent 925e5b4b94
commit e9241844a8
4 changed files with 39 additions and 30 deletions

View File

@ -504,6 +504,23 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \
pbl-common-y := $(patsubst %/, %/built-in-pbl.o, $(common-y))
common-y := $(patsubst %/, %/built-in.o, $(common-y))
ifeq ($(CONFIG_DEFAULT_COMPRESSION_GZIP),y)
DEFAULT_COMPRESSION_SUFFIX := .gz
endif
ifeq ($(CONFIG_DEFAULT_COMPRESSED_BZIP2),y)
DEFAULT_COMPRESSION_SUFFIX := .bz2
endif
ifeq ($(CONFIG_DEFAULT_COMPRESSION_LZO),y)
DEFAULT_COMPRESSION_SUFFIX := .lzo
endif
ifeq ($(CONFIG_DEFAULT_COMPRESSION_LZ4),y)
DEFAULT_COMPRESSION_SUFFIX := .lz4
endif
ifeq ($(CONFIG_DEFAULT_COMPRESSION_NONE),y)
DEFAULT_COMPRESSION_SUFFIX :=
endif
export DEFAULT_COMPRESSION_SUFFIX
# Build barebox
# ---------------------------------------------------------------------------
# barebox is built from the objects selected by $(barebox-init) and

View File

@ -535,35 +535,38 @@ config DEFAULT_ENVIRONMENT
Enabling this option will give you a default environment when
the environment found in the environment sector is invalid
config DEFAULT_ENVIRONMENT_COMPRESSED
bool
depends on DEFAULT_ENVIRONMENT
depends on !IMAGE_COMPRESSION_LZO
depends on !IMAGE_COMPRESSION_GZIP
default y if ZLIB
default y if BZLIB
default y if LZO_DECOMPRESS
if DEFAULT_ENVIRONMENT_COMPRESSED
choice
prompt "compression"
prompt "default compression for in-barebox binaries"
default DEFAULT_COMPRESSION_NONE if PBL_IMAGE
default DEFAULT_COMPRESSION_LZO if LZO_DECOMPRESS
default DEFAULT_COMPRESSION_GZIP if ZLIB
default DEFAULT_COMPRESSION_LZ4 if LZ4_DECOMPRESS
default DEFAULT_COMPRESSION_BZIP2 if BZLIB
help
Select the default compression for in-barebox binary files. Files
compiled into barebox like for example the default environment will
be compressed with this compression type.
config DEFAULT_ENVIRONMENT_COMPRESSED_GZIP
config DEFAULT_COMPRESSION_GZIP
bool "gzip"
depends on ZLIB
config DEFAULT_ENVIRONMENT_COMPRESSED_BZIP2
config DEFAULT_COMPRESSION_BZIP2
bool "bzip2"
depends on BZLIB
config DEFAULT_ENVIRONMENT_COMPRESSED_LZO
config DEFAULT_COMPRESSION_LZO
bool "lzo"
depends on LZO_DECOMPRESS
endchoice
config DEFAULT_COMPRESSION_LZ4
bool "lz4"
depends on LZ4_DECOMPRESS
endif
config DEFAULT_COMPRESSION_NONE
bool "no compression"
endchoice
config HAVE_DEFAULT_ENVIRONMENT_NEW
bool

View File

@ -76,22 +76,11 @@ cmd_envs = ($(srctree)/scripts/genenv $(srctree) $(objtree) $@ $(DEFAULT_ENVIRON
$(obj)/barebox_default_env: FORCE
$(call cmd,envs)
barebox_default_env_comp =
ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_GZIP),y)
barebox_default_env_comp = .gz
endif
ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_BZIP2),y)
barebox_default_env_comp = .bz2
endif
ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_LZO),y)
barebox_default_env_comp = .lzo
endif
quiet_cmd_env_h = ENVH $@
cmd_env_h = cat $< | (cd $(obj) && $(objtree)/scripts/bin2c default_environment) > $@; \
echo "static const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
$(obj)/barebox_default_env.h: $(obj)/barebox_default_env$(barebox_default_env_comp) FORCE
$(obj)/barebox_default_env.h: $(obj)/barebox_default_env$(DEFAULT_COMPRESSION_SUFFIX) FORCE
$(call if_changed,env_h)
quiet_cmd_pwd_h = PWDH $@

View File

@ -52,7 +52,7 @@ static int register_default_env(void)
int ret;
void *defaultenv;
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED)) {
if (!IS_ENABLED(CONFIG_DEFAULT_COMPRESSION_NONE)) {
void *tmp = malloc(default_environment_size);
if (!tmp)