os/Makefile

68 lines
1.9 KiB
Makefile
Raw Normal View History

2019-05-25 10:35:31 -05:00
PLAT=i386
C_SOURCES = $(wildcard kernel/*.c drivers/$(PLAT)/*.c drivers/$(PLAT)/*/*.c kernel/cpu/$(PLAT)/*.c fs/*.c)
ASM = $(wildcard kernel/cpu/$(PLAT)/*.asm)
S_ASM = $(wildcard kernel/cpu/$(PLAT)/*.s)
LIBC_SOURCES = $(wildcard libc/*.c libc/*/*.c)
LIBC_HEADERS = $(wildcard libc/*.h libc/*/*.h)
OBJ = $(C_SOURCES:.c=.o kernel/cpu/$(PLAT)/boot.o)
ASM_OBJ = $(S_ASM:.s=.o)
S_ASM_OBJ = $(ASM:.asm=.o)
LIBC_OBJ = $(LIBC_SOURCES:.c=.o)
CC = $(shell cat psinfo/$(PLAT)/cc.txt)
AS = $(shell cat psinfo/$(PLAT)/as.txt)
AR = $(shell cat psinfo/$(PLAT)/ar.txt)
NASM = $(shell cat psinfo/$(PLAT)/nasm.txt)
2019-04-22 08:39:46 -05:00
EMU = $(shell cat psinfo/$(PLAT)/emu.txt)
2019-02-09 12:52:45 -06:00
GDB = $(shell cat psinfo/$(PLAT)/gdb.txt)
2019-05-25 10:35:31 -05:00
CFLAGS = -Isysroot/usr/include -Wextra -Wall -Wno-unused-parameter -g -ffreestanding
2019-05-01 09:39:23 -05:00
QFLAGS = -hda ext2.img -m 2G -boot d -cdrom os.iso -serial vc #-chardev socket,id=s1,port=3000,host=localhost -serial chardev:s1
CWD = $(shell pwd)
2019-02-09 12:52:45 -06:00
2019-03-31 13:10:40 -05:00
.PHONY: sysroot
2019-02-09 12:52:45 -06:00
all: os.iso
run: os.iso
@$(EMU) $(QFLAGS) -monitor stdio
2019-02-09 12:52:45 -06:00
2019-05-25 10:35:31 -05:00
debug: os.iso kernel/kernel.elf
@$(EMU) -s $(QFLAGS) &
@$(GDB)
# gdbgui -g i386-elf-gdb --project $(CWD)
2019-02-09 12:52:45 -06:00
os.iso: kernel/kernel.elf init vfs fsdrv initrd/*
@cp kernel/kernel.elf iso/boot
2019-05-23 17:38:26 -05:00
@cd initrd; tar -f ../iso/boot/initrd.tar -c *
2019-07-01 15:30:00 -05:00
@grub-mkrescue -o $@ iso >/dev/null 2>/dev/null
2019-02-09 12:52:45 -06:00
2019-06-22 15:29:02 -05:00
init: init/* kernel/start.o
@cd $@ && make
@cp $@/$@ initrd/$@
2019-03-17 18:04:50 -05:00
2019-06-22 15:29:02 -05:00
vfs: vfs/* kernel/start.o
@cd $@ && make
@cp $@/$@ initrd/$@
fsdrv: fsdrv/* kernel/start.o
@cd $@ && make
@cp $@/$@ initrd/$@
2019-06-22 10:31:33 -05:00
2019-05-25 10:35:31 -05:00
kernel/kernel.elf: $(OBJ) $(ASM_OBJ) $(S_ASM_OBJ) libc/libc.a
@$(CC) -z max-page-size=4096 -Xlinker -n -T kernel/cpu/$(PLAT)/linker.ld -o $@ $(CFLAGS) -nostdlib $^ -lgcc
2019-02-09 12:52:45 -06:00
2019-05-25 10:35:31 -05:00
libc/libc.a: $(LIBC_OBJ)
@$(AR) rcs $@ $^
2019-05-25 10:35:31 -05:00
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
2019-05-25 10:35:31 -05:00
%.o: %.asm
@$(NASM) $< -o $@
%.o: %.s
@$(AS) $< -o $@
2019-02-09 12:52:45 -06:00
clean:
2019-05-25 10:35:31 -05:00
@rm -rf kernel/*.o drivers/*/*.o drivers/*/*/*.o cpu/*/*.o fs/*.o libc/libc.a kernel/cstart.o cpu/memory.h os.iso */*.elf iso/boot/initrd.tar