aboutsummaryrefslogtreecommitdiff
path: root/Makefile.submodule
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile.submodule')
-rw-r--r--Makefile.submodule35
1 files changed, 35 insertions, 0 deletions
diff --git a/Makefile.submodule b/Makefile.submodule
new file mode 100644
index 000000000..78f301210
--- /dev/null
+++ b/Makefile.submodule
@@ -0,0 +1,35 @@
+ifneq (,$(wildcard .git)) # if we're in a git repo
+
+# if the submodule changed, update it
+SUBMODULE_DIFF=$(shell git diff etc/coq-scripts 2>&1 | grep 'Subproject commit')
+SUBMODULE_DIRTY=$(shell git diff etc/coq-scripts 2>&1 | grep dirty)
+ifneq (,$(SUBMODULE_DIRTY))
+submodule-update::
+ @ echo "\033[0;31mThe submodule is dirty; some scripts may fail.\033[0m"
+ @ echo "\033[0;31mRun (cd etc/coq-scripts && git clean -xfd && git reset --hard)\033[0m"
+else
+ifneq (,$(SUBMODULE_DIFF))
+submodule-update::
+ git submodule sync && \
+ git submodule update --init && \
+ touch "$@"
+endif
+endif
+
+ifeq (,$(wildcard submodule-update))
+submodule-update::
+ git submodule sync && \
+ git submodule update --init && \
+ touch "$@"
+else
+submodule-update::
+endif
+
+etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early: submodule-update
+ @ touch "$@"
+endif
+
+FAST_TARGETS += clean-doc etc/coq-scripts etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early submodule-update
+SUPER_FAST_TARGETS += submodule-update
+
+Makefile.coq: etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early