summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2025-01-12 01:17:36 -0600
committerDanny Holman <dholman@gymli.org>2025-01-12 01:19:11 -0600
commit95cd78840f0891e60f5ebecc8a8eb4fbaf3c2ebf (patch)
treec8c35347b50477929727fa5be9f5d0f55cbe18fd /Makefile
parent5e166f3042a8e7b3031aae4da7006f80caa53ecc (diff)
PROJECT RESTRUCTURING
Move the entire kernel into its own directory. Create new directories for system commands, libraries and other required essentials for a complete Unix-like operating system. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile116
1 files changed, 18 insertions, 98 deletions
diff --git a/Makefile b/Makefile
index 5525936..50d1fc5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,110 +1,30 @@
-INCLUDE?=-Iinclude
-CFLAGS?=-O0 -ffreestanding -std=gnu11
-LDFLAGS?=-nostdlib
-LIBS?=-lgcc
-ARCH?=i386
+ARCH?=x86
+DESTDIR?=base-system
+PREFIX?=/usr
# -- Do not edit below this line --
-CC:=i686-elf-gcc
VERSION:="$(shell git describe --abbrev=4 --dirty --always --tags)"
-INCLUDE:=$(INCLUDE)
-CFLAGS:=$(CFLAGS) -Wall -Wextra -DVERSION=\"$(VERSION)\" -ggdb -fstack-protector-all
-LDFLAGS:=$(LDFLAGS)
-LIBS:=$(LIBS)
ARCH:=$(ARCH)
+DESTDIR:=base-system/
+PREFIX:=/usr/
+export ARCH VERSION PREFIX
-ARCHDIR=arch/$(ARCH)
+SUBDIRS:=kernel \
+ bin \
+ lib \
+ sbin \
+ usr.sbin \
-include $(ARCHDIR)/make.config
+.PHONY: all clean install install-headers $(SUBDIRS)
-CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS)
-LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)
-LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)
+all: $(SUBDIRS)
-KERNEL=vmbox
+subdirs: $(SUBDIRS)
-LIBK_OBJS=libk/string.o \
- libk/io.o \
- libk/stack_protector.o \
- libk/ubsan.o \
+$(SUBDIRS):
+ $(MAKE) $(MAKECMDGOALS) -C $@
-KERNEL_OBJS=$(KERNEL_ARCH_OBJS) \
- kernel/init.o \
- kernel/panic.o \
- kernel/vfs.o \
- kernel/sched.o \
- kernel/kthread.o \
+clean: $(SUBDIRS)
-DRIVER_OBJS=drivers/video/framebuffer.o \
- drivers/input/keyboard.o \
- drivers/pci/pci.o \
- drivers/pci/ide.o \
- drivers/tty/tty_vga.o \
-
-OBJS=$(ARCHDIR)/boot/crti.o \
- $(ARCHDIR)/crtbegin.o \
- $(KERNEL_OBJS) \
- $(DRIVER_OBJS) \
- $(LIBK_OBJS) \
- $(ARCHDIR)/crtend.o \
- $(ARCHDIR)/boot/crtn.o \
-
-LINK_LIST=$(LDFLAGS) \
- $(KERNEL_OBJS) \
- $(DRIVER_OBJS) \
- $(LIBK_OBJS) \
- $(LIBS) \
-
-.PHONY: all clean install install-headers install-kernel
-.SUFFIXES: .o .c .s
-
-all: $(KERNEL)
-
-$(KERNEL): $(OBJS) $(ARCHDIR)/linker.ld
- @$(CC) -T $(ARCHDIR)/linker.ld -o $@ $(LINK_LIST)
- @echo [LD] $@
-
-$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
- @OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@
-
-.c.o:
- @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE)
- @echo [CC] $@
-
-.s.o:
- @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE)
- @echo [AS] $@
-
-clean:
- $(RM) $(KERNEL)
- $(RM) $(OBJS) *.o */*.o */*/*.o
- $(RM) $(OBJS:.o=.d) *.d */*.d */*/*.d
-
-install: install-headers install-kernel
-
-install-headers:
- mkdir -p $(DESTDIR)$(INCLUDEDIR)
- cp -R --preserve-timestamps include/. $(DESTDIR)$(INCLUDEDIR)/.
-
-install-kernel: $(KERNEL)
- mkdir -p $(DESTDIR)$(BOOTDIR)
- cp $(KERNEL) $(DESTDIR)$(BOOTDIR)
-
-install-disk: $(KERNEL)
- rm a.img
- bximage -q -func=create -fd=1.44M a.img
- mkdosfs a.img
- syslinux -i a.img
- mcopy -i a.img img/libcom32.c32 ::libcom32.c32
- mcopy -i a.img img/mboot.c32 ::mboot.c32
- mcopy -i a.img img/syslinux.cfg ::syslinux.cfg
- mcopy -i a.img vmbox ::vmbox
-
-run: $(KERNEL)
- qemu-system-i386 -kernel $(KERNEL) -serial stdio -m 1G -drive file=a.img,format=raw -append "root=/dev/sda init=/bin/sh"
-
-debug: $(KERNEL)
- qemu-system-i386 -kernel $(KERNEL) -s -S -m 1G -drive file=a.img,format=raw -append "root=/dev/sda init=/bin/sh" &
-
--include $(OBJS:.o=.d)
+install: $(SUBDIRS)