2024-08-30 06:04:20 -05: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
|
2024-09-20 07:50:32 -05:00
|
|
|
CMAKE := $(shell (command -v cmake3 || command -v cmake || echo cmake))
|
2024-09-02 05:51:30 -05:00
|
|
|
CMAKE_GENERATOR ?= "$(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || echo "Unix Makefiles")"
|
2024-08-30 06:04:20 -05:00
|
|
|
define rmdir
|
|
|
|
rm -rf $1
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2021-09-19 17:53:48 -05:00
|
|
|
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
|
|
|
|
|
2014-06-14 10:39:20 -05: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 18:49:16 -06:00
|
|
|
# See contrib/local.mk.example
|
2014-02-25 08:55:36 -06:00
|
|
|
-include local.mk
|
|
|
|
|
2019-06-29 17:13:53 -05:00
|
|
|
all: nvim
|
|
|
|
|
2019-03-18 20:49:33 -05:00
|
|
|
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
2019-02-15 17:23:51 -06:00
|
|
|
# Extra CMake flags which extend the default set
|
|
|
|
CMAKE_EXTRA_FLAGS ?=
|
2021-09-19 17:53:48 -05:00
|
|
|
NVIM_PRG := $(MAKEFILE_DIR)/build/bin/nvim
|
2019-02-15 17:23:51 -06:00
|
|
|
|
|
|
|
# CMAKE_INSTALL_PREFIX
|
|
|
|
# - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
|
2019-02-16 22:28:32 -06:00
|
|
|
# - `checkprefix` target checks that it matches the CMake-cached value. #9615
|
2019-06-29 18:29:10 -05:00
|
|
|
ifneq (,$(CMAKE_INSTALL_PREFIX)$(CMAKE_EXTRA_FLAGS))
|
|
|
|
CMAKE_INSTALL_PREFIX := $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
|
2019-02-15 17:23:51 -06:00
|
|
|
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
|
2019-06-29 14:48:40 -05:00
|
|
|
endif
|
2019-03-18 20:49:33 -05:00
|
|
|
ifneq (,$(CMAKE_INSTALL_PREFIX))
|
2019-07-17 09:38:11 -05:00
|
|
|
override CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
|
2019-06-29 14:48:40 -05:00
|
|
|
|
|
|
|
checkprefix:
|
|
|
|
@if [ -f build/.ran-cmake ]; then \
|
2024-01-01 06:08:56 -06:00
|
|
|
cached_prefix=$(shell $(CMAKE) -L -N build | 2>/dev/null grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2); \
|
2019-06-29 14:48:40 -05: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 20:49:33 -05:00
|
|
|
endif
|
2014-03-03 09:09:06 -06:00
|
|
|
|
2024-08-30 06:04:20 -05:00
|
|
|
DEPS_BUILD_DIR ?= ".deps"
|
2018-03-11 07:15:42 -05:00
|
|
|
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
|
|
|
|
$(error DEPS_BUILD_DIR must not contain whitespace)
|
|
|
|
endif
|
2014-03-03 09:09:06 -06:00
|
|
|
|
|
|
|
DEPS_CMAKE_FLAGS ?=
|
2023-01-19 15:12:27 -06:00
|
|
|
USE_BUNDLED ?=
|
2014-06-14 10:39:20 -05:00
|
|
|
|
2018-09-24 16:18:48 -05:00
|
|
|
ifneq (,$(USE_BUNDLED))
|
|
|
|
BUNDLED_CMAKE_FLAG := -DUSE_BUNDLED=$(USE_BUNDLED)
|
2014-06-14 10:39:20 -05:00
|
|
|
endif
|
2014-02-24 18:22:48 -06:00
|
|
|
|
2016-03-06 21:42:49 -06:00
|
|
|
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
|
|
|
|
BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON
|
2024-08-30 06:04:20 -05:00
|
|
|
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || $(RM) build/.ran-*)
|
2016-03-06 21:42:49 -06:00
|
|
|
endif
|
|
|
|
|
2014-06-14 10:42:50 -05: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 20:32:25 -06:00
|
|
|
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
|
|
|
|
|
2019-06-29 14:48:40 -05:00
|
|
|
nvim: build/.ran-cmake deps
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) --build build
|
2014-02-01 08:27:24 -06:00
|
|
|
|
2014-11-30 20:22:46 -06:00
|
|
|
libnvim: build/.ran-cmake deps
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) --build build --target libnvim
|
2014-11-30 20:22:46 -06:00
|
|
|
|
2014-03-31 03:41:26 -05:00
|
|
|
cmake:
|
2024-08-30 06:04:20 -05:00
|
|
|
$(TOUCH) CMakeLists.txt
|
2014-03-31 03:41:26 -05:00
|
|
|
$(MAKE) build/.ran-cmake
|
2014-02-27 13:57:06 -06:00
|
|
|
|
2014-03-03 09:09:06 -06:00
|
|
|
build/.ran-cmake: | deps
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) -B build -G $(CMAKE_GENERATOR) $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
|
|
|
|
$(TOUCH) $@
|
2014-02-01 08:20:02 -06:00
|
|
|
|
2022-06-27 05:08:59 -05:00
|
|
|
deps: | build/.ran-deps-cmake
|
2018-09-24 16:18:48 -05:00
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED)),)
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) --build $(DEPS_BUILD_DIR)
|
2014-06-14 10:39:20 -05:00
|
|
|
endif
|
2014-02-01 08:20:02 -06:00
|
|
|
|
2018-09-24 16:18:48 -05:00
|
|
|
ifeq ($(call filter-true,$(USE_BUNDLED)),)
|
2019-06-23 21:13:57 -05:00
|
|
|
$(DEPS_BUILD_DIR):
|
2024-08-30 06:04:20 -05:00
|
|
|
$(MKDIR) $@
|
2022-06-27 05:08:59 -05:00
|
|
|
build/.ran-deps-cmake:: $(DEPS_BUILD_DIR)
|
2024-08-30 06:04:20 -05: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 10:39:20 -05:00
|
|
|
endif
|
2022-06-27 05:08:59 -05:00
|
|
|
build/.ran-deps-cmake::
|
2024-08-30 06:04:20 -05:00
|
|
|
$(MKDIR) build
|
|
|
|
$(TOUCH) "$@"
|
2014-02-27 13:57:06 -06:00
|
|
|
|
2017-02-11 18:02:54 -06:00
|
|
|
# TODO: cmake 3.2+ add_custom_target() has a USES_TERMINAL flag.
|
2024-01-01 06:08:56 -06:00
|
|
|
oldtest: | nvim
|
|
|
|
$(SINGLE_MAKE) -C test/old/testdir clean
|
2017-02-11 18:02:54 -06:00
|
|
|
ifeq ($(strip $(TEST_FILE)),)
|
2024-01-01 06:08:56 -06:00
|
|
|
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) $(MAKEOVERRIDES)
|
2017-02-11 18:02:54 -06:00
|
|
|
else
|
2019-12-02 10:18:37 -06:00
|
|
|
@# Handle TEST_FILE=test_foo{,.res,.vim}.
|
2024-01-01 06:08:56 -06:00
|
|
|
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst %.vim,%,$(patsubst %.res,%,$(TEST_FILE)))
|
2017-02-11 18:02:54 -06:00
|
|
|
endif
|
2019-12-02 10:18:37 -06:00
|
|
|
# Build oldtest by specifying the relative .vim filename.
|
|
|
|
.PHONY: phony_force
|
2023-04-27 01:26:07 -05:00
|
|
|
test/old/testdir/%.vim: phony_force nvim
|
2024-01-01 06:08:56 -06:00
|
|
|
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst test/old/testdir/%.vim,%,$@)
|
2014-09-29 07:43:52 -05:00
|
|
|
|
2023-01-19 15:12:27 -06:00
|
|
|
functionaltest-lua: | nvim
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) --build build --target functionaltest
|
2014-11-05 04:54:20 -06:00
|
|
|
|
2023-01-19 15:12:27 -06:00
|
|
|
FORMAT=formatc formatlua format
|
2025-02-06 06:45:41 -06:00
|
|
|
LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc lint luals
|
2023-01-19 15:12:27 -06:00
|
|
|
TEST=functionaltest unittest
|
2023-08-17 05:14:58 -05:00
|
|
|
generated-sources benchmark $(FORMAT) $(LINT) $(TEST) doc: | build/.ran-cmake
|
2024-01-01 06:08:56 -06:00
|
|
|
$(CMAKE) --build build --target $@
|
2016-03-06 21:42:49 -06:00
|
|
|
|
2023-01-19 15:12:27 -06:00
|
|
|
test: $(TEST)
|
2015-11-27 17:08:08 -06:00
|
|
|
|
2024-11-24 04:29:39 -06:00
|
|
|
# iwyu-fix-includes can be downloaded from
|
|
|
|
# https://github.com/include-what-you-use/include-what-you-use/blob/master/fix_includes.py.
|
|
|
|
# Create a iwyu-fix-includes shell script in your $PATH that invokes the python script.
|
2022-09-11 10:12:44 -05:00
|
|
|
iwyu: build/.ran-cmake
|
2024-01-01 06:08:56 -06:00
|
|
|
$(CMAKE) --preset iwyu
|
|
|
|
$(CMAKE) --build build > build/iwyu.log
|
2023-12-18 03:55:23 -06: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 08:34:29 -06:00
|
|
|
)" --nosafe_headers < build/iwyu.log
|
2024-01-01 06:08:56 -06:00
|
|
|
$(CMAKE) -B build -U ENABLE_IWYU
|
|
|
|
$(CMAKE) --build build
|
2022-09-11 10:12:44 -05:00
|
|
|
|
2014-02-01 08:20:02 -06:00
|
|
|
clean:
|
2024-08-30 06:04:20 -05:00
|
|
|
ifneq ($(wildcard build),)
|
|
|
|
$(CMAKE) --build build --target clean
|
|
|
|
endif
|
2023-03-06 21:13:04 -06:00
|
|
|
$(MAKE) -C test/old/testdir clean
|
2019-09-18 15:40:06 -05:00
|
|
|
$(MAKE) -C runtime/indent clean
|
2014-02-01 08:20:02 -06:00
|
|
|
|
2019-06-25 12:51:28 -05:00
|
|
|
distclean:
|
2024-08-30 06:04:20 -05:00
|
|
|
$(call rmdir, $(DEPS_BUILD_DIR))
|
|
|
|
$(call rmdir, build)
|
2019-06-25 12:51:28 -05:00
|
|
|
$(MAKE) clean
|
2014-02-24 18:04:51 -06:00
|
|
|
|
2019-06-29 14:48:40 -05:00
|
|
|
install: checkprefix nvim
|
2024-08-30 06:04:20 -05:00
|
|
|
$(CMAKE) --install build
|
2014-02-01 08:27:24 -06:00
|
|
|
|
2017-05-01 19:35:04 -05:00
|
|
|
appimage:
|
|
|
|
bash scripts/genappimage.sh
|
|
|
|
|
2019-02-15 17:23:51 -06:00
|
|
|
# Build an appimage with embedded update information.
|
|
|
|
# appimage-nightly: for nightly builds
|
|
|
|
# appimage-latest: for a release
|
2018-03-09 09:51:27 -06:00
|
|
|
appimage-%:
|
|
|
|
bash scripts/genappimage.sh $*
|
|
|
|
|
2023-07-14 08:51:15 -05:00
|
|
|
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)
|