summaryrefslogtreecommitdiff
path: root/kernel/build.sh
blob: 069180be0f82013fdcfca1d1c932c23e94d216fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/sh

cleanup_temp() {
    rm -f target/temp/* 2>&1 > /dev/null
}

build_kernel() {
    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_all() {
    build_kernel
}

not_exec=true

for arg in "$@"; do
    case "$arg" in
        "kernel") build_kernel;;
        "all") build_all;;
        *)
            echo "warn: ignoring unknown option '$arg'"
            continue;;
    esac
    not_exec=false
    break
done

print_help() {
    echo "usage: $0 option"
    echo "options: "
    echo "  kernel        build the kernel"
    echo "  all           build kernel"
}

if $not_exec; then
    echo "error: please specify an argument"
    echo
    print_help
    exit -1
fi