diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-03 22:04:38 +0200 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-03 22:04:38 +0200 |
commit | 2253da61e9b3dd5408bed182ea08e5270156c17e (patch) | |
tree | 298bb06e681ec5366faa539906cae6e805fe5862 /scripts/makefile | |
download | fwd-2253da61e9b3dd5408bed182ea08e5270156c17e.tar.gz fwd-2253da61e9b3dd5408bed182ea08e5270156c17e.zip |
initial commit
+ Lots of code copied from ek, so didn't have to start from scratch, but
might mean there are some quirks here and there that made sense in ek
but not necessarily here.
Diffstat (limited to 'scripts/makefile')
-rw-r--r-- | scripts/makefile | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/makefile b/scripts/makefile new file mode 100644 index 0000000..922497d --- /dev/null +++ b/scripts/makefile @@ -0,0 +1,69 @@ +# 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: fwd + +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) + +COMPILE_FWD = $(COMPILE) $(FWD_FLAGS) + +-include deps.mk + +fwd: $(FWD_OBJS) build/gen/parser.o + $(COMPILE_FWD) $(FWD_OBJS) build/gen/parser.o -o $@ + + +# might lint some common things twice +.PHONY: +lint: $(FWD_LINTS) |