diff options
Diffstat (limited to 'scripts/makefile')
-rw-r--r-- | scripts/makefile | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/makefile b/scripts/makefile new file mode 100644 index 0000000..fc29388 --- /dev/null +++ b/scripts/makefile @@ -0,0 +1,71 @@ +# this could be done better +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" + +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: calc + +# 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) $(LTOFLAGS) \ + $(OBFLAGS) $(ASSERTFLAGS) $(DEBUGFLAGS) + +INCLUDE_FLAGS := -I include + +COMPILE = $(COMPILER) \ + $(COMPILE_FLAGS) $(DEPFLAGS) $(INCLUDE_FLAGS) + +LINT = $(COMPILER) \ + $(COMPILE_FLAGS) $(LINTFLAGS) $(INCLUDE_FLAGS) + +COMPILE_CALC = $(COMPILE) $(CALC_FLAGS) + +-include deps.mk + +calc: $(CALC_OBJS) deps/ejit/ejit.o + $(COMPILE_CALC) $(CALC_OBJS) deps/ejit/ejit.o -o $@ + + +# might lint some common things twice +.PHONY: +lint: $(EK_LINTS) |