2024-08-30 04:04:20 -07:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
SHELL := powershell.exe
|
|
|
|
.SHELLFLAGS := -NoProfile -NoLogo
|
|
|
|
MKDIR := @$$null = new-item -itemtype directory -force
|
|
|
|
TOUCH := @$$null = new-item -force
|
|
|
|
RM := remove-item -force
|
|
|
|
CMAKE := cmake
|
|
|
|
CMAKE_GENERATOR := Ninja
|
|
|
|
define rmdir
|
|
|
|
if (Test-Path $1) { remove-item -recurse $1 }
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
MKDIR := mkdir -p
|
|
|
|
TOUCH := touch
|
|
|
|
RM := rm -rf
|
|
|
|
CMAKE := $(shell (command -v cmake3 || echo cmake))
|
|
|
|
CMAKE_GENERATOR ?= $(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || echo "Unix Makefiles")
|
|
|
|
define rmdir
|
|
|
|
rm -rf $1
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
|
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 \
|
2024-01-01 05:08:56 -07:00
|
|
|
cached_prefix=$(shell $(CMAKE) -L -N build | 2>/dev/null grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2); \
|
2019-06-29 12:48:40 -07:00
|
|
|
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
|
|
|
|
2024-08-30 04:04:20 -07:00
|
|
|
DEPS_BUILD_DIR ?= ".deps"
|
2018-03-11 05:15:42 -07:00
|
|
|
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
|
|
|
|
$(error DEPS_BUILD_DIR must not contain whitespace)
|
|
|
|
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
|
2024-08-30 04:04:20 -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
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) --build build
|
2014-02-01 07:27:24 -07:00
|
|
|
|
2014-11-30 19:22:46 -07:00
|
|
|
libnvim: build/.ran-cmake deps
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) --build build --target libnvim
|
2014-11-30 19:22:46 -07:00
|
|
|
|
2014-03-31 01:41:26 -07:00
|
|
|
cmake:
|
2024-08-30 04:04:20 -07:00
|
|
|
$(TOUCH) CMakeLists.txt
|
2014-03-31 01:41:26 -07:00
|
|
|
$(MAKE) build/.ran-cmake
|
2014-02-27 12:57:06 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
build/.ran-cmake: | deps
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) -B build -G $(CMAKE_GENERATOR) $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
|
|
|
|
$(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)),)
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) --build $(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):
|
2024-08-30 04:04:20 -07:00
|
|
|
$(MKDIR) $@
|
2022-06-27 03:08:59 -07:00
|
|
|
build/.ran-deps-cmake:: $(DEPS_BUILD_DIR)
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) -S $(MAKEFILE_DIR)/cmake.deps -B $(DEPS_BUILD_DIR) -G $(CMAKE_GENERATOR) $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) $(DEPS_CMAKE_FLAGS)
|
2014-06-14 08:39:20 -07:00
|
|
|
endif
|
2022-06-27 03:08:59 -07:00
|
|
|
build/.ran-deps-cmake::
|
2024-08-30 04:04:20 -07:00
|
|
|
$(MKDIR) 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.
|
2024-01-01 05:08:56 -07:00
|
|
|
oldtest: | nvim
|
|
|
|
$(SINGLE_MAKE) -C test/old/testdir clean
|
2017-02-11 17:02:54 -07:00
|
|
|
ifeq ($(strip $(TEST_FILE)),)
|
2024-01-01 05:08:56 -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}.
|
2024-01-01 05:08:56 -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
|
2024-01-01 05:08:56 -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
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) --build build --target functionaltest
|
2014-11-05 03:54:20 -07:00
|
|
|
|
2023-01-19 14:12:27 -07:00
|
|
|
FORMAT=formatc formatlua format
|
2024-01-28 15:22:39 -07:00
|
|
|
LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc 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
|
2024-01-01 05:08:56 -07:00
|
|
|
$(CMAKE) --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
|
|
|
|
2022-09-11 08:12:44 -07:00
|
|
|
iwyu: build/.ran-cmake
|
2024-01-01 05:08:56 -07:00
|
|
|
$(CMAKE) --preset iwyu
|
|
|
|
$(CMAKE) --build build > build/iwyu.log
|
2023-12-18 02:55:23 -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 07:34:29 -07:00
|
|
|
)" --nosafe_headers < build/iwyu.log
|
2024-01-01 05:08:56 -07:00
|
|
|
$(CMAKE) -B build -U ENABLE_IWYU
|
|
|
|
$(CMAKE) --build build
|
2022-09-11 08:12:44 -07:00
|
|
|
|
2014-02-01 07:20:02 -07:00
|
|
|
clean:
|
2024-08-30 04:04:20 -07:00
|
|
|
ifneq ($(wildcard build),)
|
|
|
|
$(CMAKE) --build build --target clean
|
|
|
|
endif
|
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:
|
2024-08-30 04:04:20 -07:00
|
|
|
$(call rmdir, $(DEPS_BUILD_DIR))
|
|
|
|
$(call rmdir, 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
|
2024-08-30 04:04:20 -07:00
|
|
|
$(CMAKE) --install build
|
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 $*
|
|
|
|
|
2023-07-14 06:51:15 -07:00
|
|
|
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)
|