• Michael Shigorin's avatar
    lib/common.mk: avoid using uninitialized variables · 860e20c6
    Michael Shigorin authored
    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.
    860e20c6
common.mk 539 Bytes
# 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; \
)