From e6f692856bf3cb32decc5850cf868cf1dc420e66 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 15 Dec 2015 12:07:14 -0600 Subject: [PATCH] Makefile: check $(shell) exit statuses Append " ok" or " no" to the output of every $(shell) invocation, and then use that to detect failures. Previously, failures were ignored. Signed-off-by: Rob Browning Tested-by: Rob Browning --- Makefile | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1e38797..5ffa480 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,29 @@ SHELL := bash pf := set -o pipefail -sampledata_rev := $(shell t/configure-sampledata --revision) +define isok + && echo " ok" || echo " no" +endef + +# If ok, strip trailing " ok" and return the output, otherwise, error +define shout +$(if $(subst ok,,$(lastword $(1))),$(error $(2)),$(shell x="$(1)"; echo $${x%???})) +endef + +sampledata_rev := $(shell t/configure-sampledata --revision $(isok)) +sampledata_rev := \ + $(call shout,$(sampledata_rev),Could not parse sampledata revision) + current_sampledata := t/sampledata/var/rev/v$(sampledata_rev) -OS:=$(shell uname | sed 's/[-_].*//') +os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok)) +os := $(call shout,$(os),Unable to determine OS) + CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS) CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS) SOEXT:=.so -ifeq ($(OS),CYGWIN) +ifeq ($(os),CYGWIN) SOEXT:=.dll endif @@ -20,7 +34,9 @@ else test_tmp := $(CURDIR)/t/tmp endif -initial_setup := $(shell ./configure-version --update) +initial_setup := $(shell ./configure-version --update $(isok)) +initial_setup := $(call shout,$(initial_setup),Version configuration failed)) + bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds all: $(bup_deps) Documentation/all $(current_sampledata) @@ -33,6 +49,7 @@ Documentation/all: $(bup_deps) $(current_sampledata): t/configure-sampledata --setup +# This needs to be a delayed assignment PYTHON = $(shell cmd/bup-python -c 'import sys; print sys.executable') define install-python-bin -- 2.39.2