From 6c2e51a3f8695cb95d6a4a6859d3f934e28c8f9f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 2 Apr 2025 21:14:23 +0300 Subject: improve build system a bit --- tests/makefile | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/makefile b/tests/makefile index 5aeef98..081170f 100644 --- a/tests/makefile +++ b/tests/makefile @@ -1,14 +1,34 @@ include ./tests.mk -LLVM ?= 0 -CROSS_COMPILE := -COMPILER != [ "$(LLVM)" != "0" ] \ - && echo clang --target="$(CROSS_COMPILE)" \ - || echo $(CROSS_COMPILE)gcc +LLVM ?= 0 +COMPILER != [ -n "$(CROSS_COMPILE)" ] \ + && { \ + [ "$(LLVM)" != "0" ] \ + && echo clang --target="$(CROSS_COMPILE)" \ + || echo $(CROSS_COMPILE)gcc \ + ; \ + } \ + || echo $(CC) -CFLAGS := -Wall -Wextra -O0 -g +RELEASE ?= 0 +OPTFLAGS != [ "$(RELEASE)" != "0" ] \ + && echo "-O2" \ + || echo "-O0" + +LTO ?= 0 +LTOFLAGS != [ "$(LTO)" != "0" ] \ + && echo "-flto=auto" + +DEBUG ?= 1 +DEBUGFLAGS != [ "$(DEBUG)" != "0" ] \ + && echo "-DDEBUG=1" \ + || echo "-DNDEBUG=1" + +OBFLAGS := -g +WARNFLAGS := -Wall -Wextra INCLUDE_FLAGS := -I include -COMPILE_TEST := $(COMPILER) $(CFLAGS) $(INCLUDE_FLAGS) +COMPILE_TEST := $(COMPILER) $(WARNFLAGS) $(OPTFLAGS) $(LTOFLAGS) \ + $(OBFLAGS) $(CFLAGS) $(DEBUGFLAGS) $(INCLUDE_FLAGS) .PHONY: check check: $(TESTS) -- cgit v1.2.3