2018-03-11 05:15:42 -07:00
|
|
|
THIS_DIR = $(shell pwd)
|
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
|
|
|
|
|
2019-06-29 15:13:53 -07:00
|
|
|
all: nvim
|
|
|
|
|
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
|
2019-03-18 18:49:33 -07:00
|
|
|
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
2019-02-15 16:23:51 -07: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.
|
2019-02-16 21:28:32 -07:00
|
|
|
# - `checkprefix` target checks that it matches the CMake-cached value. #9615
|
2019-06-29 12:48:40 -07:00
|
|
|
ifneq (,$(CMAKE_EXTRA_FLAGS))
|
2019-02-15 16:23:51 -07:00
|
|
|
CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
|
|
|
|
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
|
2019-06-29 12:48:40 -07:00
|
|
|
endif
|
2019-03-18 18:49:33 -07:00
|
|
|
ifneq (,$(CMAKE_INSTALL_PREFIX))
|
2019-06-29 12:48:40 -07:00
|
|
|
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: ;
|
2019-03-18 18:49:33 -07:00
|
|
|
endif
|
2014-03-03 08:09:06 -07:00
|
|
|
|
|
|
|
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
|
|
|
|
echo "Unix Makefiles")
|
2018-03-11 05:15:42 -07:00
|
|
|
DEPS_BUILD_DIR ?= .deps
|
|
|
|
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
|
|
|
|
$(error DEPS_BUILD_DIR must not contain whitespace)
|
|
|
|
endif
|
2014-03-03 08:09:06 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-06-23 06:25:30 -07:00
|
|
|
BUILD_CMD = $(BUILD_TOOL)
|
|
|
|
|
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)
|
2019-06-23 06:25:30 -07:00
|
|
|
BUILD_CMD += -v
|
2014-06-14 23:34:28 -07:00
|
|
|
endif
|
2014-04-23 01:59:25 -07:00
|
|
|
endif
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
DEPS_CMAKE_FLAGS ?=
|
2018-09-24 14:18:48 -07:00
|
|
|
# Back-compat: USE_BUNDLED_DEPS was the old name.
|
|
|
|
USE_BUNDLED ?= $(USE_BUNDLED_DEPS)
|
2014-06-14 08:39:20 -07:00
|
|
|
|
2018-09-24 14:18:48 -07:00
|
|
|
ifneq (,$(USE_BUNDLED))
|
|
|
|
BUNDLED_CMAKE_FLAG := -DUSE_BUNDLED=$(USE_BUNDLED)
|
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
|
2018-03-11 05:15:42 -07:00
|
|
|
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || rm build/.ran-*)
|
2016-03-06 20:42:49 -07:00
|
|
|
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)
|
|
|
|
|
2019-06-29 12:48:40 -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
|
2018-03-11 05:15:42 -07:00
|
|
|
cd build && $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(THIS_DIR)
|
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
|
2018-09-24 14:18:48 -07:00
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED)),)
|
2018-03-11 05:15:42 -07:00
|
|
|
+$(BUILD_CMD) -C $(DEPS_BUILD_DIR)
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2014-02-01 07:20:02 -07:00
|
|
|
|
2019-06-23 19:13:57 -07:00
|
|
|
build/.ran-third-party-cmake::
|
|
|
|
mkdir -p build
|
|
|
|
touch $@
|
|
|
|
|
2018-09-24 14:18:48 -07:00
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED)),)
|
2019-06-23 19:13:57 -07:00
|
|
|
$(DEPS_BUILD_DIR):
|
2019-06-26 13:44:48 -07:00
|
|
|
mkdir -p "$@"
|
|
|
|
build/.ran-third-party-cmake:: $(DEPS_BUILD_DIR)
|
2018-03-11 05:15:42 -07:00
|
|
|
cd $(DEPS_BUILD_DIR) && \
|
2017-02-23 04:45:45 -07:00
|
|
|
$(CMAKE_PRG) -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \
|
2018-03-11 05:15:42 -07:00
|
|
|
$(DEPS_CMAKE_FLAGS) $(THIS_DIR)/third-party
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
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
|
2019-01-03 18:17:18 -07:00
|
|
|
+$(BUILD_CMD) -C build runtime/doc/tags
|
2016-05-16 20:09:23 -07:00
|
|
|
|
2018-11-04 17:54:24 -07:00
|
|
|
# Builds help HTML _and_ checks for invalid help tags.
|
|
|
|
helphtml: | nvim helptags
|
|
|
|
+$(BUILD_CMD) -C build doc_html
|
|
|
|
|
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
|
|
|
|
|
2017-05-25 06:50:06 -07:00
|
|
|
lualint: | build/.ran-cmake deps
|
|
|
|
$(BUILD_CMD) -C build lualint
|
|
|
|
|
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
|
|
|
|
2019-06-25 10:51:28 -07:00
|
|
|
distclean:
|
2018-03-11 05:15:42 -07:00
|
|
|
rm -rf $(DEPS_BUILD_DIR) build
|
2019-06-25 10:51:28 -07:00
|
|
|
$(MAKE) clean
|
2014-02-24 17:04:51 -07:00
|
|
|
|
2019-06-29 12:48:40 -07:00
|
|
|
install: checkprefix nvim
|
2014-04-23 01:59:25 -07:00
|
|
|
+$(BUILD_CMD) -C build install
|
2014-02-01 07:27:24 -07:00
|
|
|
|
2017-03-31 02:02:59 -07:00
|
|
|
clint: build/.ran-cmake
|
|
|
|
+$(BUILD_CMD) -C build clint
|
|
|
|
|
|
|
|
clint-full: build/.ran-cmake
|
|
|
|
+$(BUILD_CMD) -C build clint-full
|
2014-12-12 18:20:34 -07:00
|
|
|
|
2017-02-11 10:10:53 -07:00
|
|
|
check-single-includes: build/.ran-cmake
|
|
|
|
+$(BUILD_CMD) -C build check-single-includes
|
|
|
|
|
2018-09-06 02:11:59 -07:00
|
|
|
generated-sources: build/.ran-cmake
|
|
|
|
+$(BUILD_CMD) -C build generated-sources
|
|
|
|
|
2017-05-01 17:35:04 -07:00
|
|
|
appimage:
|
|
|
|
bash scripts/genappimage.sh
|
|
|
|
|
2019-02-15 16:23:51 -07:00
|
|
|
# Build an appimage with embedded update information.
|
|
|
|
# appimage-nightly: for nightly builds
|
|
|
|
# appimage-latest: for a release
|
2018-03-09 08:51:27 -07:00
|
|
|
appimage-%:
|
|
|
|
bash scripts/genappimage.sh $*
|
|
|
|
|
2017-05-25 06:50:06 -07:00
|
|
|
lint: check-single-includes clint testlint lualint
|
2017-03-29 08:45:48 -07:00
|
|
|
|
2019-02-16 21:28:32 -07:00
|
|
|
.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|