From 97fc7ae27dcc31d66925c789d13f917f20b43e2b Mon Sep 17 00:00:00 2001
From: Michael Eischer <eischer@cs.fau.de>
Date: Thu, 3 Oct 2019 14:16:30 +0200
Subject: [PATCH] Delete output pdf on build failures

This is intended as a replacement for the call of the clean target in the
i4neo-demo Makefile. The call of clean is problematic as this triggers
both the clean target in i4neo-demo and the cache in the i4neo theme.
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index 725623a..18781b8 100644
--- a/Makefile
+++ b/Makefile
@@ -42,12 +42,16 @@ $(PACKAGE_TGT): $(wildcard $(PACKAGE_DIR)/*.ins) $(PACKAGE_SRC) | $(CACHE_DIR)
 $(CACHE_DIR):; @mkdir -p $(CACHE_DIR)
 
 %_handout.pdf: %.tex $(wildcard *.bib) $(PACKAGE_TGT) | $(CACHE_DIR)
+	@# touch pdf to ensure it is deleted on build failures
+	@test -f $@ && touch $@ || true
 	@cd $(dir $< ) && $(COMPILE_TEX) -jobname=$*_handout $(notdir $<)
 	@cp $(CACHE_DIR)/$(notdir $@) $@
 	@cp $(CACHE_DIR)/$(notdir $*_handout.synctex.gz) $*_handout.synctex.gz
 	@test ! -f $@pc -a -f $(CACHE_DIR)/$(notdir $@)pc && ( /bin/echo "[file]"; /bin/echo "$@"; /bin/echo "[font_size]"; /bin/echo "$(PDFPC_SIZE)"; cat $(CACHE_DIR)/$(notdir $@)pc | sed 's/\\\\/\n/g' | sed 's/\\par/\n\n/g' ) > $@pc || echo "ignoring PDFPC file" && exit 0
 
 %.pdf: %.tex $(wildcard *.bib) $(PACKAGE_TGT) | $(CACHE_DIR)
+	@# touch pdf to ensure it is deleted on build failures
+	@test -f $@ && touch $@ || true
 	@cd $(dir $< ) && $(COMPILE_TEX) $(notdir $<)
 	@cp $(CACHE_DIR)/$(notdir $@) $@
 	@cp $(CACHE_DIR)/$(notdir $*.synctex.gz) $*.synctex.gz
@@ -66,3 +70,4 @@ evince-%: %.pdf
 	@evince $<
 
 FORCE:
+.DELETE_ON_ERROR:
-- 
GitLab