From 01d4aff9c7674a7daa65355674742b3d49172a25 Mon Sep 17 00:00:00 2001
From: Ralf Jung <jung@mpi-sws.org>
Date: Wed, 20 Sep 2017 12:53:55 +0200
Subject: [PATCH] Update for Coq 8.7 coq_makefile

---
 Makefile           | 10 +---------
 Makefile.coq.local |  5 +++++
 _CoqProject        |  1 +
 awk.Makefile       |  3 ++-
 4 files changed, 9 insertions(+), 10 deletions(-)
 create mode 100644 Makefile.coq.local

diff --git a/Makefile b/Makefile
index 6394c42a..7bfa06f8 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,6 @@ ifeq ($(Y), 1)
 	YFLAG=-y
 endif
 
-# Determine Coq version
-COQ_VERSION=$(shell coqc --version | egrep -o 'version 8.[0-9]' | egrep -o '8.[0-9]')
-COQ_MAKEFILE_FLAGS ?=
-
-ifeq ($(COQ_VERSION), 8.6)
-	COQ_MAKEFILE_FLAGS += -arg -w -arg -notation-overridden,-redundant-canonical-projection,-several-object-files
-endif
-
 # Forward most targets to Coq makefile (with some trick to make this phony)
 %: Makefile.coq phony
 	+@make -f Makefile.coq $@
@@ -25,7 +17,7 @@ clean: Makefile.coq
 
 # Create Coq Makefile. POSIX awk can't do in-place editing, but coq_makefile wants the real filename, so we do some file gymnastics.
 Makefile.coq: _CoqProject Makefile awk.Makefile
-	coq_makefile $(COQ_MAKEFILE_FLAGS) -f _CoqProject -o Makefile.coq
+	coq_makefile -f _CoqProject -o Makefile.coq
 	mv Makefile.coq Makefile.coq.tmp && awk -f awk.Makefile Makefile.coq.tmp > Makefile.coq && rm Makefile.coq.tmp
 
 # Install build-dependencies
diff --git a/Makefile.coq.local b/Makefile.coq.local
new file mode 100644
index 00000000..b261de99
--- /dev/null
+++ b/Makefile.coq.local
@@ -0,0 +1,5 @@
+uninstall::
+	@# This makes sure we also delete stale files in the destination directory
+	$(HIDE)df="$(COQLIBINSTALL)/`$(COQMKFILE) -destination-of "theories/base.v" $(COQLIBS)`" &&\
+	echo "RM in $$df" &&\
+	if [ -d "$$df" ]; then find "$$df" \( -name "*.vo" -o -name "*.v" -o -name "*.glob" -o \( -type d -empty \) \) -print -delete; fi
diff --git a/_CoqProject b/_CoqProject
index e411deab..9c07436c 100644
--- a/_CoqProject
+++ b/_CoqProject
@@ -1,4 +1,5 @@
 -Q theories stdpp
+-arg -w -arg -notation-overridden,-redundant-canonical-projection,-several-object-files
 theories/option.v
 theories/fin_map_dom.v
 theories/bset.v
diff --git a/awk.Makefile b/awk.Makefile
index 09ded0aa..74f7d570 100644
--- a/awk.Makefile
+++ b/awk.Makefile
@@ -11,7 +11,8 @@
 
 # Patch the uninstall target to work properly, and to also uninstall stale files.
 # Also see <https://coq.inria.fr/bugs/show_bug.cgi?id=4907>.
-/^uninstall:/ {
+# This (and the section above) can be removed once we no longer support Coq 8.6.
+/^uninstall: / {
 	print "uninstall:";
 	print "\tif [ -d \"$(DSTROOT)\"$(COQLIBINSTALL)/"PROJECT"/ ]; then find \"$(DSTROOT)\"$(COQLIBINSTALL)/"PROJECT"/ \\( -name \"*.vo\" -o -name \"*.v\" -o -name \"*.glob\" -o \\( -type d -empty \\) \\) -print -delete; fi";
 	getline;
-- 
GitLab