diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-05-24 14:32:35 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-05-24 14:39:31 +0300 |
| commit | 123860bc029465ff88c3bf82165a89170fa41153 (patch) | |
| tree | 7218306027a61d5e9c1dc1107aeef09eb153ec1b /scripts/makefile | |
| parent | 9f261587a75d5fa21ef63fd9a38e0f7851180adf (diff) | |
| download | qbt-123860bc029465ff88c3bf82165a89170fa41153.tar.gz qbt-123860bc029465ff88c3bf82165a89170fa41153.zip | |
fix bmake compilation
Diffstat (limited to 'scripts/makefile')
| -rw-r--r-- | scripts/makefile | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/makefile b/scripts/makefile new file mode 100644 index 0000000..b416c35 --- /dev/null +++ b/scripts/makefile @@ -0,0 +1,68 @@ +# this could be done better +RELEASE ?= 0 +OPTFLAGS != [ "$(RELEASE)" != "0" ] \ + && echo "-O3 -flto" \ + || echo "-O0" + +DEBUG ?= 1 +DEBUGFLAGS != [ "$(DEBUG)" != "0" ] \ + && echo "-DDEBUG=1" \ + || echo "-DNDEBUG=1" + +ASSERT ?= 1 +ASSERTFLAGS != [ "$(ASSERT)" != "0" ] \ + && echo "-DASSERT=1" \ + || echo + +DEPFLAGS = -MT $@ -MMD -MP -MF $@.d +LINTFLAGS := -fsyntax-only +PREPROCESS := -E + +LLVM ?= 0 +BUILD := build + +all: qbt + +include gen/source.mk + +# default values, overwrite if/when needed +CROSS_COMPILE := + +OBJCOPY != [ "$(LLVM)" != "0" ] \ + && echo llvm-objcopy \ + || echo $(CROSS_COMPILE)objcopy + +COMPILER != [ "$(LLVM)" != "0" ] \ + && echo clang --target="$(CROSS_COMPILE)" \ + || echo $(CROSS_COMPILE)gcc + + +OBFLAGS := -g +WARNFLAGS := -Wall -Wextra + +COMPILE_FLAGS := $(CFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(OBFLAGS) $(ASSERTFLAGS) \ + $(DEBUGFLAGS) + +INCLUDE_FLAGS := -I include + +COMPILE = $(COMPILER) \ + $(COMPILE_FLAGS) $(DEPFLAGS) $(INCLUDE_FLAGS) + +LINT = $(COMPILER) \ + $(COMPILE_FLAGS) $(LINTFLAGS) $(INCLUDE_FLAGS) + +UBSAN ?= 0 +TRISCV_FLAGS != [ "$(UBSAN)" != "0" ] \ + && echo -fsanitize=undefined \ + || echo + +COMPILE_QBT = $(COMPILE) $(QBT_FLAGS) + +-include deps.mk + +qbt: $(QBT_OBJS) + $(COMPILE_QBT) $(QBT_OBJS) -o $@ + +# might lint some common things twice +.PHONY: +lint: $(TRISCV_LINTS) |
