Skip to content
Snippets Groups Projects
Makefile 1.93 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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)
    
    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=$@
    
    Florian Schmaus's avatar
    Florian Schmaus committed
    
    
    STATIC_ANALYSIS_NINJA_TARGETS += iwyu
    
    # 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)
    
    STATIC_ANALYSIS_NINJA_TARGETS += clang-tidy
    
    else
    $(warning old mesion version $(MESON_VERSION) detected, meson >= 0.52 required for clang-tidy)
    endif
    
    
    static-analysis: all
    	$(NINJA) -C build $(STATIC_ANALYSIS_NINJA_TARGETS)
    
    Florian Schmaus's avatar
    Florian Schmaus committed
    
    
    smoke-test: all check-format check-license doc static-analysis
    	cd build && meson test --suite smoke
    
    
    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: iwyu
    iwyu: all
    	$(NINJA) -C build $@
    
    
    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