init commit

This commit is contained in:
Faynot
2026-07-07 20:35:07 +03:00
commit 38cc34a6e9
33 changed files with 659 additions and 0 deletions

40
Makefile Normal file
View File

@@ -0,0 +1,40 @@
CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
CFLAGS ?= -Os -fno-builtin -ffreestanding -nostdinc
LDFLAGS ?= -nostdlib -static
-include config.mak
ARCH ?= x86_64
CFLAGS += -I. -I include
SRC_DIRS = src/string src/stdio src/stdlib src/internal
OBJ_DIR = obj
LIB_DIR = lib
SRCS := $(shell find $(SRC_DIRS) -name '*.c' 2>/dev/null)
OBJS := $(SRCS:%=$(OBJ_DIR)/%.o)
CRT_OBJ := crt/crt1.o
.PHONY: all clean distclean
all: $(LIB_DIR)/libc.a $(CRT_OBJ)
$(OBJ_DIR)/%.c.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
$(LIB_DIR)/libc.a: $(OBJS)
@mkdir -p $(LIB_DIR)
$(AR) crs $@ $^
$(RANLIB) $@
crt/crt1.o: crt/crt1.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(OBJ_DIR) $(LIB_DIR)
distclean: clean
rm -f config.mak