summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2021-12-12 12:10:39 -0500
committerJon Santmyer <jon@jonsantmyer.com>2021-12-12 12:10:39 -0500
commit63a5f312b06143951a49faad190d1ab2fd37fcc5 (patch)
tree82296930087bf6ea96a00a13b601dfe32c1e826a
parentc4f27dbf1d2a257e08087e9a1ce932579f9dc72f (diff)
downloadmodit-kernel-63a5f312b06143951a49faad190d1ab2fd37fcc5.tar.gz
modit-kernel-63a5f312b06143951a49faad190d1ab2fd37fcc5.tar.bz2
modit-kernel-63a5f312b06143951a49faad190d1ab2fd37fcc5.zip
revamped build system; each module has makefile, no more shell nonsense
-rw-r--r--Makefile40
-rwxr-xr-xmakemods.sh31
-rw-r--r--src/arch_common/init/Makefile24
-rw-r--r--src/arch_common/initrd/Makefile24
-rw-r--r--src/arch_common/klibc/Makefile24
-rw-r--r--src/arch_common/serialtxt/Makefile24
-rw-r--r--src/arch_common/vgatxt/Makefile24
-rw-r--r--src/arch_x86/64/apic/Makefile24
-rw-r--r--src/arch_x86/64/gdt/Makefile24
-rw-r--r--src/arch_x86/64/interrupt/Makefile24
-rw-r--r--src/arch_x86/64/pmmbitmap/Makefile24
-rw-r--r--src/arch_x86/64/pmmstack/Makefile24
-rw-r--r--src/arch_x86/64/syscall/Makefile24
-rw-r--r--src/arch_x86/64/task/Makefile24
-rw-r--r--src/arch_x86/64/tlb/Makefile24
-rw-r--r--src/arch_x86/64/user/Makefile24
-rw-r--r--src/arch_x86/common/acpi/Makefile24
-rw-r--r--src/arch_x86/common/cpu/Makefile24
-rw-r--r--src/arch_x86/common/heap/Makefile24
-rw-r--r--src/arch_x86/common/klibc/Makefile24
-rw-r--r--src/arch_x86/common/panic/Makefile24
-rw-r--r--src/arch_x86/common/pic/Makefile24
-rw-r--r--src/arch_x86/common/pit/Makefile24
-rw-r--r--src/arch_x86/common/stivale2/Makefile24
-rw-r--r--src/arch_x86/common/syscall/Makefile24
-rw-r--r--src/arch_x86/common/timer/Makefile24
26 files changed, 593 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index 02bb3b0..43aabff 100644
--- a/Makefile
+++ b/Makefile
@@ -10,20 +10,20 @@ ifndef LOGLEVEL
endif
#Files
+PWD := $(shell pwd)
+
CORESRC := src/arch_$(ARCH)/common/main.c
COREOBJ := $(patsubst %.c,%.o,$(CORESRC))
-#include modules.mk
-MODOBJS := $(patsubst %.c,%.o,$(wildcard src/arch_$(ARCH)/common/*/*.c))
-MODOBJS += $(patsubst %.s,%.o,$(wildcard src/arch_$(ARCH)/common/*/*.s))
+SRCPATHS := src/arch_$(ARCH)/$(BITS)
+SRCPATHS += src/arch_$(ARCH)/common
+SRCPATHS += src/arch_common
-MODOBJS += $(patsubst %.c,%.o,$(wildcard src/arch_$(ARCH)/$(BITS)/*/*.c))
-MODOBJS += $(patsubst %.s,%.o,$(wildcard src/arch_$(ARCH)/$(BITS)/*/*.s))
+FINDMOD = $(foreach path,$(SRCPATHS),$(wildcard $(path)/$(mod)/))
-MODOBJS += $(patsubst %.c,%.o,$(wildcard src/arch_common/*/*.c))
-MODOBJS += $(patsubst %.s,%.o,$(wildcard src/arch_common/*/*.s))
+MODDIRS := $(foreach mod,$(MODORDER),$(FINDMOD))
-#MODLIBS := $(patsubst %,%.a,$(MODORDER))
+MODS := $(patsubst %/,%.a,$(MODDIRS))
LINK ?= src/arch_$(ARCH)/$(BITS)/linker.ld
#Tools
@@ -32,7 +32,7 @@ LD ?= ld
AS ?= as
WARNS := -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -Wnull-dereference -Wdouble-promotion -Wshadow -Wcast-align
-INCLUDE := -Iinclude/arch_$(ARCH)/common -Iinclude/arch_$(ARCH)/$(BITS) -Iinclude/arch_common/
+INCLUDE := -I$(PWD)/include/arch_$(ARCH)/common -I$(PWD)/include/arch_$(ARCH)/$(BITS) -I$(PWD)/include/arch_common/
DEFINES := -DARCH_$(ARCH) -DBITS_$(BITS) -DLOGLEVEL=$(LOGLEVEL)
CFLAGS := -ffreestanding -nostdlib -fno-stack-protector $(INCLUDE) $(WARNS) -fno-pic -fpie -fomit-frame-pointer -mno-red-zone -mgeneral-regs-only $(DEFINES) -g
LDFLAGS := -T$(LINK) -nostdlib -pie -static-pie -fno-pic -fpie -z max-page-size=0x1000 -Wl,--whole-archive
@@ -40,22 +40,14 @@ LDFLAGS := -T$(LINK) -nostdlib -pie -static-pie -fno-pic -fpie -z max-page-size=
#Logic
.PHONY: build
-build: $(COREOBJ) $(MODOBJS) modsordered
- $(CC) $(LDFLAGS) $(shell cat modsordered) $(COREOBJ) -o kernel.elf
- rm modsordered
-
-.PHONY: modsordered
-modsordered: $(MODORDER)
- ./makemods.sh $(MODORDER) $(ARCH) $(BITS) $(AR)
+build: $(COREOBJ) $(MODS)
+ $(CC) $(LDFLAGS) $(MODS) $(COREOBJ) -o kernel.elf
+ #rm modsordered
.PHONY: clean
clean:
rm $(COREOBJ)
- rm src/arch_common/*.o | true
- rm src/arch_common/*.a | true
- rm src/arch_*/*/*.o | true
- rm src/arch_*/*/*/*.o | true
- rm src/arch_*/*/*.a | true
+ rm $(MODS)
%.o:%.c
$(CC) $(CFLAGS) -c $< -o $@
@@ -63,7 +55,9 @@ clean:
%.o:%.s
$(CC) $(CFLAGS) -c $< -o $@
-%.a:%/
- $(AR) rcs $@ $^*.o
+%.a:%/ FORCE
+ @$(MAKE) -C $< CC=$(CC) LD=$(LD) AS=$(AS) AR=$(AR) CFLAGS="$(CFLAGS)"
+
+FORCE:
# vim: set ts=4 sw=4 tw=0 noet :
diff --git a/makemods.sh b/makemods.sh
deleted file mode 100755
index cfb084e..0000000
--- a/makemods.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-#ARCH AR
-LIBORDER=""
-
-MOFILE=$1
-ARCH=$2
-BITS=$3
-AR=$4
-
-compile_lib() {
- #$1 = lib folder
- MODNAME=$(basename -- $1)
- $AR rcs $1.a $1/*.o
- LIBORDER="$LIBORDER $1.a"
-}
-
-for word in `sed '/#/d' $MOFILE`; do
- echo $word
- if [ -d "src/arch_common/$word" ]; then
- compile_lib "src/arch_common/$word"
- fi
- if [ -d "src/arch_$ARCH/common/$word" ]; then
- compile_lib "src/arch_$ARCH/common/$word"
- fi
- if [ -d "src/arch_$ARCH/$BITS/$word" ]; then
- compile_lib "src/arch_$ARCH/$BITS/$word"
- fi
-done
-
-echo $LIBORDER > modsordered
diff --git a/src/arch_common/init/Makefile b/src/arch_common/init/Makefile
new file mode 100644
index 0000000..3c00f91
--- /dev/null
+++ b/src/arch_common/init/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := init
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_common/initrd/Makefile b/src/arch_common/initrd/Makefile
new file mode 100644
index 0000000..0579637
--- /dev/null
+++ b/src/arch_common/initrd/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := initrd
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_common/klibc/Makefile b/src/arch_common/klibc/Makefile
new file mode 100644
index 0000000..83aeed7
--- /dev/null
+++ b/src/arch_common/klibc/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := klibc
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_common/serialtxt/Makefile b/src/arch_common/serialtxt/Makefile
new file mode 100644
index 0000000..84ec13a
--- /dev/null
+++ b/src/arch_common/serialtxt/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := serialtxt
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_common/vgatxt/Makefile b/src/arch_common/vgatxt/Makefile
new file mode 100644
index 0000000..0067393
--- /dev/null
+++ b/src/arch_common/vgatxt/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := vgatxt
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/apic/Makefile b/src/arch_x86/64/apic/Makefile
new file mode 100644
index 0000000..ae18db3
--- /dev/null
+++ b/src/arch_x86/64/apic/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := apic
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/gdt/Makefile b/src/arch_x86/64/gdt/Makefile
new file mode 100644
index 0000000..ffc986d
--- /dev/null
+++ b/src/arch_x86/64/gdt/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := gdt
+
+.PHONY: all
+all: $(OFILES)
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/interrupt/Makefile b/src/arch_x86/64/interrupt/Makefile
new file mode 100644
index 0000000..c004376
--- /dev/null
+++ b/src/arch_x86/64/interrupt/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := interrupt
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/pmmbitmap/Makefile b/src/arch_x86/64/pmmbitmap/Makefile
new file mode 100644
index 0000000..f010abb
--- /dev/null
+++ b/src/arch_x86/64/pmmbitmap/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := pmmbitmap
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/pmmstack/Makefile b/src/arch_x86/64/pmmstack/Makefile
new file mode 100644
index 0000000..6f4f184
--- /dev/null
+++ b/src/arch_x86/64/pmmstack/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := pmmstack
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/syscall/Makefile b/src/arch_x86/64/syscall/Makefile
new file mode 100644
index 0000000..58ac95c
--- /dev/null
+++ b/src/arch_x86/64/syscall/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := syscall
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/task/Makefile b/src/arch_x86/64/task/Makefile
new file mode 100644
index 0000000..b1d7a7e
--- /dev/null
+++ b/src/arch_x86/64/task/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := task
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/tlb/Makefile b/src/arch_x86/64/tlb/Makefile
new file mode 100644
index 0000000..ca6221c
--- /dev/null
+++ b/src/arch_x86/64/tlb/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := tlb
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/64/user/Makefile b/src/arch_x86/64/user/Makefile
new file mode 100644
index 0000000..f7dbf77
--- /dev/null
+++ b/src/arch_x86/64/user/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := user
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/acpi/Makefile b/src/arch_x86/common/acpi/Makefile
new file mode 100644
index 0000000..20e4d68
--- /dev/null
+++ b/src/arch_x86/common/acpi/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := acpi
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/cpu/Makefile b/src/arch_x86/common/cpu/Makefile
new file mode 100644
index 0000000..fdd940e
--- /dev/null
+++ b/src/arch_x86/common/cpu/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := cpu
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/heap/Makefile b/src/arch_x86/common/heap/Makefile
new file mode 100644
index 0000000..5ca143b
--- /dev/null
+++ b/src/arch_x86/common/heap/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := heap
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/klibc/Makefile b/src/arch_x86/common/klibc/Makefile
new file mode 100644
index 0000000..83aeed7
--- /dev/null
+++ b/src/arch_x86/common/klibc/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := klibc
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/panic/Makefile b/src/arch_x86/common/panic/Makefile
new file mode 100644
index 0000000..ce10c29
--- /dev/null
+++ b/src/arch_x86/common/panic/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := panic
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/pic/Makefile b/src/arch_x86/common/pic/Makefile
new file mode 100644
index 0000000..dca05d7
--- /dev/null
+++ b/src/arch_x86/common/pic/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := pic
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/pit/Makefile b/src/arch_x86/common/pit/Makefile
new file mode 100644
index 0000000..1ce793a
--- /dev/null
+++ b/src/arch_x86/common/pit/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := pit
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/stivale2/Makefile b/src/arch_x86/common/stivale2/Makefile
new file mode 100644
index 0000000..c74ca9b
--- /dev/null
+++ b/src/arch_x86/common/stivale2/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := stivale2
+
+.PHONY: all
+all: $(OFILES)
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/syscall/Makefile b/src/arch_x86/common/syscall/Makefile
new file mode 100644
index 0000000..58ac95c
--- /dev/null
+++ b/src/arch_x86/common/syscall/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := syscall
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/src/arch_x86/common/timer/Makefile b/src/arch_x86/common/timer/Makefile
new file mode 100644
index 0000000..1c0643b
--- /dev/null
+++ b/src/arch_x86/common/timer/Makefile
@@ -0,0 +1,24 @@
+CFILES := $(wildcard *.c)
+CFILES += $(wildcard *.s)
+
+OFILES := $(patsubst %.c,%.o,$(CFILES))
+OFILES += $(patsubst %.s,%.o,$(CFILES))
+
+CC ?= cc
+AS ?= as
+AR ?= ar
+LD ?= ld
+
+CFLAGS ?=
+
+OUT := timer
+
+.PHONY: all
+all: ${OFILES}
+ $(AR) -rcs ../$(OUT).a *.o
+
+%.o:%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.o:%.s
+ $(CC) $(CFLAGS) -c $< -o $@