mkimage-profiles/lib/common.mk
Michael Shigorin 860e20c62d lib/common.mk: avoid using uninitialized variables
It somehow managed to evade me that $(TMP) might be uninitialized;
definitely should be checked before stuffing into sed substitution
command.

NB: this could be done in pure make but my take was less readable.

Thanks shadowsbrother/gmail for hitting and reporting this.
2012-05-26 14:08:19 +03:00

24 lines
539 B
Makefile

# common bits for building and reporting parts
# somewhat reusable
BUILD_LOG = build.log
# link it to BUILDDIR if possible
SYMLINK = build
# brevity postprocessor; not exported, for toplevel use only
SHORTEN = $(shell FILTER=; \
if [ -s "$(SYMLINK)" ]; then \
FILTER=" -e 's,$(BUILDDIR),$(SYMLINK),'"; \
fi; \
if [ -n "$$TMP" ]; then \
FILTER="$$FILTER -e 's,$$TMP,\$$TMP,'"; \
fi; \
if [ -n "$$HOME" ]; then \
FILTER="$$FILTER -e 's,$$HOME,~,'"; \
fi; \
if [ -n "$$FILTER" ]; then \
echo -n "| sed $$FILTER"; \
fi; \
)