aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 31 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8576e6f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,31 @@
+ARCH = arm-none-eabi
+CC = $(ARCH)-gcc
+CFLAGS = -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -std=c23 -g -O0 -ffreestanding -Wpedantic -Wall -Wextra -Werror
+LDFLAGS = -Tlink.ld -nostdlib
+
+SRCDIR = src
+BUILDDIR = build
+SRCS_C = $(wildcard src/*.c)
+SRCS_S = $(wildcard src/*.s)
+SRCS = $(SRCS_C) $(SRCS_S)
+OBJS = $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%.o,$(basename $(SRCS)))
+EXEC = $(BUILDDIR)/nanji
+
+all: $(BUILDDIR) $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) $^ -o $@
+
+$(BUILDDIR)/%.o: $(SRCDIR)/%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+$(BUILDDIR)/%.o: $(SRCDIR)/%.s
+ $(CC) $(CFLAGS) -c $< -o $@
+
+$(BUILDDIR):
+ mkdir -p $@
+
+clean:
+ rm -rf $(BUILDDIR)
+
+.PHONY: clean