aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-06-29 21:48:40 +0200
committerGitHub <noreply@github.com>2019-06-29 21:48:40 +0200
commit5031e329866e4fe34f926e05a45a20c936b68208 (patch)
treed576638149f7d5d6c1d345fb8dd03f46810d417c
parent2d4a37ebab354afb94dfe600b302d8a2b1f2d889 (diff)
downloadrneovim-5031e329866e4fe34f926e05a45a20c936b68208.tar.gz
rneovim-5031e329866e4fe34f926e05a45a20c936b68208.tar.bz2
rneovim-5031e329866e4fe34f926e05a45a20c936b68208.zip
Makefile: revisit/improve checkprefix handling (#10348)
Main improvement: do not error out, but re-run CMake in case CMAKE_INSTALL_PREFIX changed, and only check it for "install". - only look at CMAKE_EXTRA_FLAGS via shell if not empty - add CMAKE_INSTALL_PREFIX to CMAKE_EXTRA_FLAGS (not CMAKE_FLAGS), to override it being set in CMAKE_EXTRA_FLAGS from local.mk - use an empty "checkprefix" target if CMAKE_INSTALL_PREFIX is not provided - skip checking of cached value without build/.ran-cmake; it will be run then anyway - only use it with "install" target; it is only relevant there - do not error, but re-run CMake (by removing the stamp file)
-rw-r--r--Makefile28
1 files changed, 16 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 6e09d0ea25..7b93c08a63 100644
--- a/Makefile
+++ b/Makefile
@@ -14,10 +14,23 @@ CMAKE_EXTRA_FLAGS ?=
# CMAKE_INSTALL_PREFIX
# - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
# - `checkprefix` target checks that it matches the CMake-cached value. #9615
+ifneq (,$(CMAKE_EXTRA_FLAGS))
CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
+endif
ifneq (,$(CMAKE_INSTALL_PREFIX))
- CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
+ CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
+
+checkprefix:
+ @if [ -f build/.ran-cmake ]; then \
+ cached_prefix=$(shell $(CMAKE_PRG) -L -N build | 2>/dev/null grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2); \
+ if ! [ "$(CMAKE_INSTALL_PREFIX)" = "$$cached_prefix" ]; then \
+ printf "Re-running CMake: CMAKE_INSTALL_PREFIX '$(CMAKE_INSTALL_PREFIX)' does not match cached value '%s'.\n" "$$cached_prefix"; \
+ $(RM) build/.ran-cmake; \
+ fi \
+ fi
+else
+checkprefix: ;
endif
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
@@ -69,7 +82,7 @@ SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
all: nvim
-nvim: checkprefix build/.ran-cmake deps
+nvim: build/.ran-cmake deps
+$(BUILD_CMD) -C build
libnvim: build/.ran-cmake deps
@@ -146,7 +159,7 @@ distclean:
rm -rf $(DEPS_BUILD_DIR) build
$(MAKE) clean
-install: | nvim
+install: checkprefix nvim
+$(BUILD_CMD) -C build install
clint: build/.ran-cmake
@@ -172,13 +185,4 @@ appimage-%:
lint: check-single-includes clint testlint lualint
-checkprefix:
- @cached_prefix=$$("$(CMAKE_PRG)" -L -N build | 2>/dev/null grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2); \
- if [ -n "$(CMAKE_INSTALL_PREFIX)" ] && [ -n "$$cached_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