aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-05-04 11:10:26 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-05-04 11:10:26 +0200
commit436187efa55385c2bec80981d255566d5083c9e8 (patch)
treed844402679c49910327f2cd6b358a239db68af2b /Makefile
parentc24348eb207fdd124b61212c27ab6951279ce322 (diff)
downloadchattymalloc-436187efa55385c2bec80981d255566d5083c9e8.tar.gz
chattymalloc-436187efa55385c2bec80981d255566d5083c9e8.zip
copy speedymalloc's build system
Thanks to Florian Schmaus for most of the work.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile57
1 files changed, 57 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1def4c2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,57 @@
+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 builddir check check-format clean debug format release
+
+all: release
+
+BUILDTYPE ?= debugoptimized
+BUILDDIR := build-$(BUILDTYPE)
+
+release:
+ $(MAKE) build BUILDTYPE=$@
+
+debug:
+ $(MAKE) build BUILDTYPE=$@
+
+build: builddir
+ ninja -C $(BUILDDIR)
+
+builddir:
+ [[ -d $(BUILDDIR) ]] || mkdir $(BUILDDIR)
+ [[ -d build && $(shell realpath $(BUILDDIR)) == $(shell realpath build) ]] || ( \
+ rm -f build && \
+ ln -rs $(BUILDDIR) build && \
+ meson --buildtype=$(BUILDTYPE) $(BUILDDIR) \
+ )
+
+
+CHECK_NINJA_TARGETS += test
+
+# 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)
+CHECK_NINJA_TARGETS += clang-tidy
+else
+$(warning old mesion version $(MESON_VERSION) detected, meson >= 0.52 required for clang-tidy)
+endif
+
+check: all check-format
+ ninja -C build $(CHECK_NINJA_TARGETS)
+
+format: all
+ ninja -C build clang-format
+
+check-format:
+ ./tools/check-format
+
+clean:
+ rm -rf build
+ rm -rf build-*