aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2021-12-29 22:50:30 +0100
committerMarvin Borner2021-12-29 22:50:30 +0100
commit6236c3d88ccba4429cbb4020ea0ed02816282451 (patch)
treeb687c87c3076e77f0aba581c4ffb6d879fc817e6
Start
-rw-r--r--.gitignore4
-rw-r--r--README.md3
-rw-r--r--makefile45
-rw-r--r--src/create.c7
4 files changed, 59 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..39b9f19
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+tags
+compile_commands.json
+
+build/
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..84c736e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# MarFS
+
+This is a sub-project of Melvix and shouldn't be used otherwise.
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..c05d506
--- /dev/null
+++ b/makefile
@@ -0,0 +1,45 @@
+# Copyright (c) 2021, Marvin Borner <melvix@marvinborner.de>
+# SPDX-License-Identifier: MIT
+
+CC = gcc
+LD = ld
+SU = sudo
+TG = ctags
+
+BUILD = $(PWD)/build
+SRC = ./src
+INC = ./inc
+SRCS = $(shell find $(SRC) -type f -name '*.c')
+OBJS = $(SRCS:%=$(BUILD)/%.o)
+
+CFLAGS_WARNINGS = -Wall -Wextra -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors
+CFLAGS = $(CFLAGS_WARNINGS) -std=c99 -fno-profile-generate -fno-omit-frame-pointer -fno-common -fno-asynchronous-unwind-tables -mno-red-zone -Ofast -I$(INC)
+
+all: $(BUILD) $(OBJS)
+
+compile: all sync
+
+clean:
+ @rm -rf $(BUILD)/*
+
+run: compile $(BUILD) $(BUILD)/disk.img
+
+sync: # Ugly hack
+ @$(MAKE) --always-make --dry-run | grep -wE 'gcc' | grep -w '\-c' | jq -nR '[inputs|{directory: match("/marfs/build/[^.]+").string[14:], command: ., file: match(" [^ ]+$$").string[1:]}]' >compile_commands.json &
+ @$(TG) -R --exclude=.git --exclude=build . &
+
+$(BUILD)/%.c.o: %.c
+ @$(CC) $(CFLAGS) $< -o $(patsubst $(BUILD)/$(SRC)/%.c.o,$(BUILD)/%,$@)
+
+.PHONY: all run compile clean sync
+
+$(BUILD):
+ @mkdir -p $@
+
+%.img: $(BUILD)
+ @dd if=/dev/zero of=$@ bs=1k count=32k status=none
+ @DEV=$$($(SU) losetup --find --partscan --show $@) && \
+ PART="p1" && \
+ $(SU) parted -s "$$DEV" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on && \
+ echo Formatting... && \
+ $(SU) losetup -d "$$DEV"
diff --git a/src/create.c b/src/create.c
new file mode 100644
index 0000000..e0653bc
--- /dev/null
+++ b/src/create.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ printf("AAH\n");
+ return 0;
+}