mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
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)
This commit is contained in:
parent
2d4a37ebab
commit
5031e32986
28
Makefile
28
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
|
||||
|
Loading…
Reference in New Issue
Block a user