From 5d29afb530ffdaab4b5032b7422da988b31c0867 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 29 Oct 2023 14:38:33 +0200 Subject: initial working compiled program on simulator --- tdump/scripts/makefile | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tdump/scripts/makefile (limited to 'tdump/scripts/makefile') diff --git a/tdump/scripts/makefile b/tdump/scripts/makefile new file mode 100644 index 0000000..b782cd1 --- /dev/null +++ b/tdump/scripts/makefile @@ -0,0 +1,72 @@ +# 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: tdump + +# 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 = -std=gnu17 -g +WARNFLAGS = -Wall -Wextra + +COMPILE_FLAGS = $(CFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(OBFLAGS) $(ASSERTFLAGS) \ + $(DEBUGFLAGS) + +INCLUDE_FLAGS = -I include -I ../core + +# This makes sure .bss is loaded into the binary +OBJCOPY_FLAGS ?= -Obinary -R .garbage \ + --set-section-flags .bss=alloc,load,contents + +COMPILE = $(COMPILER) \ + $(COMPILE_FLAGS) $(DEPFLAGS) $(INCLUDE_FLAGS) + +LINT = $(COMPILER) \ + $(COMPILE_FLAGS) $(LINTFLAGS) $(INCLUDE_FLAGS) + +UBSAN ?= 0 +TASM_FLAGS != [ "$(UBSAN)" != "0" ] \ + && echo -fsanitize=undefined \ + || echo + +COMPILE_TDUMP = $(COMPILE) $(TDUMP_FLAGS) + +-include deps.mk +-include src/source.mk + +tdump: $(TDUMP_OBJS) + $(COMPILE_TDUMP) $(TDUMP_OBJS) -o $@ + + +# might lint some common things twice +.PHONY: +lint: $(TDUMP_LINTS) -- cgit v1.3