From fe4d353333bb9dea2c0e35549976a25626dd840c Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sat, 26 May 2018 18:39:48 +0200
Subject: [PATCH 5/5] Makefile.inc1: Do not continue the build upon an error in
 various cases.

Before this commit, the build would limp on even though a library
failed building, for example, leading to sometimes confusing followup
errors later in the build. It was also more difficult to see directly
why a build really failed in the first place.

To prevent this, make various targets use '&&' instead of ';' to
chain commands.

People wanting the build to carry on for as long as possible, can
always use make's -k option.
---
 Makefile.inc1          | 40 ++++++++++++++++++++--------------------
 lib/libefivar/Makefile |  2 ++
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 9f61dfddae..543617c4d8 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -522,7 +522,7 @@ installworld-force:
 	rm -rf /usr/obj/temp > /dev/null 2>& 1 || chflags -R noschg /usr/obj/temp
 	rm -rf /usr/obj/temp
 	mkdir -p /usr/obj/temp/cpdup/bin
-	(cd ${.CURDIR}/bin/cpdup; make clean; make obj; make clean; make CFLAGS=-static all install DESTDIR=/usr/obj/temp/cpdup NOMAN=TRUE)
+	(cd ${.CURDIR}/bin/cpdup; make clean && make obj && make clean && make CFLAGS=-static all install DESTDIR=/usr/obj/temp/cpdup NOMAN=TRUE)
 	@echo "XXXXXXXXX Installing to temporary XXXXXXXXX"
 	@sleep 1
 	(cd ${.CURDIR}; ${MAKE} installworld DESTDIR=/usr/obj/temp > /dev/null 2>&1)
@@ -904,9 +904,9 @@ bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}
 bstrap-${_tool}!
 	${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
 		cd ${.CURDIR}/${_tool}; \
-		make DIRPRFX=${_tool}/ obj; \
-		make DIRPRFX=${_tool}/ depend; \
-		make DIRPRFX=${_tool}/ all; \
+		make DIRPRFX=${_tool}/ obj && \
+		make DIRPRFX=${_tool}/ depend && \
+		make DIRPRFX=${_tool}/ all && \
 		make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
 .endfor
 
@@ -966,9 +966,9 @@ build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
 btools-${_tool}!
 	${ECHODIR} "===> ${_tool} (build-tools)"; \
 		cd ${.CURDIR}/${_tool}; \
-		make DIRPRFX=${_tool}/ obj; \
-		make DIRPRFX=${_tool}/ depend; \
-		make DIRPRFX=${_tool}/ all; \
+		make DIRPRFX=${_tool}/ obj && \
+		make DIRPRFX=${_tool}/ depend && \
+		make DIRPRFX=${_tool}/ all && \
 		make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
 .endfor
 .endif
@@ -993,9 +993,9 @@ cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
 ctools-${_tool}!
 	${ECHODIR} "===> ${_tool} (cross-tools)"; \
 		cd ${.CURDIR}/${_tool}; \
-		make DIRPRFX=${_tool}/ obj; \
-		make DIRPRFX=${_tool}/ depend; \
-		make DIRPRFX=${_tool}/ all; \
+		make DIRPRFX=${_tool}/ obj && \
+		make DIRPRFX=${_tool}/ depend && \
+		make DIRPRFX=${_tool}/ all && \
 		make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
 .endfor
 
@@ -1032,10 +1032,10 @@ libraries:
 . endif
 .endif
 	cd ${.CURDIR}; \
-	    make -f Makefile.inc1 _startup_libs -DSYSBUILD; \
-	    make -f Makefile.inc1 _prebuild_libs -DSYSBUILD; \
-	    make -f Makefile.inc1 _generic_libs -DSYSBUILD;
-	touch ${WORLDDEST}/.libraries_done
+	    make -f Makefile.inc1 _startup_libs -DSYSBUILD && \
+	    make -f Makefile.inc1 _prebuild_libs -DSYSBUILD && \
+	    make -f Makefile.inc1 _generic_libs -DSYSBUILD && \
+	    touch ${WORLDDEST}/.libraries_done
 
 # These dependencies are not automatically generated:
 #
@@ -1113,12 +1113,12 @@ ${_lib}__L: .PHONY
 .if exists(${.CURDIR}/${_lib})
 	@${ECHODIR} "===> ${_lib}"; \
 		cd ${.CURDIR}/${_lib}; \
-		echo "STEP DEP ${_lib}"; \
-		make DIRPRFX=${_lib}/ depend; \
-		echo "STEP ALL ${_lib}"; \
-		make DIRPRFX=${_lib}/ all; \
-		echo "STEP INSTALL ${_lib}"; \
-		make DIRPRFX=${_lib}/ install; \
+		echo "STEP DEP ${_lib}" && \
+		make DIRPRFX=${_lib}/ depend && \
+		echo "STEP ALL ${_lib}" && \
+		make DIRPRFX=${_lib}/ all && \
+		echo "STEP INSTALL ${_lib}" && \
+		make DIRPRFX=${_lib}/ install && \
 		echo "STEP DONE ${_lib}";
 .else
 .warning missing ${.CURDIR}/${_lib} directory.
diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile
index 1bafc0be26..86805717f1 100644
--- a/lib/libefivar/Makefile
+++ b/lib/libefivar/Makefile
@@ -35,6 +35,8 @@ CFLAGS+=	-I${.CURDIR}/../../sys/contrib/edk2/Include
 CFLAGS+=	-I${.CURDIR}/../../sys/contrib/edk2/Include/X64
 .endif
 
+CFLAGS+=	-save-temps
+
 MLINKS+=efivar.3 efi_variables_supported.3 \
 	efivar.3 efi_del_variable.3 \
 	efivar.3 efi_get_variable.3 \
-- 
2.17.0

