From 1b498e82be8e54a064743d389d371496f8d6bb5f Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Thu, 24 Oct 2019 17:46:14 +0200 Subject: Add init and clean option to build script --- kernel/build.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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" } -- cgit v1.2.3-54-g00ecf From 327aa4c75f6f0b788398eb33294454c65823631c Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Thu, 24 Oct 2019 18:05:17 +0200 Subject: Add build kernel-iso option to build script --- kernel/build.sh | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/kernel/build.sh b/kernel/build.sh index 7986ee1..f47a5b6 100755 --- a/kernel/build.sh +++ b/kernel/build.sh @@ -1,28 +1,44 @@ #!/usr/bin/sh +ASM_PATH="./" +TARGET_PATH="target/" +TMP_PATH="$TARGET_PATH/temp/" +OBJ_PATH="$TMP_PATH" +LINK_SCRIPT_PATH="./" + remove_target() { - rm -rf target &> /dev/null + rm -rf $TARGET_PATH &> /dev/null } create_target() { - mkdir target &> /dev/null - mkdir target/temp &> /dev/null + mkdir $TARGET_PATH &> /dev/null + mkdir $TMP_PATH &> /dev/null } cleanup_temp() { - rm -f target/temp/* &> /dev/null + rm -f $TMP_PATH/* &> /dev/null } # --------------------------------------------------- -build_kernel() { +build_kernel_elf() { 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 + nasm -felf64 $ASM_PATH/multiboot_header.asm -o $OBJ_PATH/multiboot_header.o + nasm -felf64 $ASM_PATH/boot.asm -o $OBJ_PATH/boot.o + ld -n -o $TARGET_PATH/kernel.bin -T $LINK_SCRIPT_PATH/linker.ld $OBJ_PATH/*.o cleanup_temp } +build_kernel_iso_from_elf() { + create_target + echo NIY: build kernel from elf +} + +build_kernel_iso() { + build_kernel_elf + build_kernel_iso_from_elf +} + build_init() { create_target } @@ -39,7 +55,9 @@ not_exec=true for arg in "$@"; do case "$arg" in - "kernel") build_kernel;; + "kernel-elf") build_kernel_elf;; + "kernel-iso-from-elf") build_kernel_iso_from_elf;; + "kernel-iso") build_kernel_iso;; "init") build_init;; "clean") build_clean;; "all") build_all;; @@ -54,11 +72,13 @@ done print_help() { echo "usage: $0 option" echo "options: " - echo " init initialise directory" - echo " clean cleanup binaries" + echo " init initialise directory" + echo " clean cleanup binaries" echo - echo " kernel build the kernel" - echo " all build kernel" + echo " kernel-elf build the kernel-elf" + echo " kernel-iso-from-elf build the kernel-iso from an existing kernel-elf" + echo " kernel-iso build the kernel-elf and the kernel-iso" + echo " all build kernel" } if $not_exec; then -- cgit v1.2.3-54-g00ecf