Newer
Older
barebox / scripts / Makefile.lib
@Masahiro Yamada Masahiro Yamada on 25 May 2020 19 KB kbuild: switch over to thin archive
# SPDX-License-Identifier: GPL-2.0
# Backward compatibility
asflags-y  += $(EXTRA_AFLAGS)
ccflags-y  += $(EXTRA_CFLAGS)
cppflags-y += $(EXTRA_CPPFLAGS)
ldflags-y  += $(EXTRA_LDFLAGS)
always-y   += $(always)
hostprogs  += $(hostprogs-y) $(hostprogs-m)

# Figure out what we need to build from the various variables
# ===========================================================================

# When an object is listed to be built compiled-in and modular,
# only build the compiled-in version

obj-m := $(filter-out $(obj-y),$(obj-m))

# Libraries are always collected in one lib file.
# Filter out objects already built-in

lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))

# Handle objects in subdirs
# ---------------------------------------------------------------------------
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
#   and add the directory to the list of dirs to descend into: $(subdir-y)
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
#   and add the directory to the list of dirs to descend into: $(subdir-m)

# lowlevel is present in the PBL if enabled
# otherwise in barebox
ifeq ($(CONFIG_PBL_IMAGE), y)
pbl-y		+= $(lwl-y)
else
obj-y		+= $(lwl-y)
endif

obj-y		+= $(obj-pbl-y)
pbl-y		+= $(obj-pbl-y)

# pbl objects are suffixed with .pbl.o
pbl-y		:= $(patsubst %.o,%.pbl.o,$(pbl-y))

# add subdir from $(obj-y) too so we do not need to have the dir define in
# both $(obj-y) and $(pbl-y)
__pbl-y		:= $(filter-out $(pbl-y), $(filter %/, $(obj-y)))
pbl-y		+= $(__pbl-y)

pbl-y		:= $(sort $(patsubst %/, %/built-in.pbl.a, $(pbl-y)))

__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y	+= $(__subdir-y)
__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
subdir-m	+= $(__subdir-m)
obj-y		:= $(patsubst %/, %/built-in.a, $(obj-y))
obj-m		:= $(filter-out %/, $(obj-m))

# Subdirectories we need to descend into

subdir-ym	:= $(sort $(subdir-y) $(subdir-m))

# if $(foo-objs) exists, foo.o is a composite object
multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
multi-used   := $(multi-used-y) $(multi-used-m)
single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))

# Build list of the parts of our composite objects, our composite
# objects depend on those (obviously)
multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
multi-objs   := $(multi-objs-y) $(multi-objs-m)

# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
# tell kbuild to descend
__subdir-obj-y := $(filter %/built-in.pbl.a, $(pbl-y))
subdir-obj-y := $(filter %/built-in.a, $(obj-y))
subdir-obj-y += $(__subdir-obj-y)

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))

# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))

always-y += $(always-m)

# Add subdir path

extra-y		:= $(addprefix $(obj)/,$(extra-y))
always-y	:= $(addprefix $(obj)/,$(always-y))
targets		:= $(addprefix $(obj)/,$(targets))
obj-y		:= $(addprefix $(obj)/,$(obj-y))
obj-m		:= $(addprefix $(obj)/,$(obj-m))
lib-y		:= $(addprefix $(obj)/,$(lib-y))
pbl-y		:= $(addprefix $(obj)/,$(pbl-y))
subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
multi-used-y	:= $(addprefix $(obj)/,$(multi-used-y))
multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))

# target with $(obj)/ and its suffix stripped
target-stem = $(basename $(patsubst $(obj)/%,%,$@))

# These flags are needed for modversions and compiling, so we define them here
# already
# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
# end up in (or would, if it gets compiled in)
# Note: It's possible that one object gets potentially linked into more
#       than one module. In that case KBUILD_MODNAME will be set to foo_bar,
#       where foo and bar are the name of the modules.
name-fix = $(subst $(comma),_,$(subst -,_,$1))
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
modname_flags  = $(if $(filter 1,$(words $(modname))),\
                 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")

_c_flags       = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(target-stem).o)
_a_flags       = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(target-stem).o)
_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)

ifeq ($(CONFIG_UBSAN),y)
_CFLAGS_UBSAN   = $(eval _CFLAGS_UBSAN := $(CFLAGS_UBSAN))$(_CFLAGS_UBSAN)
_c_flags       += $(if $(patsubst n%,, \
		$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
		$(_CFLAGS_UBSAN))
PBL_CPPFLAGS   += $(call cc-option,-fno-sanitize=all)
endif

# If building barebox in a separate objtree expand all occurrences
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').

ifndef building_out_of_srctree
__c_flags	= $(_c_flags)
__a_flags	= $(_a_flags)
__cpp_flags     = $(_cpp_flags)
else

# -I$(obj) locates generated .h files
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
#   and locates generated .h files
# FIXME: Replace both with specific CFLAGS* statements in the makefiles
__c_flags	= $(call addtree,-I$(obj)) $(call flags,_c_flags)
__a_flags	=                          $(call flags,_a_flags)
__cpp_flags     =                          $(call flags,_cpp_flags)
endif

part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
part-of-pbl    = $(if $(filter $(basename $@).o, $(pbl-y))$(filter $@, $(pbl-target)),y)
quiet_modtag = $(if $(part-of-pbl),[P],$(if $(part-of-module),[M],   ))

pbl_cppflags = $(if $(part-of-pbl), -D__PBL__ $(PBL_CPPFLAGS))

modkern_cflags =                                          \
	$(if $(part-of-module),                           \
		$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))

modkern_aflags = $(if $(part-of-module),				\
			$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE),	\
			$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))

c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
		 $(__c_flags) $(modkern_cflags) $(pbl_cppflags) \
		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)

a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
		 $(__a_flags) $(modkern_aflags) $(pbl_cppflags)

cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)

ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y)

dtc_cpp_flags  = -Wp,-MD,$(depfile).pre -nostdinc                        \
		 -I$(srctree)/arch/$(SRCARCH)/dts/include		 \
		 -I$(srctree)/dts/include                                \
		 -I$(srctree)/include                                    \
		 -I$(srctree)/dts/src/                                   \
		 -undef -D__DTS__

ifdef CONFIG_BOOTM_FITIMAGE_PUBKEY
ifneq ($(CONFIG_BOOTM_FITIMAGE_PUBKEY),"")
dtc_cpp_flags += -DCONFIG_BOOTM_FITIMAGE_PUBKEY=\"$(CONFIG_BOOTM_FITIMAGE_PUBKEY)\"
endif
endif

# Finds the multi-part object the current object will be linked into
modname-multi = $(sort $(foreach m,$(multi-used),\
		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))

# Useful for describing the dependency of composite objects
# Usage:
#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
define multi_depend
$(foreach m, $(notdir $1), \
	$(eval $(obj)/$m: \
	$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
endef

# Shipped files
# ===========================================================================

quiet_cmd_shipped = SHIPPED $@
cmd_shipped = cat $< > $@

$(obj)/%:: $(src)/%_shipped
	$(call cmd,shipped)

# Commands useful for building a boot image
# ===========================================================================
#
#	Use as following:
#
#	target: source(s) FORCE
#		$(if_changed,ld/objcopy/gzip)
#
#	and add target to extra-y so that we know we have to
#	read in the saved command line

# Linking
# ---------------------------------------------------------------------------

quiet_cmd_ld = LD      $@
cmd_ld = $(LD) $(KBUILD_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \
	       $(filter-out FORCE,$^) -o $@

# Objcopy
# ---------------------------------------------------------------------------

quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@

# Gzip
# ---------------------------------------------------------------------------

quiet_cmd_gzip = GZIP    $@
cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
	(rm -f $@ ; false)

%.gz: %
	$(call if_changed,gzip)

# XZ
# ---------------------------------------------------------------------------
# Use xzkern to compress the kernel image and xzmisc to compress other things.
#
# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
# of the kernel decompressor. A BCJ filter is used if it is available for
# the target architecture. xzkern also appends uncompressed size of the data
# using size_append. The .xz format has the size information available at
# the end of the file too, but it's in more complex format and it's good to
# avoid changing the part of the boot code that reads the uncompressed size.
# Note that the bytes added by size_append will make the xz tool think that
# the file is corrupt. This is expected.
#
# xzmisc doesn't use size_append, so it can be used to create normal .xz
# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
# big dictionary would increase the memory usage too much in the multi-call
# decompression mode. A BCJ filter isn't used either.
quiet_cmd_xzkern = XZKERN  $@
cmd_xzkern = (cat $(filter-out FORCE,$^) | \
	sh $(srctree)/scripts/xz_wrap.sh && \
	$(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

quiet_cmd_xzmisc = XZMISC  $@
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
	(rm -f $@ ; false)

%.xzkern: %
	$(call if_changed,xzkern)

# DTC
# ---------------------------------------------------------------------------

DTC_FLAGS += -Wno-unit_address_vs_reg \
	 -Wno-unit_address_format \
	 -Wno-avoid_unnecessary_addr_size \
	 -Wno-alias_paths \
	 -Wno-alias_paths \
	 -Wno-graph_child_address \
	 -Wno-simple_bus_reg \
	 -Wno-unique_unit_address \
	 -Wno-pci_device_reg

ifeq ($(CONFIG_OF_OVERLAY_LIVE), y)
DTC_FLAGS += -@
endif

# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb = DTB     $@
cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD) > $@
$(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s FORCE
	$(call if_changed,dt_S_dtb)

quiet_cmd_dtc = DTC     $@
cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
		-i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
		-i $(srctree)/dts/src/$(SRCARCH) \
		-d $(depfile).dtc $(dtc-tmp) ; \
	cat $(depfile).pre $(depfile).dtc > $(depfile)

$(obj)/%.dtb: $(src)/%.dts FORCE
	$(call if_changed_dep,dtc)

dtc-tmp = $(subst $(comma),_,$(dot-target).dts)

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) $@ $<

# genenv is always called, but only generates output when the file actually
# changes, so that the dependent targets are not unnecessarily rebuilt
%.bbenv$(DEFAULT_COMPRESSION_SUFFIX): % FORCE
	$(call cmd,env)

# Bzip2
# ---------------------------------------------------------------------------

# Bzip2 and LZMA do not include size in file... so we have to fake that;
# append the size as a 32-bit littleendian number as gzip does.
size_append = printf $(shell						\
dec_size=0;								\
for F in $1; do								\
	fsize=$$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $$F);\
	dec_size=$$(expr $$dec_size + $$fsize);				\
done;									\
printf "%08x\n" $$dec_size |						\
	sed 's/\(..\)/\1 /g' | {					\
		read ch0 ch1 ch2 ch3;					\
		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
			printf '%s%03o' '\\' $$((0x$$ch)); 		\
		done;							\
	}								\
)

quiet_cmd_bzip2 = BZIP2   $@
cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
	bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

%.bz2: %
	$(call if_changed,bzip2)

# Lzma
# ---------------------------------------------------------------------------

quiet_cmd_lzma = LZMA    $@
cmd_lzma = (cat $(filter-out FORCE,$^) | \
	lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

%.lzma: %
	$(call if_changed,lzma)

quiet_cmd_lzo = LZO     $@
cmd_lzo = (cat $(filter-out FORCE,$^) | \
	lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

%.lzo: %
	$(call if_changed,lzo)

# XZ
# ---------------------------------------------------------------------------
# Use xzkern to compress the kernel image and xzmisc to compress other things.
#
# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
# of the kernel decompressor. A BCJ filter is used if it is available for
# the target architecture. xzkern also appends uncompressed size of the data
# using size_append. The .xz format has the size information available at
# the end of the file too, but it's in more complex format and it's good to
# avoid changing the part of the boot code that reads the uncompressed size.
# Note that the bytes added by size_append will make the xz tool think that
# the file is corrupt. This is expected.
#
# xzmisc doesn't use size_append, so it can be used to create normal .xz
# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
# big dictionary would increase the memory usage too much in the multi-call
# decompression mode. A BCJ filter isn't used either.
quiet_cmd_xzkern = XZKERN  $@
cmd_xzkern = (cat $(filter-out FORCE,$^) | \
	sh $(srctree)/scripts/xz_wrap.sh && \
	$(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

quiet_cmd_xzmisc = XZMISC  $@
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
	(rm -f $@ ; false)

# lz4
# ---------------------------------------------------------------------------

quiet_cmd_lz4 = LZ4     $@
cmd_lz4 = (cat $(filter-out FORCE,$^) | \
	lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
	(rm -f $@ ; false)

%.lz4: %
	$(call if_changed,lz4)

# comp_copy
# ---------------------------------------------------------------------------
# Wrapper which only copies a file, but compatible to the compression
# functions above. Appends the size to the result file
quiet_cmd_comp_copy ?= SHIPPED_S $@
cmd_comp_copy ?= cat $(filter-out FORCE,$^) > $@; \
                 $(call size_append, $(filter-out FORCE,$^)) >> $@

quiet_cmd_disasm = DISASM  $@
cmd_disasm = $(OBJDUMP) -d $< > $@

quiet_cmd_ln = LN      $@
cmd_ln = ln -sf $< $@

quiet_cmd_check_size = CHKSIZE $2
      cmd_check_size = set -e;						\
	size=`printf "%d" $2`;						\
	max_size=`printf "%d" $3`;					\
	if [ $$size -gt $$max_size ] ;					\
	then								\
		echo "$@ size $$size > maximum size $$max_size" >&2;	\
		exit 1 ;						\
	fi;

# Check size of a file
quiet_cmd_check_file_size = CHKFILESIZE $2
      cmd_check_file_size = set -e;					\
	size=`${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $2`;	\
	max_size=`printf "%d" $3`;					\
	if [ $$size -gt $$max_size ] ;					\
	then								\
		echo "$@ size $$size > maximum size $$max_size" >&2;	\
		exit 1 ;						\
	fi;

quiet_cmd_imximage__S_dcd= DCD_S   $@
cmd_imximage_S_dcd=						\
(								\
	echo '\#include <asm-generic/barebox.lds.h>';		\
	echo '.balign STRUCT_ALIGNMENT';			\
	echo '.global $(subst -,_,$(*F))_start';		\
	echo '$(subst -,_,$(*F))_start:';			\
	echo '.incbin "$<" ';					\
	echo '$(subst -,_,$(*F))_end:';				\
	echo '.global $(subst -,_,$(*F))_end';			\
	echo '.balign STRUCT_ALIGNMENT';			\
) > $@

overwrite-hab-env = $(shell set -e; \
      test -n "$(CONFIG_HAB_CERTS_ENV)"; \
      test -n "$$$(1)"; \
      echo -D$(1)=\\\"$(shell echo $$$(1))\\\")

imxcfg_cpp_flags  = -Wp,-MD,$(depfile) -nostdinc -x assembler-with-cpp \
      -I $(srctree)/include -I $(srctree)/arch/arm/mach-imx/include \
      -include include/generated/autoconf.h \
      $(call overwrite-hab-env,CONFIG_HABV3_SRK_PEM) \
      $(call overwrite-hab-env,CONFIG_HABV3_CSF_CRT_DER) \
      $(call overwrite-hab-env,CONFIG_HABV3_IMG_CRT_DER) \
      $(call overwrite-hab-env,CONFIG_HABV4_TABLE_BIN) \
      $(call overwrite-hab-env,CONFIG_HABV4_CSF_CRT_PEM) \
      $(call overwrite-hab-env,CONFIG_HABV4_IMG_CRT_PEM)

dcd-tmp = $(subst $(comma),_,$(dot-target).dcd.tmp)

quiet_cmd_dcd = DCD     $@
      cmd_dcd = $(CPP) $(imxcfg_cpp_flags) -o $(dcd-tmp) $< ; \
		$(objtree)/scripts/imx/imx-image -d -o $@ -c $(dcd-tmp)

$(obj)/%.dcd: $(obj)/%.imxcfg FORCE
	$(call if_changed,dcd)

$(obj)/%.dcd.S: $(obj)/%.dcd
	$(call cmd,imximage_S_dcd)

imximg-tmp = $(subst $(comma),_,$(dot-target).imxcfg.tmp)

quiet_cmd_imx_image = IMX-IMG $@
      cmd_imx_image = $(CPP) $(imxcfg_cpp_flags) -o $(imximg-tmp) $(2) ; \
		      $(objtree)/scripts/imx/imx-image -o $@ -b -c $(imximg-tmp) $(3) -f $<

quiet_cmd_kwb_image = KWB     $@
      cmd_kwb_image = scripts/kwbimage -p $< $(OPTS_$(@F)) -o $@

quiet_cmd_mvebu1_image = MVIMG   $@
      cmd_mvebu1_image = scripts/mvebuimg -v 1 create -o $@ $(foreach b,$(BINHDR_$(@F)),-b $b) $(FLAGS_$(@F)) $(BOOTSRC_$(@F)) $<

quiet_cmd_cboot_bct = BCT     $@
      cmd_cboot_bct = $(objtree)/scripts/tegra/cbootimage -gbct -s $(soc) $< $@

$(obj)/%.bct: $(obj)/%.bct.cfg
	$(call cmd,cboot_bct)

quiet_cmd_stm32_image = STM32-IMG $@
      cmd_stm32_image = $(objtree)/scripts/stm32image $(OPTS_$(@F)) -i $< -o $@

quiet_cmd_b64dec = B64DEC  $@
      cmd_b64dec = base64 -d $< > $@

# rsa_keys
# ---------------------------------------------------------------------------
# Build a header file containing a rsa public key.
#
# The keys can change without the build system noticing, so we always
# have to call rsatoc. To avoid unnecessary rebuilds of barebox compare
# its output to the last rsatoc output. Only if it differs overwrite the
# target file.
quiet_cmd_rsa_keys = RSAKEY  $@
cmd_rsa_keys = \
	$(objtree)/scripts/rsatoc -o $@.tmp $(2) &&			\
	if cmp -s $@.tmp $@; then					\
		rm $@.tmp;						\
	else								\
		mv $@.tmp $@;						\
	fi

%: %.base64
	$(call cmd,b64dec)