2014-06-14 08:39:20 -07: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 17:49:16 -07:00
|
|
|
# See contrib/local.mk.example
|
2014-02-25 07:55:36 -07:00
|
|
|
-include local.mk
|
|
|
|
|
2017-02-23 04:45:45 -07:00
|
|
|
CMAKE_PRG ?= $(shell (command -v cmake3 || echo cmake))
|
2014-05-31 05:13:49 -07:00
|
|
|
CMAKE_BUILD_TYPE ?= Debug
|
|
|
|
|
|
|
|
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
2015-08-16 22:54:12 -07:00
|
|
|
DOC_DOWNLOAD_URL_BASE := https://raw.githubusercontent.com/neovim/doc/gh-pages
|
|
|
|
CLINT_ERRORS_FILE_PATH := /reports/clint/errors.json
|
2014-03-03 08:09:06 -07:00
|
|
|
|
|
|
|
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
|
|
|
|
echo "Unix Makefiles")
|
|
|
|
|
|
|
|
ifeq (,$(BUILD_TOOL))
|
|
|
|
ifeq (Ninja,$(BUILD_TYPE))
|
2017-02-23 04:45:45 -07:00
|
|
|
ifneq ($(shell $(CMAKE_PRG) --help 2>/dev/null | grep Ninja),)
|
2014-06-14 23:34:28 -07:00
|
|
|
BUILD_TOOL := ninja
|
|
|
|
else
|
|
|
|
# User's version of CMake doesn't support Ninja
|
2014-03-03 08:09:06 -07:00
|
|
|
BUILD_TOOL = $(MAKE)
|
2014-06-14 23:34:28 -07:00
|
|
|
BUILD_TYPE := Unix Makefiles
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
BUILD_TOOL = $(MAKE)
|
2014-03-03 08:09:06 -07:00
|
|
|
endif
|
|
|
|
endif
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2014-04-23 01:59:25 -07:00
|
|
|
ifneq ($(VERBOSE),)
|
2014-06-14 23:34:28 -07:00
|
|
|
# Only need to handle Ninja here. Make will inherit the VERBOSE variable.
|
|
|
|
ifeq ($(BUILD_TYPE),Ninja)
|
|
|
|
VERBOSE_FLAG := -v
|
|
|
|
endif
|
2014-04-23 01:59:25 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
BUILD_CMD = $(BUILD_TOOL) $(VERBOSE_FLAG)
|
|
|
|
|
2014-02-24 17:22:48 -07:00
|
|
|
# Extra CMake flags which extend the default set
|
2014-03-03 08:09:06 -07:00
|
|
|
CMAKE_EXTRA_FLAGS ?=
|
|
|
|
DEPS_CMAKE_FLAGS ?=
|
2014-06-14 08:39:20 -07:00
|
|
|
USE_BUNDLED_DEPS ?=
|
|
|
|
|
|
|
|
ifneq (,$(USE_BUNDLED_DEPS))
|
2014-06-14 23:34:28 -07:00
|
|
|
BUNDLED_CMAKE_FLAG := -DUSE_BUNDLED=$(USE_BUNDLED_DEPS)
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2014-02-24 17:22:48 -07:00
|
|
|
|
2016-03-06 20:42:49 -07:00
|
|
|
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
|
|
|
|
BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON
|
|
|
|
$(shell [ -x .deps/usr/bin/lua ] || rm build/.ran-*)
|
|
|
|
endif
|
|
|
|
|
2014-06-14 08:42:50 -07:00
|
|
|
# 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.
|
2014-02-28 19:32:25 -07:00
|
|
|
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
all: nvim
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
nvim: build/.ran-cmake deps
|
2014-04-23 01:59:25 -07:00
|
|
|
+$(BUILD_CMD) -C build
|
2014-02-01 07:27:24 -07:00
|
|
|
|
2014-11-30 19:22:46 -07:00
|
|
|
libnvim: build/.ran-cmake deps
|
|
|
|
+$(BUILD_CMD) -C build libnvim
|
|
|
|
|
2014-03-31 01:41:26 -07:00
|
|
|
cmake:
|
|
|
|
touch CMakeLists.txt
|
|
|
|
$(MAKE) build/.ran-cmake
|
2014-02-27 12:57:06 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
build/.ran-cmake: | deps
|
2017-02-23 04:45:45 -07:00
|
|
|
cd build && $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) ..
|
2014-03-03 08:09:06 -07:00
|
|
|
touch $@
|
2014-02-01 07:20:02 -07:00
|
|
|
|
2014-06-14 08:39:20 -07:00
|
|
|
deps: | build/.ran-third-party-cmake
|
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED_DEPS)),)
|
2014-12-01 08:59:55 -07:00
|
|
|
+$(BUILD_CMD) -C .deps
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2014-02-01 07:20:02 -07:00
|
|
|
|
2014-06-14 08:39:20 -07:00
|
|
|
build/.ran-third-party-cmake:
|
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED_DEPS)),)
|
2014-12-01 08:59:55 -07:00
|
|
|
mkdir -p .deps
|
|
|
|
cd .deps && \
|
2017-02-23 04:45:45 -07:00
|
|
|
$(CMAKE_PRG) -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \
|
2014-12-01 08:59:55 -07:00
|
|
|
$(DEPS_CMAKE_FLAGS) ../third-party
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
|
|
|
mkdir -p build
|
2014-03-03 08:09:06 -07:00
|
|
|
touch $@
|
2014-02-27 12:57:06 -07:00
|
|
|
|
2017-02-11 17:02:54 -07:00
|
|
|
# TODO: cmake 3.2+ add_custom_target() has a USES_TERMINAL flag.
|
2016-06-05 00:36:51 -07:00
|
|
|
oldtest: | nvim helptags
|
2017-02-11 17:02:54 -07:00
|
|
|
+$(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
|
2014-09-29 05:43:52 -07:00
|
|
|
|
2016-06-05 00:36:51 -07:00
|
|
|
helptags: | nvim
|
2016-07-17 04:26:00 -07:00
|
|
|
+$(BUILD_CMD) -C build helptags
|
2016-05-16 20:09:23 -07:00
|
|
|
|
2014-11-05 03:54:20 -07:00
|
|
|
functionaltest: | nvim
|
|
|
|
+$(BUILD_CMD) -C build functionaltest
|
|
|
|
|
2016-03-06 20:42:49 -07:00
|
|
|
functionaltest-lua: | nvim
|
|
|
|
+$(BUILD_CMD) -C build functionaltest-lua
|
|
|
|
|
2016-05-10 11:44:57 -07:00
|
|
|
testlint: | build/.ran-cmake deps
|
2015-11-17 05:16:33 -07:00
|
|
|
$(BUILD_CMD) -C build testlint
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
unittest: | nvim
|
2014-04-23 01:59:25 -07:00
|
|
|
+$(BUILD_CMD) -C build unittest
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2015-03-28 14:28:37 -07:00
|
|
|
benchmark: | nvim
|
|
|
|
+$(BUILD_CMD) -C build benchmark
|
|
|
|
|
2015-11-27 16:08:08 -07:00
|
|
|
test: functionaltest unittest
|
|
|
|
|
2014-02-01 07:20:02 -07:00
|
|
|
clean:
|
2014-04-23 01:59:25 -07:00
|
|
|
+test -d build && $(BUILD_CMD) -C build clean || true
|
2014-05-12 06:50:37 -07:00
|
|
|
$(MAKE) -C src/nvim/testdir clean
|
2016-12-02 18:33:57 -07:00
|
|
|
$(MAKE) -C runtime/doc clean
|
2014-02-01 07:20:02 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
distclean: clean
|
|
|
|
rm -rf .deps build
|
2014-02-24 17:04:51 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
install: | nvim
|
2014-04-23 01:59:25 -07:00
|
|
|
+$(BUILD_CMD) -C build install
|
2014-02-01 07:27:24 -07:00
|
|
|
|
2016-05-10 11:44:57 -07:00
|
|
|
clint:
|
2017-02-23 04:45:45 -07:00
|
|
|
$(CMAKE_PRG) -DLINT_PRG=./src/clint.py \
|
2014-12-12 18:20:34 -07:00
|
|
|
-DLINT_DIR=src \
|
2015-08-16 22:54:12 -07:00
|
|
|
-DLINT_SUPPRESS_URL="$(DOC_DOWNLOAD_URL_BASE)$(CLINT_ERRORS_FILE_PATH)" \
|
2014-12-12 18:20:34 -07:00
|
|
|
-P cmake/RunLint.cmake
|
|
|
|
|
2016-05-10 11:44:57 -07:00
|
|
|
lint: clint testlint
|
|
|
|
|
|
|
|
.PHONY: test testlint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install
|