111 lines
2.5 KiB
Makefile
111 lines
2.5 KiB
Makefile
# Define the object files
|
|
OBJS = bin/boot.o bin/kernel.o bin/idt.o bin/isr.o bin/screen.o bin/utils.o bin/string.o bin/stdio.o bin/disk.o bin/pic.o bin/pit.o bin/keyboard.o bin/paging.o bin/fat.o bin/task.o bin/switch.o
|
|
|
|
# Define the compiler and assembler
|
|
CC = gcc -D__is_katauos
|
|
AS = nasm
|
|
|
|
# Define the compiler flags
|
|
CFLAGS = -std=gnu99 -ffreestanding -O0 -Wall -Wextra -m32 -g
|
|
ASFLAGS = -f elf32
|
|
|
|
# Define the linker flags
|
|
LDFLAGS = -ffreestanding -O0 -nostdlib -m32 -g -lgcc
|
|
LDSCRIPT = link.ld
|
|
|
|
# Define the output file
|
|
OUTPUT = myos.bin
|
|
|
|
all: $(OUTPUT)
|
|
|
|
create-image:
|
|
cp myos.bin grubshit/boot/
|
|
dd if=/dev/zero of=boot.iso bs=1M count=256
|
|
parted boot.iso --script mklabel msdos
|
|
parted boot.iso --script mkpart primary fat32 1MiB 100%
|
|
sudo losetup /dev/loop0 boot.iso
|
|
sudo losetup /dev/loop1 boot.iso -o 1048576
|
|
#sudo mkdosfs -F32 -f 2 /dev/loop1
|
|
sudo mkfs.vfat -F32 -f 2 /dev/loop1
|
|
sudo mount /dev/loop1 /mnt
|
|
sudo grub-install --root-directory=/mnt --no-floppy --modules="normal part_msdos ext2 multiboot biosdisk" /dev/loop0 #there was biosdev also
|
|
sudo cp -r grubshit/* /mnt/
|
|
sync
|
|
sudo umount /mnt
|
|
sudo losetup -D
|
|
|
|
image:
|
|
cp myos.bin grubshit/boot
|
|
sudo losetup /dev/loop0 boot.iso
|
|
sudo losetup /dev/loop1 boot.iso -o 1048576
|
|
sudo mount /dev/loop1 /mnt
|
|
sudo cp -r grubshit/* /mnt/
|
|
sync
|
|
sudo umount /mnt
|
|
sudo losetup -D
|
|
|
|
test:
|
|
qemu-system-i386 -drive file=boot.iso,media=disk,format=raw -m 512M -d int
|
|
#qemu-system-i386 -s -S -kernel myos.bin
|
|
|
|
test-bochs:
|
|
bochs -f bochsrc
|
|
|
|
$(OUTPUT): $(OBJS)
|
|
$(CC) -T $(LDSCRIPT) -o $@ $(OBJS) $(LDFLAGS)
|
|
|
|
bin/boot.o: src/boot.asm
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
bin/kernel.o: src/kernel.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/screen.o: src/screen.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/isr.o: src/isr.c
|
|
$(CC) $(CFLAGS) -mgeneral-regs-only -c $< -o $@
|
|
|
|
bin/idt.o: src/idt.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/utils.o: src/utils.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/string.o: src/string.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/stdio.o: src/stdio.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/disk.o: src/disk.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/pic.o: src/pic.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/pit.o: src/pit.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/keyboard.o: src/keyboard.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/paging.o: src/paging.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/fat.o: src/fat.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
bin/switch.o: src/switch.asm
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
bin/task.o: src/task.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
rm -rf bin/
|
|
rm -f $(OUTPUT)
|
|
rm boot.iso
|
|
|
|
.PHONY: all clean
|