# 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" DEPFLAGS = -MT $@ -MMD -MP -MF $@.d LINTFLAGS := -fsyntax-only PREPROCESS := -E LLVM ?= 0 BUILD := build all: libejit.a # 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) $(LTOFLAGS) \ $(OBFLAGS) $(ASSERTFLAGS) $(DEBUGFLAGS) INCLUDE_FLAGS := -I include COMPILE = $(COMPILER) \ $(COMPILE_FLAGS) $(DEPFLAGS) $(INCLUDE_FLAGS) LINT = $(COMPILER) \ $(COMPILE_FLAGS) $(LINTFLAGS) $(INCLUDE_FLAGS) UBSAN ?= 0 UBSAN_FLAGS != [ "$(UBSAN)" != "0" ] \ && echo -fsanitize=undefined \ || echo COMPILE_EJIT = $(COMPILE) $(EJIT_FLAGS) -include deps.mk libejit.a: $(EJIT_OBJS) $(CROSS_COMPILE)ar rcs libejit.a $(EJIT_OBJS) examples: examples/loop examples/fib examples/matrix_mult examples/matrix_mult: examples/matrix_mult.c libejit.a $(COMPILE_EJIT) examples/matrix_mult.c libejit.a -o $@ examples/loop: examples/loop.c libejit.a $(COMPILE_EJIT) examples/loop.c libejit.a -o $@ examples/fib: examples/fib.c libejit.a $(COMPILE_EJIT) examples/fib.c libejit.a -o $@ # might lint some common things twice .PHONY: lint: $(TRISCV_LINTS)