A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
eOS/Makefile

68 lines
1.4 KiB

# Compiler/assembler settings
# C
CC = gcc
CFLAGS = -fno-pie -m32 -Os -ffreestanding
# Rust
RC = rustc
# WARN: target might not exist on your machine. Just swap it out to whatever 32bit target that you have.
RFLAGS = --emit=obj --target i686-unknown-linux-gnu
# Assembly
AA = nasm
AFLAGS =
# Linking
LD = gcc
LDFLAGS = -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
# VM/Debug settings
VM = qemu-system-x86_64
VMFLAGS =
# Do not touch these.
C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h)
R_SOURCES = $(wildcard kernel/*.rs drivers/*.rs lib/*.rs)
OBJ = $(C_SOURCES:.c=.o)
ROBJ = $(R_SOURCES:.rs=.o)
all: eos.iso
run: all
$(VM) $(VMFLAGS) eos.iso
drun: clean run
grub: eos_grub.iso
$(VM) $(VMFLAGS) eos_grub.iso
eos_grub.iso : kernel.bin grub/grub.cfg
mkdir -p boot/grub
cp $< boot/eOS.bin
cp grub/grub.cfg boot/grub/grub.cfg
grub-mkrescue -o eos_grub.iso ./
eos.iso: bootloader/bootloader.bin kernel.bin
cat $^ > eos.iso
kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ) $(ROBJ)
$(LD) -o $@ $^ $(LDFLAGS)
%.o : %.c ${HEADERS}
$(CC) $(CFLAGS) -c $< -o $@
%.o : %.rs
$(RC) $(RFLAGS) $< -o $@
%.o : %.asm
$(AA) $< -f elf -o $@ $(AFLAGS)
%.bin : %.asm
$(AA) $< -f bin -o $@ $(AFLAGS)
clean:
rm -rf *.bin *.dis *.o eos.iso *.map boot/ *.iso
rm -rf kernel/*.o bootloader/*.bin drivers/*.o