Skip to content
Snippets Groups Projects
Makefile 2.71 KiB
Newer Older
SHELL = bash
Florian Schmaus's avatar
Florian Schmaus committed

# https://stackoverflow.com/a/39124162/194894
word-dot = $(word $2,$(subst ., ,$1))

MESON_VERSION=$(shell meson --version)
MESON_MAJOR_VERSION=$(call word-dot, $(MESON_VERSION), 1)
MESON_MINOR_VERSION=$(call word-dot, $(MESON_VERSION), 2)

.PHONY: all build check check-format clean distclean\
	doc release debug stresstest test

all: build

export BUILDTYPE ?= debugoptimized
export BUILDDIR = build-$(BUILDTYPE)

NPROC := $(shell nproc)
JOBS := $(shell echo $$(( $(NPROC) + 6)))
LOAD := $(shell echo $$(( $(NPROC) * 2)))

NINJA_BIN ?= ninja
NINJA := $(NINJA_BIN) -j $(JOBS) -l $(LOAD) $(EXTRA_NINJA_ARGS)

build:
	[[ -L build ]] || ./tools/prepare-build-dir
	$(NINJA) -C $@

release:
	rm -f build
	$(MAKE) build BUILDTYPE=$@

debug:
	rm -f build
	$(MAKE) build BUILDTYPE=$@
Florian Schmaus's avatar
Florian Schmaus committed

libc++:
	rm -f build
	$(MAKE) build \
		CC=clang CXX=clang++ \
		EMPER_CPP_ARGS="-stdlib=libc++" \
		EMPER_CPP_LINK_ARGS="-stdlib=libc++" \
		EMPER_USE_BUNDLED_DEPS="always" \
		BUILDDIR="build-libc++"

.PHONY: clang
clang:
	rm -f build
	$(MAKE) build \
		CC=clang CXX=clang++ \
		BUILDDIR="build-$@"

.PHONY: fibril-locked
fibril-locked:
	rm -f build
	$(MAKE) build \
		EMPER_CONTINUATION_STEALING_MODE=locked \
		EMPER_LOCKED_WS_QUEUE=true \
		EMPER_IO=false \
		BUILDDIR="build-$@"

.PHONY: fibril-unmap
fibril-unmap:
	rm -f build
	$(MAKE) build \
		EMPER_CONTINUATION_STEALING_MADVISE_STACK=free \
		EMPER_IO=false \
		BUILDDIR="build-$@"

.PHONY: fast-static-analysis
fast-static-analysis: all check-format check-license doc

.PHONY: static-analysis
static-analysis: fast-static-analysis iwyu tidy
Florian Schmaus's avatar
Florian Schmaus committed

.PHONY: smoke-test-suite
smoke-test-suite: all
	cd build && meson test --suite smoke
.PHONY: smoke-test
smoke-test: smoke-test-suite static-analysis

TEST_NINJA_TARGETS += test

doc: all
	$(NINJA) -C build doc/html


test: all
	$(NINJA) -C build $(TEST_NINJA_TARGETS)
Florian Schmaus's avatar
Florian Schmaus committed

clean:
	rm -f build
	rm -rf build-*

distclean: clean
Florian Schmaus's avatar
Florian Schmaus committed
	git clean -x -d -f

Florian Schmaus's avatar
Florian Schmaus committed

.PHONY: check-license
check-license:
	./tools/check-license

.PHONY: format
format: all
	$(NINJA) -C build clang-format

.PHONY: tidy
tidy: compile_commands_wo_subprojects/compile_commands.json
	./tools/run-clang-tidy
PHONY: iwyu
iwyu: compile_commands_wo_subprojects/compile_commands.json
	$(NINJA) -C build $@

build/compile_commands.json: all

compile_commands_wo_subprojects/compile_commands.json: all build/compile_commands.json
	./tools/gen-compile-commands-wo-subprojects

PHONY: fix-includes
fix-includes: all
	./tools/fix-includes

Florian Schmaus's avatar
Florian Schmaus committed
stresstest: test
	./stresstest/stresstest.sh build/tests/simplest_fib_test

# TODO: Determine how we can run also jobs from the 'test' stage,
# e.g. test-gcc.
.PHONY: gitlab-runner
gitlab-runner:
	gitlab-runner exec docker smoke-test