os/Makefile

46 lines
1.2 KiB
Makefile
Raw Normal View History

2019-02-09 12:52:45 -06:00
PLAT=i386
2019-03-30 11:44:01 -05:00
C_SOURCES = $(wildcard kernel/*.c drivers/$(PLAT)/*.c drivers/$(PLAT)/*/*.c cpu/$(PLAT)/*.c fs/*.c)
LIBC_SOURCES = $(wildcard libc/*.c libc/*/*.c)
2019-02-09 12:52:45 -06:00
OBJ = $(C_SOURCES:.c=.o $(shell cat psinfo/$(PLAT)/o.txt))
2019-03-30 11:44:01 -05:00
LIBC_OBJ = $(LIBC_SOURCES:.c=.o)
2019-02-09 12:52:45 -06:00
CC = $(shell cat psinfo/$(PLAT)/cc.txt)
GDB = $(shell cat psinfo/$(PLAT)/gdb.txt)
2019-03-11 09:32:55 -05:00
CFLAGS = -Ilibc -Wextra -Wall -Wno-unused-parameter -g -ffreestanding
2019-02-09 12:52:45 -06:00
QFLAGS = -m 2G -boot d -cdrom os.iso -serial vc #-chardev socket,id=s1,port=3000,host=localhost -serial chardev:s1
all: os.iso
run: os.iso
qemu-system-i386 $(QFLAGS) -monitor stdio
debug: os.iso kernel/kernel.elf
qemu-system-i386 -s $(QFLAGS) &
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
2019-03-17 18:04:50 -05:00
os.iso: kernel/kernel.elf initrd/* initrd/prog.elf
2019-02-09 12:52:45 -06:00
cp kernel/kernel.elf iso/boot
ruby makeinitrd.rb initrd iso/boot/initrd
grub-mkrescue -o $@ iso
2019-03-17 18:04:50 -05:00
initrd/prog.elf: prog/*
cd prog && make
cp prog/prog.elf initrd
2019-03-30 11:44:01 -05:00
kernel/kernel.elf: $(OBJ) libc/libc.a
2019-02-09 12:52:45 -06:00
i386-elf-ld -T linker.ld -o $@ $^
2019-03-30 11:44:01 -05:00
libc/libc.a: $(LIBC_OBJ)
i386-elf-ar rcs $@ $^
2019-03-17 12:22:00 -05:00
%.o: %.c
2019-02-09 12:52:45 -06:00
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.asm
nasm $< -f elf -o $@
%.o: %.s
i386-elf-as $< -o $@
clean:
2019-03-30 11:44:01 -05:00
rm -rf $(OBJ) libc/libc.a kernel/cstart.o cpu/memory.h os.iso */*.elf iso/boot/initrd.tar