2021-09-19 15:53:48 -07:00
|
|
|
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
|
|
|
|
|
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 ?=
|
2021-09-19 15:53:48 -07:00
|
|
|
NVIM_PRG := $(MAKEFILE_DIR)/build/bin/nvim
|
2019-02-15 16:23:51 -07:00
|
|
|
|
|
|
|
# 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 16:29:10 -07:00
|
|
|
ifneq (,$(CMAKE_INSTALL_PREFIX)$(CMAKE_EXTRA_FLAGS))
|
|
|
|
CMAKE_INSTALL_PREFIX := $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
|
2019-02-15 16:23:51 -07:00
|
|
|
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-07-17 07:38:11 -07:00
|
|
|
override CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
|
2019-06-29 12:48:40 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
2021-09-19 15:53:48 -07:00
|
|
|
CMAKE_GENERATOR ?= $(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || \
|
2014-03-03 08:09:06 -07:00
|
|
|
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))
|
2021-09-19 15:53:48 -07:00
|
|
|
ifeq (Ninja,$(CMAKE_GENERATOR))
|
2022-06-09 08:09:24 -07:00
|
|
|
BUILD_TOOL = ninja
|
2014-06-14 23:34:28 -07:00
|
|
|
else
|
|
|
|
BUILD_TOOL = $(MAKE)
|
2014-03-03 08:09:06 -07:00
|
|
|
endif
|
|
|
|
endif
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2021-09-20 23:19:46 -07:00
|
|
|
# Only need to handle Ninja here. Make will inherit the VERBOSE variable, and the -j, -l, and -n flags.
|
2021-09-19 15:53:48 -07:00
|
|
|
ifeq ($(CMAKE_GENERATOR),Ninja)
|
2020-05-01 07:36:56 -07:00
|
|
|
ifneq ($(VERBOSE),)
|
2021-09-19 15:53:48 -07:00
|
|
|
BUILD_TOOL += -v
|
2014-06-14 23:34:28 -07:00
|
|
|
endif
|
2021-09-20 23:19:46 -07:00
|
|
|
BUILD_TOOL += $(shell printf '%s' '$(MAKEFLAGS)' | grep -o -- ' *-[jl][0-9]\+ *')
|
2020-05-01 07:36:56 -07:00
|
|
|
ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS))))
|
2021-09-19 15:53:48 -07:00
|
|
|
BUILD_TOOL += -n
|
2020-05-01 07:36:56 -07:00
|
|
|
endif
|
2014-04-23 01:59:25 -07:00
|
|
|
endif
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
DEPS_CMAKE_FLAGS ?=
|
2023-01-19 14:12:27 -07:00
|
|
|
USE_BUNDLED ?=
|
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
|
2021-09-19 15:53:48 -07:00
|
|
|
+$(BUILD_TOOL) -C build
|
2014-02-01 07:27:24 -07:00
|
|
|
|
2014-11-30 19:22:46 -07:00
|
|
|
libnvim: build/.ran-cmake deps
|
2021-09-19 15:53:48 -07:00
|
|
|
+$(BUILD_TOOL) -C build libnvim
|
2014-11-30 19:22:46 -07:00
|
|
|
|
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
|
2021-09-19 15:53:48 -07:00
|
|
|
cd build && $(CMAKE_PRG) -G '$(CMAKE_GENERATOR)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
|
2014-03-03 08:09:06 -07:00
|
|
|
touch $@
|
2014-02-01 07:20:02 -07:00
|
|
|
|
2022-06-27 03:08:59 -07:00
|
|
|
deps: | build/.ran-deps-cmake
|
2018-09-24 14:18:48 -07:00
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED)),)
|
2021-09-19 15:53:48 -07:00
|
|
|
+$(BUILD_TOOL) -C $(DEPS_BUILD_DIR)
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2014-02-01 07:20:02 -07:00
|
|
|
|
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 "$@"
|
2022-06-27 03:08:59 -07:00
|
|
|
build/.ran-deps-cmake:: $(DEPS_BUILD_DIR)
|
2018-03-11 05:15:42 -07:00
|
|
|
cd $(DEPS_BUILD_DIR) && \
|
2021-09-19 15:53:48 -07:00
|
|
|
$(CMAKE_PRG) -G '$(CMAKE_GENERATOR)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \
|
2022-06-27 03:08:59 -07:00
|
|
|
$(DEPS_CMAKE_FLAGS) $(MAKEFILE_DIR)/cmake.deps
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2022-06-27 03:08:59 -07:00
|
|
|
build/.ran-deps-cmake::
|
2019-07-02 15:25:49 -07:00
|
|
|
mkdir -p build
|
|
|
|
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.
|
2019-08-28 13:47:54 -07:00
|
|
|
oldtest: | nvim build/runtime/doc/tags
|
2023-03-06 20:13:04 -07:00
|
|
|
+$(SINGLE_MAKE) -C test/old/testdir clean
|
2017-02-11 17:02:54 -07:00
|
|
|
ifeq ($(strip $(TEST_FILE)),)
|
2023-03-06 20:13:04 -07:00
|
|
|
+$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) $(MAKEOVERRIDES)
|
2017-02-11 17:02:54 -07:00
|
|
|
else
|
2019-12-02 09:18:37 -07:00
|
|
|
@# Handle TEST_FILE=test_foo{,.res,.vim}.
|
2023-03-06 20:13:04 -07:00
|
|
|
+$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst %.vim,%,$(patsubst %.res,%,$(TEST_FILE)))
|
2017-02-11 17:02:54 -07:00
|
|
|
endif
|
2019-12-02 09:18:37 -07:00
|
|
|
# Build oldtest by specifying the relative .vim filename.
|
|
|
|
.PHONY: phony_force
|
2023-04-26 23:26:07 -07:00
|
|
|
test/old/testdir/%.vim: phony_force nvim
|
2023-03-06 20:13:04 -07:00
|
|
|
+$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst test/old/testdir/%.vim,%,$@)
|
2014-09-29 05:43:52 -07:00
|
|
|
|
2023-01-19 14:12:27 -07:00
|
|
|
functionaltest-lua: | nvim
|
2023-05-24 12:14:47 -07:00
|
|
|
$(BUILD_TOOL) -C build functionaltest
|
2014-11-05 03:54:20 -07:00
|
|
|
|
2023-01-19 14:12:27 -07:00
|
|
|
FORMAT=formatc formatlua format
|
2023-10-26 13:30:00 -07:00
|
|
|
LINT=lintlua lintsh lintc clang-analyzer lintcommit lint
|
2023-01-19 14:12:27 -07:00
|
|
|
TEST=functionaltest unittest
|
2023-08-17 03:14:58 -07:00
|
|
|
generated-sources benchmark $(FORMAT) $(LINT) $(TEST) doc: | build/.ran-cmake
|
2022-06-09 08:09:24 -07:00
|
|
|
$(CMAKE_PRG) --build build --target $@
|
2016-03-06 20:42:49 -07:00
|
|
|
|
2023-01-19 14:12:27 -07:00
|
|
|
test: $(TEST)
|
2015-11-27 16:08:08 -07:00
|
|
|
|
2023-11-26 07:34:29 -07:00
|
|
|
# The ignored header files should be synced with the `check_includes_ignore`
|
|
|
|
# array in src/clint.py
|
2022-09-11 08:12:44 -07:00
|
|
|
iwyu: build/.ran-cmake
|
2023-03-11 11:21:54 -07:00
|
|
|
cmake --preset iwyu
|
2023-08-26 02:20:40 -07:00
|
|
|
cmake --build build > build/iwyu.log
|
2023-11-26 13:36:02 -07:00
|
|
|
iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
|
2023-11-26 05:24:38 -07:00
|
|
|
|src/nvim/api/private/validate.h\
|
2023-11-28 12:31:00 -07:00
|
|
|
|src/nvim/assert_defs.h\
|
2023-11-26 05:24:38 -07:00
|
|
|
|src/nvim/buffer.h\
|
|
|
|
|src/nvim/buffer_defs.h\
|
|
|
|
|src/nvim/channel.h\
|
2023-12-12 07:40:21 -07:00
|
|
|
|src/nvim/channel_defs.h\
|
2023-11-26 05:24:38 -07:00
|
|
|
|src/nvim/charset.h\
|
|
|
|
|src/nvim/drawline.h\
|
|
|
|
|src/nvim/eval.h\
|
|
|
|
|src/nvim/eval/encode.h\
|
|
|
|
|src/nvim/eval/typval.h\
|
|
|
|
|src/nvim/eval/typval_defs.h\
|
|
|
|
|src/nvim/eval/userfunc.h\
|
|
|
|
|src/nvim/eval/window.h\
|
|
|
|
|src/nvim/event/libuv_process.h\
|
|
|
|
|src/nvim/event/loop.h\
|
|
|
|
|src/nvim/event/process.h\
|
|
|
|
|src/nvim/event/rstream.h\
|
|
|
|
|src/nvim/event/signal.h\
|
|
|
|
|src/nvim/event/socket.h\
|
|
|
|
|src/nvim/event/stream.h\
|
|
|
|
|src/nvim/event/time.h\
|
|
|
|
|src/nvim/event/wstream.h\
|
|
|
|
|src/nvim/garray.h\
|
|
|
|
|src/nvim/globals.h\
|
|
|
|
|src/nvim/grid.h\
|
|
|
|
|src/nvim/highlight.h\
|
|
|
|
|src/nvim/input.h\
|
|
|
|
|src/nvim/keycodes.h\
|
|
|
|
|src/nvim/lua/executor.h\
|
|
|
|
|src/nvim/main.h\
|
|
|
|
|src/nvim/msgpack_rpc/channel_defs.h\
|
|
|
|
|src/nvim/msgpack_rpc/helpers.h\
|
|
|
|
|src/nvim/msgpack_rpc/unpacker.h\
|
|
|
|
|src/nvim/option.h\
|
|
|
|
|src/nvim/os/input.h\
|
|
|
|
|src/nvim/os/pty_conpty_win.h\
|
|
|
|
|src/nvim/os/pty_process_unix.h\
|
|
|
|
|src/nvim/os/pty_process_win.h\
|
|
|
|
|src/nvim/tui/input.h\
|
|
|
|
|src/nvim/ui.h\
|
|
|
|
|src/nvim/viml/parser/expressions.h\
|
|
|
|
|src/nvim/viml/parser/parser.h\
|
2023-11-26 07:34:29 -07:00
|
|
|
)" --nosafe_headers < build/iwyu.log
|
2022-09-11 08:12:44 -07:00
|
|
|
cmake -B build -U ENABLE_IWYU
|
2023-11-25 03:32:32 -07:00
|
|
|
cmake --build build
|
2022-09-11 08:12:44 -07:00
|
|
|
|
2014-02-01 07:20:02 -07:00
|
|
|
clean:
|
2021-09-19 15:53:48 -07:00
|
|
|
+test -d build && $(BUILD_TOOL) -C build clean || true
|
2023-03-06 20:13:04 -07:00
|
|
|
$(MAKE) -C test/old/testdir clean
|
2019-09-18 13:40:06 -07:00
|
|
|
$(MAKE) -C runtime/indent 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
|
2021-09-19 15:53:48 -07:00
|
|
|
+$(BUILD_TOOL) -C build install
|
2014-02-01 07:27:24 -07:00
|
|
|
|
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 $*
|
|
|
|
|
2019-08-04 08:13:04 -07:00
|
|
|
# Generic pattern rules, allowing for `make build/bin/nvim` etc.
|
|
|
|
# Does not work with "Unix Makefiles".
|
2021-09-19 15:53:48 -07:00
|
|
|
ifeq ($(CMAKE_GENERATOR),Ninja)
|
2019-12-02 09:18:37 -07:00
|
|
|
build/%: phony_force
|
2021-09-19 15:53:48 -07:00
|
|
|
$(BUILD_TOOL) -C build $(patsubst build/%,%,$@)
|
2019-07-30 04:53:33 -07:00
|
|
|
|
2019-12-02 09:18:37 -07:00
|
|
|
$(DEPS_BUILD_DIR)/%: phony_force
|
2021-09-19 15:53:48 -07:00
|
|
|
$(BUILD_TOOL) -C $(DEPS_BUILD_DIR) $(patsubst $(DEPS_BUILD_DIR)/%,%,$@)
|
2019-08-04 08:13:04 -07:00
|
|
|
endif
|
2019-07-30 04:53:33 -07:00
|
|
|
|
2023-07-14 06:51:15 -07:00
|
|
|
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)
|