diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-18 22:35:27 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-23 18:25:23 +0300 |
commit | 7c5f098511b8f612a17f4ccdd8a4924c325d37e1 (patch) | |
tree | 4a97d802557bbffcadfcfd776c8e4afdb31d96aa /scripts/makefile | |
parent | 18262dcbecd97591dd15ee9274a81abb8c2ba1c4 (diff) | |
download | lyn-7c5f098511b8f612a17f4ccdd8a4924c325d37e1.tar.gz lyn-7c5f098511b8f612a17f4ccdd8a4924c325d37e1.zip |
initial parser+lexer
+ AST might still change, also not a *huge* fan of having to reverse
all arrays but I guess it's unlikely to be a significant bottleneck
Diffstat (limited to 'scripts/makefile')
-rw-r--r-- | scripts/makefile | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/makefile b/scripts/makefile new file mode 100644 index 0000000..dd0f7fd --- /dev/null +++ b/scripts/makefile @@ -0,0 +1,74 @@ +# this could be done better +RELEASE ?= 0 +OPTFLAGS != [ "$(RELEASE)" != "0" ] \ + && echo "-O2 -flto=auto" \ + || 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: lyn + +include gen/source.mk + +# default values, overwrite if/when needed +CROSS_COMPILE := + +OBJCOPY != [ "$(LLVM)" != "0" ] \ + && echo llvm-objcopy \ + || echo $(CROSS_COMPILE)objcopy + +COMPILER != [ -n "$(CROSS_COMPILE)" ] \ + && { \ + [ "$(LLVM)" != "0" ] \ + && echo clang --target="$(CROSS_COMPILE)" \ + || echo $(CROSS_COMPILE)gcc \ + ; \ + } \ + || echo $(CC) + + +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_LYN = $(COMPILE) $(LYN_FLAGS) + +-include deps.mk + +lyn: $(LYN_OBJS) build/gen/parser.o + $(COMPILE_LYN) $(LYN_OBJS) build/gen/parser.o -o $@ + + +# might lint some common things twice +.PHONY: +lint: $(LYN_LINTS) |