Makefile 1.75 KB
Newer Older
Florian Fischer's avatar
Florian Fischer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
SHELL=bash

# 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 coverage debug\
	format release smoke-test test

all: build

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

NINJA_BIN ?= ninja
NINJA := $(NINJA_BIN) $(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=$@

coverage:
	$(MAKE) COVERAGE_REPORT=true test

SMOKE_TEST_NINJA_TARGETS += iwyu

TEST_NINJA_TARGETS += test

ifeq ($(COVERAGE_REPORT), true)
ifeq ($(shell command -v gcovr &> /dev/null && echo true), true)
TEST_NINJA_TARGETS += coverage
export EMPER_ECHO_SERVER_COVERAGE = true
else
$(warning can not produce coverage report, because missing gcovr)
endif
endif

# Meson >= 0.52 will automatically generate a clang-tidy target if a
# .clang-tidy file is found.
# Source version check: https://stackoverflow.com/a/3732456/194894
ifeq ($(shell [ $(MESON_MINOR_VERSION) -ge 52 ] && echo true), true)
SMOKE_TEST_NINJA_TARGETS += clang-tidy
else
$(warning old mesion version $(MESON_VERSION) detected, meson >= 0.52 required for clang-tidy)
endif

smoke-test: all check-format check-license
	cd build && meson test --suite smoke
	$(NINJA) -C build $(SMOKE_TEST_NINJA_TARGETS)

test: all
	$(NINJA) -C build $(TEST_NINJA_TARGETS)

check: smoke-test test

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

check-format:
	./tools/check-format

check-license:
	./tools/check-license

clean:
	rm -rf build
	rm -rf build-*
79
	rm -rf subprojects/emper