This commit is contained in:
sfja 2025-09-05 21:33:02 +02:00
commit b8c15c65ee
5 changed files with 84 additions and 0 deletions

14
.clang-format Normal file
View File

@ -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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build/

53
Makefile Normal file
View File

@ -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/

10
compile_flags.txt Normal file
View File

@ -0,0 +1,10 @@
-xc
-std=c23
-Wall
-Wextra
-Wpedantic
-Wconversion
-pedantic
-pedantic-errors
-Wno-unused-variable

6
vm/main.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main(void)
{
printf("test\n");
}