Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

203 lines
5.9 KiB
Makefile
Raw Permalink Normal View History

2024-08-30 13:04:20 +02:00
ifeq ($(OS),Windows_NT)
2025-02-22 16:46:31 +01:00
ifeq '$(findstring ;,$(PATH))' ';'
UNIX_LIKE := FALSE
else
UNIX_LIKE := TRUE
endif
else
UNIX_LIKE := TRUE
endif
ifeq ($(UNIX_LIKE),FALSE)
2024-08-30 13:04:20 +02:00
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 || command -v cmake || echo cmake))
CMAKE_GENERATOR ?= "$(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || echo "Unix Makefiles")"
2024-08-30 13:04:20 +02:00
define rmdir
rm -rf $1
endef
endif
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
2014-06-14 19:39:20 +04: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 19:49:16 -05:00
# See contrib/local.mk.example
2014-02-25 11:55:36 -03:00
-include local.mk
all: nvim
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
2019-02-16 00:23:51 +01:00
# Extra CMake flags which extend the default set
CMAKE_EXTRA_FLAGS ?=
NVIM_PRG := $(MAKEFILE_DIR)/build/bin/nvim
2019-02-16 00:23:51 +01:00
# CMAKE_INSTALL_PREFIX
# - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
# - `checkprefix` target checks that it matches the CMake-cached value. #9615
ifneq (,$(CMAKE_INSTALL_PREFIX)$(CMAKE_EXTRA_FLAGS))
CMAKE_INSTALL_PREFIX := $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
2019-02-16 00:23:51 +01:00
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
endif
ifneq (,$(CMAKE_INSTALL_PREFIX))
override CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
checkprefix:
@if [ -f build/.ran-cmake ]; then \
2024-01-01 13:08:56 +01:00
cached_prefix=$(shell $(CMAKE) -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: ;
endif
2014-03-03 10:09:06 -05:00
2024-08-30 13:04:20 +02:00
DEPS_BUILD_DIR ?= ".deps"
2018-03-11 13:15:42 +01:00
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
$(error DEPS_BUILD_DIR must not contain whitespace)
endif
2014-03-03 10:09:06 -05:00
DEPS_CMAKE_FLAGS ?=
USE_BUNDLED ?=
2014-06-14 19:39:20 +04:00
ifdef BUNDLED_CMAKE_FLAG
$(error BUNDLED_CMAKE_FLAG was removed. Use DEPS_CMAKE_FLAGS instead)
endif
ifdef BUNDLED_LUA_CMAKE_FLAG
$(error BUNDLED_LUA_CMAKE_FLAG was removed. Use DEPS_CMAKE_FLAGS instead)
endif
# If USE_BUNDLED is non-empty, prepend the flag to DEPS_CMAKE_FLAGS
ifneq (,$(USE_BUNDLED))
DEPS_CMAKE_FLAGS := -DUSE_BUNDLED=$(USE_BUNDLED) $(DEPS_CMAKE_FLAGS)
2014-06-14 19:39:20 +04:00
endif
2016-03-07 00:42:49 -03:00
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
DEPS_CMAKE_FLAGS := -DUSE_BUNDLED_LUA=ON $(DEPS_CMAKE_FLAGS)
2024-08-30 13:04:20 +02:00
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || $(RM) build/.ran-*)
2016-03-07 00:42:49 -03:00
endif
# 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.
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
nvim: build/.ran-cmake deps
2024-08-30 13:04:20 +02:00
$(CMAKE) --build build
2014-02-01 11:27:24 -03:00
2014-11-30 21:22:46 -05:00
libnvim: build/.ran-cmake deps
2024-08-30 13:04:20 +02:00
$(CMAKE) --build build --target libnvim
2014-11-30 21:22:46 -05:00
cmake:
2024-08-30 13:04:20 +02:00
$(TOUCH) CMakeLists.txt
$(MAKE) build/.ran-cmake
2014-02-27 16:57:06 -03:00
2014-03-03 10:09:06 -05:00
build/.ran-cmake: | deps
2024-08-30 13:04:20 +02:00
$(CMAKE) -B build -G $(CMAKE_GENERATOR) $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
$(TOUCH) $@
2014-02-01 11:20:02 -03:00
2026-03-19 10:56:54 +01:00
ifneq ($(call filter-true,$(USE_BUNDLED)),)
deps: ;
else
2022-06-27 03:08:59 -07:00
deps: | build/.ran-deps-cmake
2024-08-30 13:04:20 +02:00
$(CMAKE) --build $(DEPS_BUILD_DIR)
2014-02-01 11:20:02 -03:00
$(DEPS_BUILD_DIR):
2024-08-30 13:04:20 +02:00
$(MKDIR) $@
2022-06-27 03:08:59 -07:00
build/.ran-deps-cmake:: $(DEPS_BUILD_DIR)
$(CMAKE) -S $(MAKEFILE_DIR)/cmake.deps -B $(DEPS_BUILD_DIR) -G $(CMAKE_GENERATOR) $(DEPS_CMAKE_FLAGS)
2014-06-14 19:39:20 +04:00
endif
2026-03-19 10:56:54 +01:00
2022-06-27 03:08:59 -07:00
build/.ran-deps-cmake::
2024-08-30 13:04:20 +02:00
$(MKDIR) build
$(TOUCH) "$@"
2014-02-27 16:57:06 -03:00
# TODO: cmake 3.2+ add_custom_target() has a USES_TERMINAL flag.
2024-01-01 13:08:56 +01:00
oldtest: | nvim
$(SINGLE_MAKE) -C test/old/testdir clean
ifeq ($(strip $(TEST_FILE)),)
2024-01-01 13:08:56 +01:00
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) $(MAKEOVERRIDES)
else
@# Handle TEST_FILE=test_foo{,.res,.vim}.
2024-01-01 13:08:56 +01:00
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst %.vim,%,$(patsubst %.res,%,$(TEST_FILE)))
endif
2026-03-19 10:56:54 +01:00
# Build oldtest by specifying the relative .vim filename.
.PHONY: phony_force
test/old/testdir/%.vim: phony_force nvim
2024-01-01 13:08:56 +01:00
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst test/old/testdir/%.vim,%,$@)
functionaltest-lua: | nvim
2024-08-30 13:04:20 +02:00
$(CMAKE) --build build --target functionaltest
2025-03-14 10:40:36 -07:00
FORMAT=formatc formatlua formatquery format
2026-04-16 10:48:11 -04:00
LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc lintdocurls lint luals lintquery linterrcodes
TEST=functionaltest unittest
2023-08-17 11:14:58 +01:00
generated-sources benchmark $(FORMAT) $(LINT) $(TEST) doc: | build/.ran-cmake
2024-01-01 13:08:56 +01:00
$(CMAKE) --build build --target $@
2016-03-07 00:42:49 -03:00
test: $(TEST)
2015-11-27 18:08:08 -05:00
+3
2024-11-24 11:29:39 +01: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.
iwyu: build/.ran-cmake
2024-01-01 13:08:56 +01:00
$(CMAKE) --preset iwyu
$(CMAKE) --build build > build/iwyu.log
2023-12-18 10:55:23 +01: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\
)" --nosafe_headers < build/iwyu.log
2024-01-01 13:08:56 +01:00
$(CMAKE) -B build -U ENABLE_IWYU
$(CMAKE) --build build
2014-02-01 11:20:02 -03:00
clean:
2024-08-30 13:04:20 +02:00
ifneq ($(wildcard build),)
$(CMAKE) --build build --target clean
endif
$(MAKE) -C test/old/testdir clean
2014-02-01 11:20:02 -03:00
distclean:
2024-08-30 13:04:20 +02:00
$(call rmdir, $(DEPS_BUILD_DIR))
$(call rmdir, build)
$(call rmdir, .zig-cache)
$(call rmdir, zig-out)
$(MAKE) clean
2014-02-25 00:04:51 +00:00
install: checkprefix nvim
2024-08-30 13:04:20 +02:00
$(CMAKE) --install build
2014-02-01 11:27:24 -03:00
2017-05-01 20:35:04 -04:00
appimage:
bash scripts/genappimage.sh
2019-02-16 00:23:51 +01:00
# Build an appimage with embedded update information.
# appimage-nightly: for nightly builds
# appimage-latest: for a release
appimage-%:
bash scripts/genappimage.sh $*
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)
2025-06-05 11:31:51 +01:00
.PHONY: emmylua-check
emmylua-check:
-emmylua_check runtime/lua \
--config .luarc.json \
--config .emmyrc.json