aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-01-31 23:24:42 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-01-31 23:24:42 +0200
commit950f164a2eb851dbab0aacb44334f0b687d123e8 (patch)
treea31c6e3140de2b208eca99e82535d740e9ca4039
parentInitial commit (diff)
downloadkernel.cpp-950f164a2eb851dbab0aacb44334f0b687d123e8.tar.xz
libk: add its own makefile
-rw-r--r--.gitignore1
-rw-r--r--libk/makefile11
-rw-r--r--libk/stdlib.h (renamed from stdlib/stdlib.h)0
-rw-r--r--libk/stdlib/console.cc (renamed from stdlib/stdlib/console.cc)0
-rw-r--r--libk/string.cc (renamed from stdlib/string.cc)0
-rw-r--r--libk/string.h (renamed from stdlib/string.h)0
-rw-r--r--libk/types.h (renamed from stdlib/types.h)0
-rw-r--r--makefile35
-rw-r--r--readme.md5
9 files changed, 37 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 8deeab7..8bfb596 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.o
+*.a
*.bin
diff --git a/libk/makefile b/libk/makefile
new file mode 100644
index 0000000..faf5b79
--- /dev/null
+++ b/libk/makefile
@@ -0,0 +1,11 @@
+
+CXX_OBJ := string.o stdlib/console.o
+
+libk.a: $(CXX_OBJ)
+ $(AR) rcs $@ $(CXX_OBJ)
+
+$(CXX_OBJ): %.o : %.cc
+ $(CXX) -target $(TARGET) $(CXX_FLAGS) -I$(CURDIR) -c $^ -o $@
+
+clean:
+ rm libk.a $(CXX_OBJ)
diff --git a/stdlib/stdlib.h b/libk/stdlib.h
index 3e6619d..3e6619d 100644
--- a/stdlib/stdlib.h
+++ b/libk/stdlib.h
diff --git a/stdlib/stdlib/console.cc b/libk/stdlib/console.cc
index dbc9b86..dbc9b86 100644
--- a/stdlib/stdlib/console.cc
+++ b/libk/stdlib/console.cc
diff --git a/stdlib/string.cc b/libk/string.cc
index 5cd4bb2..5cd4bb2 100644
--- a/stdlib/string.cc
+++ b/libk/string.cc
diff --git a/stdlib/string.h b/libk/string.h
index deb6fde..deb6fde 100644
--- a/stdlib/string.h
+++ b/libk/string.h
diff --git a/stdlib/types.h b/libk/types.h
index 0818342..0818342 100644
--- a/stdlib/types.h
+++ b/libk/types.h
diff --git a/makefile b/makefile
index 82e3bba..10cfacf 100644
--- a/makefile
+++ b/makefile
@@ -3,39 +3,46 @@
# ?= only set if it doesn't have a value
# != execute a shell script on the right-hand side and assign its result to the left-hand side
-TARGET := i686-elf
+export TARGET := i686-elf
-NASM := nasm
-CXX := clang++
-CXXFLAGS := -std=c++20 -ffreestanding -nostdinc -fno-exceptions -fno-rtti -Wall -Wextra -O2
-INCLUDE := stdlib
-
-OBJ := kernel.o vga.o stdlib/string.o stdlib/stdlib/console.o
+export AR := llvm-ar
+export NASM := nasm
+export LD := ld.lld
+export CXX := clang++
+export CXX_FLAGS := -std=c++20 -ffreestanding -nostdinc -fno-exceptions -fno-rtti -Wall -Wextra -O2
+CXX_INCLUDE := libk
+CXX_OBJ := kernel.o vga.o
# $@ is target
# $< is first dependency
# $^ is all dependencies
-default: boot.o $(OBJ)
- ld.lld -T linker.ld -o myos.bin boot.o $(OBJ)
+default: myos.bin
+
+myos.bin: boot.o $(CXX_OBJ) libk/libk.a
+ $(LD) -T linker.ld -o myos.bin boot.o $(CXX_OBJ) -Llibk -lk
boot.o: boot.asm
$(NASM) -felf32 -o $@ $^
-$(OBJ): %.o : %.cc
- $(CXX) -target $(TARGET) $(CXXFLAGS) -I$(INCLUDE) -c $^ -o $@
+$(CXX_OBJ): %.o : %.cc
+ $(CXX) -target $(TARGET) $(CXX_FLAGS) -I$(CXX_INCLUDE) -c $^ -o $@
+
+libk/libk.a:
+ $(MAKE) -C libk libk.a
-iso:
+iso: myos.bin
mkdir -p isodir/boot/grub
cp myos.bin isodir/boot/myos.bin
cp grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o myos.iso isodir
-run:
+run: myos.bin
qemu-system-i386 -kernel myos.bin
clean:
- rm boot.o $(OBJ) myos.bin
+ rm boot.o $(CXX_OBJ) myos.bin
+ $(MAKE) -C libk clean
clean-iso:
rm -rf isodir
diff --git a/readme.md b/readme.md
index 5e5bbdc..72aed4c 100644
--- a/readme.md
+++ b/readme.md
@@ -1,7 +1,10 @@
## Compiling
- gnu make
-- llvm/clang++
+- llvm/clang (llvm-ar, clang++, ld.lld)
- nasm
- grub
- qemu
+
+## running
+- make run