define Build/check-size
@imagesize="$$(stat -c%s $@)"; \
- limitsize="$$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE))))))"; \
+ limitsize="$$(($(call exp_units,$(if $(1),$(1),$(IMAGE_SIZE)))))"; \
[ $$limitsize -ge $$imagesize ] || { \
$(call ERROR_MESSAGE, WARNING: Image file $@ is too big: $$imagesize > $$limitsize); \
rm -f $@; \
define Build/pad-offset
let \
size="$$(stat -c%s $@)" \
- pad="$(subst k,* 1024,$(word 1, $(1)))" \
- offset="$(subst k,* 1024,$(word 2, $(1)))" \
+ pad="$(call exp_units,$(word 1, $(1)))" \
+ offset="$(call exp_units,$(word 2, $(1)))" \
pad="(pad - ((size + offset) % pad)) % pad" \
newsize='size + pad'; \
dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync
define Build/zyxel-ras-image
let \
- newsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
+ newsize="$(call exp_units,$(RAS_ROOTFS_SIZE))"; \
$(STAGING_DIR_HOST)/bin/mkrasimage \
-b $(RAS_BOARD) \
-v $(RAS_VERSION) \
override MAKE:=$(_SINGLE)$(SUBMAKE)
override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE)
+exp_units = $(subst k, * 1024,$(subst m, * 1024k,$(subst g, * 1024m,$(1))))
+
target_params = $(subst +,$(space),$*)
param_get = $(patsubst $(1)=%,%,$(filter $(1)=%,$(2)))
param_get_default = $(firstword $(call param_get,$(1),$(2)) $(3))
let \
size="$$(stat -c%s $@)" \
- pad="$(subst k,* 1024,$(BLOCKSIZE))" \
+ pad="$(call exp_units,$(BLOCKSIZE))" \
pad="(pad - (size % pad)) % pad" \
newsize='size + pad' ; \
[ $$newsize -lt $$((0x660000)) ] && newsize=0x660000 ; \
define Build/zyxel-factory
let \
- maxsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
+ maxsize="$(call exp_units,$(RAS_ROOTFS_SIZE))"; \
let size="$$(stat -c%s $@)"; \
if [ $$size -lt $$maxsize ]; then \
$(STAGING_DIR_HOST)/bin/mkrasimage \
let \
size="$$(stat -c%s $@)" \
- pad="$(subst k,* 1024,$(BLOCKSIZE))" \
+ pad="$(call exp_units,$(BLOCKSIZE))" \
pad="(pad - (size % pad)) % pad" \
newsize='size + pad'; \
$(STAGING_DIR_HOST)/bin/mkmylofw \
-f $(kern_bin) \
$(if $(rtfs_bin),\
-a 0x20000 \
- -b $$(( $(subst k, * 1024,$(kern_size)) )) \
+ -b $$(( $(call exp_units,$(kern_size)) )) \
-f $(rtfs_bin),) \
$(if $(apnd_bin),\
-A $(apnd_bin) \
define Build/jcg-header
$(STAGING_DIR_HOST)/bin/jcgimage -v $(1) \
- $(if $(JCG_MAXSIZE), -m $$(($(subst k, * 1024,$(JCG_MAXSIZE)))),) \
+ $(if $(JCG_MAXSIZE), -m $$(($(call exp_units,$(JCG_MAXSIZE)))),) \
-u $@ -o $@.new
mv $@.new $@
endef
define Build/trx
$(STAGING_DIR_HOST)/bin/trx $(1) \
-o $@ \
- -m $$(($(subst k, * 1024,$(IMAGE_SIZE)))) \
+ -m $$(($(call exp_units,$(IMAGE_SIZE)))) \
-f $(IMAGE_KERNEL) \
-a 4 -f $(IMAGE_ROOTFS)
endef