forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstallers.mk
34 lines (31 loc) · 1.62 KB
/
uninstallers.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# include after all other files:
# defines uninstallers and version-checks
# based on the contents of the UNINSTALL_* variables and the manifest files
install: version-check
version-check: $(addprefix version-check-, $(DEP_LIBS_STAGED))
uninstall: $(addprefix uninstall-, $(DEP_LIBS_STAGED))
## read 'uninstall-*' definition from either the manifest or the current session
define define-uninstaller
MANIFEST_$1 := $$(shell [ -e $$(build_prefix)/manifest/$1 ] && cat $$(build_prefix)/manifest/$1)
ifeq (undefined,$$(flavor $$(word 2,$$(MANIFEST_$1))))
MANIFEST_$1 := $$(UNINSTALL_$1)
endif
UNINST_HOW_$1 := $$(word 2,$$(MANIFEST_$1))
ifneq ($$(UNINST_HOW_$1),)
UNINST_WHO_$1 := $$(firstword $$(MANIFEST_$1))
UNINST_WHERE_$1 := $$(wordlist 3,99,$$(MANIFEST_$1))
$$(eval $$(call $$(UNINST_HOW_$1),$1,$$(UNINST_WHO_$1),$$(UNINST_WHERE_$1)))
endif
endef
$(foreach dep,$(DEP_LIBS_STAGED),$(eval $(call define-uninstaller,$(dep))))
# for each subproject with a manifest, keep the user aware if something is not the expected version
$(addprefix version-check-,$(DEP_LIBS_STAGED)) : version-check-% : install-%
@if [ ! -e $(build_prefix)/manifest/$* ] || ( \
[ "1" != "`wc -w $(build_prefix)/manifest/$* | cut -f 1 -d ' '`" ] && \
[ "$(UNINSTALL_$*)" != "`cat $(build_prefix)/manifest/$*`" ]) ; then \
echo "WARNING: using mismatched version for $$(cat $(build_prefix)/manifest/$*):" ; \
echo " want $(UNINSTALL_$*)" ; \
echo " To resolve this warning, you could try either of the following suggestions: " ; \
echo " 1. Run the following command: make -C deps uninstall" ; \
echo " 2. Remove the following directory: $(JULIAHOME)/usr" ; \
fi