summaryrefslogtreecommitdiff
path: root/kernel/build.sh
diff options
context:
space:
mode:
authornatrixaeria <upezu@student.kit.edu>2019-10-24 17:46:14 +0200
committernatrixaeria <upezu@student.kit.edu>2019-10-24 17:46:14 +0200
commit1b498e82be8e54a064743d389d371496f8d6bb5f (patch)
tree4af0aaf564a550f09d8d99b52289ecceaa94e37a /kernel/build.sh
parent2106724907a306897fe846a0efabed09c8850bce (diff)
Add init and clean option to build script
Diffstat (limited to 'kernel/build.sh')
-rwxr-xr-xkernel/build.sh27
1 files changed, 26 insertions, 1 deletions
diff --git a/kernel/build.sh b/kernel/build.sh
index 069180b..7986ee1 100755
--- a/kernel/build.sh
+++ b/kernel/build.sh
@@ -1,16 +1,36 @@
#!/usr/bin/sh
+remove_target() {
+ rm -rf target &> /dev/null
+}
+
+create_target() {
+ mkdir target &> /dev/null
+ mkdir target/temp &> /dev/null
+}
+
cleanup_temp() {
- rm -f target/temp/* 2>&1 > /dev/null
+ rm -f target/temp/* &> /dev/null
}
+# ---------------------------------------------------
+
build_kernel() {
+ create_target
nasm -felf64 multiboot_header.asm -o target/temp/multiboot_header.o
nasm -felf64 boot.asm -o target/temp/boot.o
ld -n -o target/kernel.bin -T linker.ld target/temp/*.o
cleanup_temp
}
+build_init() {
+ create_target
+}
+
+build_clean() {
+ remove_target
+}
+
build_all() {
build_kernel
}
@@ -20,6 +40,8 @@ not_exec=true
for arg in "$@"; do
case "$arg" in
"kernel") build_kernel;;
+ "init") build_init;;
+ "clean") build_clean;;
"all") build_all;;
*)
echo "warn: ignoring unknown option '$arg'"
@@ -32,6 +54,9 @@ done
print_help() {
echo "usage: $0 option"
echo "options: "
+ echo " init initialise directory"
+ echo " clean cleanup binaries"
+ echo
echo " kernel build the kernel"
echo " all build kernel"
}