aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-02-17 05:28:32 +0100
committerGitHub <noreply@github.com>2019-02-17 05:28:32 +0100
commit3b473bb14f9f452461016c7042949a23499df629 (patch)
tree402f6e0c0b1e1f6cca6f95381392b266c6b93548
parent023e832d409abeed4819807fc219fa532bcbdb03 (diff)
downloadrneovim-3b473bb14f9f452461016c7042949a23499df629.tar.gz
rneovim-3b473bb14f9f452461016c7042949a23499df629.tar.bz2
rneovim-3b473bb14f9f452461016c7042949a23499df629.zip
build/Makefile: validate prefix for specific targets (#9621)
`clean` and `distclean` should not check CMAKE_INSTALL_PREFIX. ref #9615 Helped-by: bruce-hill
-rw-r--r--Makefile27
1 files changed, 12 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 980ea83bdd..ba10a156b0 100644
--- a/Makefile
+++ b/Makefile
@@ -13,21 +13,9 @@ CMAKE_EXTRA_FLAGS ?=
# CMAKE_INSTALL_PREFIX
# - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
-# - Fail if the given value does not match the CMake cached value. #9615
-CACHED_PREFIX := $(shell $(CMAKE_PRG) -L -N build | 2>/dev/null \
- grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2)
+# - `checkprefix` target checks that it matches the CMake-cached value. #9615
CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
-ifneq (,$(CMAKE_INSTALL_PREFIX))
- ifneq (,$(CACHED_PREFIX))
- ifneq ($(CMAKE_INSTALL_PREFIX),$(CACHED_PREFIX))
- $(info error: CMAKE_INSTALL_PREFIX "$(CMAKE_INSTALL_PREFIX)" does not match cached value "$(CACHED_PREFIX)")
- $(info . Run this command, then try again:)
- $(info . cmake build -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX))
- $(error error)
- endif
- endif
-endif
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
echo "Unix Makefiles")
@@ -78,7 +66,7 @@ SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
all: nvim
-nvim: build/.ran-cmake deps
+nvim: checkprefix build/.ran-cmake deps
+$(BUILD_CMD) -C build
libnvim: build/.ran-cmake deps
@@ -177,4 +165,13 @@ appimage-%:
lint: check-single-includes clint testlint lualint
-.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage
+checkprefix:
+ @cached_prefix=$$($(CMAKE_PRG) -L -N build | 2>/dev/null grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2); \
+ if [ -n "$(CMAKE_INSTALL_PREFIX)" ] && ! [ "$(CMAKE_INSTALL_PREFIX)" = "$$cached_prefix" ]; then \
+ printf "\nerror: CMAKE_INSTALL_PREFIX '$(CMAKE_INSTALL_PREFIX)' does not match cached value '%s'\n" "$$cached_prefix"; \
+ printf " Run this command, then try again:\n"; \
+ printf " cmake build -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)\n"; \
+ exit 1; \
+ fi;
+
+.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix