From e2a3ed01311db58f215867165b23bae0f8cc36c8 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 17 Feb 2023 13:44:04 +0100 Subject: [PATCH] Makefile: Build with 4 workers, add 'run-debug', improve 'help' --- .gitignore | 3 +++ Makefile | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a17e883..0ac8acd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,8 @@ /build/* !/build/.emptydirectory +# Debug build directory +/build-debug/* + /.vscode/* /.vs/ diff --git a/Makefile b/Makefile index ba0dcbe..76c3adf 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,41 @@ SOURCES := $(shell find src/ -type f | grep -E '\.(h|c)(pp)?$$') +MAKE_OPTS := -j4 .PHONY: help help: @echo -e "Try one of these make targets:\n" - @grep "^\.PHONY: " Makefile | cut -d" " -f2- | sed -e "s/ /\n/g" | grep -v "^_" + @grep "^\.PHONY: " Makefile | cut -d" " -f2- | tr -s " " | sed -e "s/ /\n/g" | grep -v "^_" | sed -e "s/^/make /" -.PHONY: run run-with-music +.PHONY: run run-with-music run-debug run: build cd build && ./glowbox run-with-music: build cd build && ./glowbox --enable-music +run-debug: build-debug | has-gdb + cd build-debug && gdb -batch -ex "run" -ex "backtrace" ./glowbox .PHONY: build build: build/glowbox build/glowbox: ${SOURCES} | build/Makefile has-make - make -C build - + make -C build $(MAKE_OPTS) build/Makefile: | build/ _submodules has-cmake cd build && cmake .. +.PHONY: build-debug +build-debug: build-debug/glowbox +build-debug/glowbox: ${SOURCES} | build-debug/Makefile has-make + make -C build-debug $(MAKE_OPTS) +build-debug/Makefile: | build-debug/ _submodules has-cmake + cd build-debug && cmake -DCMAKE_BUILD_TYPE=Debug .. + .PHONY: _submodules _submodules: | has-git @git submodule update --init .PHONY: clean clean: - # TODO: submodules + @# TODO: submodules + @test -d build-debug && rm -rfv build-debug/ || true @rm -rfv build/*