-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
48 lines (40 loc) · 1.23 KB
/
Copy pathbuild.sh
File metadata and controls
48 lines (40 loc) · 1.23 KB
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
45
46
47
48
#!/bin/bash
set -e
echo "--- Starting REAL OS Build Process ---"
# Cleanup
echo "Cleaning old build files..."
rm -rf isodir myos.bin myos.iso *.o
# Autodetect compiler
if command -v i686-elf-gcc &> /dev/null; then
CC="i686-elf-gcc"
AS="i686-elf-as"
else
echo "Warning: i686-elf-gcc not found, attempting host gcc with -m32"
CC="gcc -m32"
AS="as --32"
fi
# 1. Assemble boot.s
echo "[1/4] Assembling boot.s..."
$AS boot.s -o boot.o
# 2. Compile Kernel
echo "[2/4] Compiling kernel.c..."
$CC -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
# 3. Link objects
echo "[3/4] Linking objects into kernel binary..."
$CC -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc
# 4. Create ISO
echo "[4/4] Packaging ISO..."
mkdir -p isodir/boot/grub
cp myos.bin isodir/boot/myos.bin
cat > isodir/boot/grub/grub.cfg << EOF
menuentry "OS-Studio MyOS" {
multiboot /boot/myos.bin
}
EOF
if command -v grub-mkrescue &> /dev/null; then
grub-mkrescue -o myos.iso isodir
echo "--- Build Finished Successfully! Created myos.iso ---"
else
echo "Warning: grub-mkrescue not found (install mtools and xorriso). Continuing without ISO."
echo "--- Build Finished Successfully! Created myos.bin ---"
fi