From b8c15c65ee22cf99bbef461c8b246a85b771fa9e Mon Sep 17 00:00:00 2001 From: sfja Date: Fri, 5 Sep 2025 21:33:02 +0200 Subject: [PATCH] init --- .clang-format | 14 +++++++++++++ .gitignore | 1 + Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++ compile_flags.txt | 10 +++++++++ vm/main.c | 6 ++++++ 5 files changed, 84 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 compile_flags.txt create mode 100644 vm/main.c diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a56cbd0 --- /dev/null +++ b/.clang-format @@ -0,0 +1,14 @@ +Language: Cpp +BasedOnStyle: WebKit +IndentWidth: 4 +ColumnLimit: 80 +IndentCaseLabels: true +InsertNewlineAtEOF: true +AllowShortFunctionsOnASingleLine: None + +BinPackArguments: false +AllowAllArgumentsOnNextLine: true + +BinPackParameters: false +AllowAllParametersOfDeclarationOnNextLine: true + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..21bfd0e --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ + +MAKEFLAGS += -j $(shell nproc) + +CC = gcc + +COMPILER_FLAGS = \ + -std=c23 \ + -Wall -Wextra -Wpedantic -Wconversion \ + -pedantic -pedantic-errors \ + -Wno-unused-function \ + +LINKER_FLAGS = \ + -pthread + +COMPILER_FLAGS += $(shell pkg-config sdl2 --cflags) +LINKER_FLAGS += $(shell pkg-config sdl2 --libs) + +FEATURE_FLAGS = +OPTIMIZATION_FLAGS = + +# override by 'make RELEASE=1 ...' +RELEASE=0 + +ifeq ($(RELEASE),1) + COMPILER_FLAGS += -Werror + FEATURE_FLAGS += -flto=auto + OPTIMIZATION_FLAGS += -O3 +else + COMPILER_FLAGS += -g -Wno-unused-variable + FEATURE_FLAGS += -fsanitize=address,undefined,leak + OPTIMIZATION_FLAGS += -Og +endif + +HEADERS = $(shell find . -name *.h) + +VM_SOURCES = $(shell find vm/ -name *.c) +VM_OBJECTS = $(patsubst %.c,build/%.o,$(VM_SOURCES)) + +all: build/bin/vm + +build/bin/vm: $(VM_OBJECTS) + @mkdir -p $(dir $@) + $(CC) $(VM_OBJECTS) -o $@ $(FEATURE_FLAGS) $(OPTIMIZATION_FLAGS) $(LINKER_FLAGS) + +build/%.o: %.c $(HEADERS) + @mkdir -p $(dir $@) + $(CC) $< -c -o $@ $(COMPILER_FLAGS) $(OPTIMIZATION_FLAGS) $(FEATURE_FLAGS) + +.PHONY: run_kern clean + +clean: + rm -rf build/ bin/ + diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..7672925 --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,10 @@ +-xc +-std=c23 +-Wall +-Wextra +-Wpedantic +-Wconversion +-pedantic +-pedantic-errors +-Wno-unused-variable + diff --git a/vm/main.c b/vm/main.c new file mode 100644 index 0000000..083d128 --- /dev/null +++ b/vm/main.c @@ -0,0 +1,6 @@ +#include + +int main(void) +{ + printf("test\n"); +}