Files
neovim/Makefile
T

183 lines
5.2 KiB
Makefile
Raw Normal View History

2018-03-11 13:15:42 +01:00
THIS_DIR = $(shell pwd)
2014-06-14 19:39:20 +04:00
filter-false = $(strip $(filter-out 0 off OFF false FALSE,$1))
filter-true = $(strip $(filter-out 1 on ON true TRUE,$1))
2015-03-07 19:49:16 -05:00
# See contrib/local.mk.example
2014-02-25 11:55:36 -03:00
-include local.mk
CMAKE_PRG ?= $(shell (command -v cmake3 || echo cmake))
CMAKE_BUILD_TYPE ?= Debug
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
2019-02-16 00:23:51 +01:00
# Extra CMake flags which extend the default set
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
2019-02-16 00:23:51 +01:00
CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
ifneq (,$(CMAKE_INSTALL_PREFIX))
CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
endif
2014-03-03 10:09:06 -05:00
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
echo "Unix Makefiles")
2018-03-11 13:15:42 +01:00
DEPS_BUILD_DIR ?= .deps
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
$(error DEPS_BUILD_DIR must not contain whitespace)
endif
2014-03-03 10:09:06 -05:00
ifeq (,$(BUILD_TOOL))
ifeq (Ninja,$(BUILD_TYPE))
ifneq ($(shell $(CMAKE_PRG) --help 2>/dev/null | grep Ninja),)
BUILD_TOOL := ninja
else
# User's version of CMake doesn't support Ninja
2014-03-03 10:09:06 -05:00
BUILD_TOOL = $(MAKE)
BUILD_TYPE := Unix Makefiles
endif
else
BUILD_TOOL = $(MAKE)
2014-03-03 10:09:06 -05:00
endif
endif
BUILD_CMD = $(BUILD_TOOL)
ifneq ($(VERBOSE),)
# Only need to handle Ninja here. Make will inherit the VERBOSE variable.
ifeq ($(BUILD_TYPE),Ninja)
BUILD_CMD += -v
endif
endif
2014-03-03 10:09:06 -05:00
DEPS_CMAKE_FLAGS ?=
# Back-compat: USE_BUNDLED_DEPS was the old name.
USE_BUNDLED ?= $(USE_BUNDLED_DEPS)
2014-06-14 19:39:20 +04:00
ifneq (,$(USE_BUNDLED))
BUNDLED_CMAKE_FLAG := -DUSE_BUNDLED=$(USE_BUNDLED)
2014-06-14 19:39:20 +04:00
endif
2016-03-07 00:42:49 -03:00
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON
2018-03-11 13:15:42 +01:00
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || rm build/.ran-*)
2016-03-07 00:42:49 -03:00
endif
# For use where we want to make sure only a single job is run. This does issue
# a warning, but we need to keep SCRIPTS argument.
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
2014-03-03 10:09:06 -05:00
all: nvim
nvim: checkprefix build/.ran-cmake deps
+$(BUILD_CMD) -C build
2014-02-01 11:27:24 -03:00
2014-11-30 21:22:46 -05:00
libnvim: build/.ran-cmake deps
+$(BUILD_CMD) -C build libnvim
cmake:
touch CMakeLists.txt
$(MAKE) build/.ran-cmake
2014-02-27 16:57:06 -03:00
2014-03-03 10:09:06 -05:00
build/.ran-cmake: | deps
2018-03-11 13:15:42 +01:00
cd build && $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(THIS_DIR)
2014-03-03 10:09:06 -05:00
touch $@
2014-02-01 11:20:02 -03:00
2014-06-14 19:39:20 +04:00
deps: | build/.ran-third-party-cmake
ifeq ($(call filter-true,$(USE_BUNDLED)),)
2018-03-11 13:15:42 +01:00
+$(BUILD_CMD) -C $(DEPS_BUILD_DIR)
2014-06-14 19:39:20 +04:00
endif
2014-02-01 11:20:02 -03:00
build/.ran-third-party-cmake::
mkdir -p build
touch $@
ifeq ($(call filter-true,$(USE_BUNDLED)),)
build/.ran-third-party-cmake:: $(DEPS_BUILD_DIR)
$(DEPS_BUILD_DIR):
2018-03-11 13:15:42 +01:00
mkdir -p $(DEPS_BUILD_DIR)
cd $(DEPS_BUILD_DIR) && \
$(CMAKE_PRG) -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \
2018-03-11 13:15:42 +01:00
$(DEPS_CMAKE_FLAGS) $(THIS_DIR)/third-party
2014-06-14 19:39:20 +04:00
endif
2014-02-27 16:57:06 -03:00
# TODO: cmake 3.2+ add_custom_target() has a USES_TERMINAL flag.
oldtest: | nvim helptags
+$(SINGLE_MAKE) -C src/nvim/testdir clean
ifeq ($(strip $(TEST_FILE)),)
+$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" $(MAKEOVERRIDES)
else
+$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" NEW_TESTS=$(TEST_FILE) SCRIPTS= $(MAKEOVERRIDES)
endif
helptags: | nvim
2019-01-04 02:17:18 +01:00
+$(BUILD_CMD) -C build runtime/doc/tags
2018-11-05 01:54:24 +01:00
# Builds help HTML _and_ checks for invalid help tags.
helphtml: | nvim helptags
+$(BUILD_CMD) -C build doc_html
functionaltest: | nvim
+$(BUILD_CMD) -C build functionaltest
2016-03-07 00:42:49 -03:00
functionaltest-lua: | nvim
+$(BUILD_CMD) -C build functionaltest-lua
testlint: | build/.ran-cmake deps
2015-11-17 13:16:33 +01:00
$(BUILD_CMD) -C build testlint
2017-05-25 16:50:06 +03:00
lualint: | build/.ran-cmake deps
$(BUILD_CMD) -C build lualint
2014-03-03 10:09:06 -05:00
unittest: | nvim
+$(BUILD_CMD) -C build unittest
2015-03-28 22:28:37 +01:00
benchmark: | nvim
+$(BUILD_CMD) -C build benchmark
2015-11-27 18:08:08 -05:00
test: functionaltest unittest
2014-02-01 11:20:02 -03:00
clean:
+test -d build && $(BUILD_CMD) -C build clean || true
$(MAKE) -C src/nvim/testdir clean
2016-12-02 20:33:57 -05:00
$(MAKE) -C runtime/doc clean
2014-02-01 11:20:02 -03:00
2014-03-03 10:09:06 -05:00
distclean: clean
2018-03-11 13:15:42 +01:00
rm -rf $(DEPS_BUILD_DIR) build
2014-02-25 00:04:51 +00:00
2014-03-03 10:09:06 -05:00
install: | nvim
+$(BUILD_CMD) -C build install
2014-02-01 11:27:24 -03:00
clint: build/.ran-cmake
+$(BUILD_CMD) -C build clint
clint-full: build/.ran-cmake
+$(BUILD_CMD) -C build clint-full
check-single-includes: build/.ran-cmake
+$(BUILD_CMD) -C build check-single-includes
2018-09-06 11:11:59 +02:00
generated-sources: build/.ran-cmake
+$(BUILD_CMD) -C build generated-sources
2017-05-01 20:35:04 -04:00
appimage:
bash scripts/genappimage.sh
2019-02-16 00:23:51 +01:00
# Build an appimage with embedded update information.
# appimage-nightly: for nightly builds
# appimage-latest: for a release
appimage-%:
bash scripts/genappimage.sh $*
2017-05-25 16:50:06 +03:00
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); \
2019-02-17 21:41:42 +01:00
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