2019-05-25 10:35:31 -05:00
|
|
|
PLAT=i386
|
2020-07-30 21:58:23 -05:00
|
|
|
TIMER_TYPE=$(shell cat psinfo/$(PLAT)/timer_type.txt)
|
|
|
|
C_SOURCES = $(wildcard kernel/*.c kernel/cpu/$(PLAT)/*.c kernel/cpu/*.c kernel/timer/$(TIMER_TYPE)/*.c)
|
|
|
|
C_HEADERS = $(wildcard kernel/*.h kernel/cpu/$(PLAT)/*.h kernel/cpu/*.h kernel/timer/$(TIMER_TYPE)/*.h)
|
2019-05-25 10:35:31 -05:00
|
|
|
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-08-26 13:21:20 -05:00
|
|
|
CFLAGS = -Isysroot/usr/include -Wextra -Wall -Wno-unused-parameter -g -ffreestanding
|
2019-08-04 13:14:35 -05:00
|
|
|
QFLAGS = -hda ext2.img -m 2G -boot d -cdrom os.iso -serial file:serout #-chardev socket,id=s1,port=3000,host=localhost -serial chardev:s1
|
2019-07-13 10:18:41 -05:00
|
|
|
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
|
2020-08-02 14:35:44 -05:00
|
|
|
rm -f serout
|
|
|
|
touch serout
|
|
|
|
@$(EMU) $(QFLAGS) &
|
|
|
|
tail -f serout
|
2019-02-09 12:52:45 -06:00
|
|
|
|
2019-05-25 10:35:31 -05:00
|
|
|
debug: os.iso kernel/kernel.elf
|
2019-05-22 14:18:29 -05:00
|
|
|
@$(EMU) -s $(QFLAGS) &
|
2020-08-01 09:04:18 -05:00
|
|
|
gdb
|
2019-07-20 11:03:27 -05:00
|
|
|
#gdbgui -g i386-elf-gdb --project $(CWD)
|
2019-02-09 12:52:45 -06:00
|
|
|
|
2020-08-23 14:05:38 -05:00
|
|
|
os.iso: kernel/kernel.elf init vfs devfs vga_drv initrd_drv tar_fs sysroot/usr/share/man # vfs devfs initrd vga_drv initrd_drv pci
|
2019-08-26 13:32:19 -05:00
|
|
|
@cp kernel/kernel.elf sysroot/boot
|
|
|
|
@cd initrd; tar -f ../sysroot/boot/initrd.tar -c *
|
|
|
|
@grub-mkrescue -o $@ sysroot >/dev/null 2>/dev/null
|
2019-02-09 12:52:45 -06:00
|
|
|
|
2019-08-28 08:26:42 -05:00
|
|
|
crts: kernel/crt0.o
|
2019-08-28 17:34:02 -05:00
|
|
|
@cp $^ sysroot/usr/lib
|
2019-08-28 08:26:42 -05:00
|
|
|
|
2019-09-07 10:02:10 -05:00
|
|
|
init: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-07-13 10:18:41 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
2019-03-17 18:04:50 -05:00
|
|
|
|
2019-09-07 10:02:10 -05:00
|
|
|
vfs: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-07-13 10:18:41 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
|
|
|
|
2019-09-07 10:02:10 -05:00
|
|
|
devfs: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-07-13 10:18:41 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
|
|
|
|
2019-09-08 13:01:37 -05:00
|
|
|
pci: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-09-08 13:01:37 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
2019-06-22 10:31:33 -05:00
|
|
|
|
2019-09-07 10:02:10 -05:00
|
|
|
vga_drv: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-08-31 10:49:52 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
|
|
|
|
2019-10-20 09:44:33 -05:00
|
|
|
initrd_drv: crts libc
|
2020-07-12 16:34:40 -05:00
|
|
|
@cd $@ && make
|
2019-10-20 09:44:33 -05:00
|
|
|
@cp $@/$@ initrd/$@
|
|
|
|
|
2020-08-23 14:05:38 -05:00
|
|
|
tar_fs: crts libc
|
|
|
|
@cd $@ && make
|
|
|
|
@cp $@/$@ initrd/$@
|
|
|
|
|
2019-08-26 17:00:00 -05:00
|
|
|
kernel/kernel.elf: $(OBJ) $(ASM_OBJ) $(S_ASM_OBJ) sysroot/usr/lib/libc.a
|
2019-05-25 10:35:31 -05:00
|
|
|
@$(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-09-08 13:01:37 -05:00
|
|
|
libc: sysroot/usr/lib/libc.a
|
|
|
|
|
2019-08-26 17:00:00 -05:00
|
|
|
sysroot/usr/lib/libc.a: $(LIBC_OBJ)
|
2019-05-25 10:35:31 -05:00
|
|
|
@$(AR) rcs $@ $^
|
2019-05-24 11:52:13 -05:00
|
|
|
|
2020-07-26 07:29:30 -05:00
|
|
|
sysroot/usr/share/man: doc
|
2020-07-26 14:39:08 -05:00
|
|
|
@ cp -r kernel/docs/man/man9 sysroot/usr/share/man
|
2020-07-26 15:38:29 -05:00
|
|
|
@ cp -r libc/docs/man/man3 sysroot/usr/share/man
|
2020-07-26 14:39:08 -05:00
|
|
|
|
|
|
|
sysroot/usr/include: $(LIBC_SOURCES) $(LIBC_HEADERS)
|
|
|
|
@ cd libc;rsync -R *.h */*.h ../sysroot/usr/include/
|
2020-07-26 07:29:30 -05:00
|
|
|
|
2020-07-22 19:26:55 -05:00
|
|
|
kernel/cpu/arch_consts.h: kernel/cpu/$(PLAT)/arch_consts.h
|
2020-07-22 19:38:10 -05:00
|
|
|
@cp kernel/cpu/$(PLAT)/arch_consts.h kernel/cpu/arch_consts.h
|
2020-07-22 19:26:55 -05:00
|
|
|
kernel/cpu/isr.h: kernel/cpu/$(PLAT)/isr.h
|
2020-07-22 19:38:10 -05:00
|
|
|
@cp kernel/cpu/$(PLAT)/isr.h kernel/cpu/isr.h
|
2020-07-22 19:26:55 -05:00
|
|
|
|
2020-07-26 14:39:08 -05:00
|
|
|
%.o: %.c kernel/cpu/arch_consts.h kernel/cpu/isr.h sysroot/usr/include
|
2019-05-25 10:35:31 -05:00
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
2019-05-25 10:27:12 -05:00
|
|
|
|
2019-05-25 10:35:31 -05:00
|
|
|
%.o: %.asm
|
2020-07-12 16:34:40 -05:00
|
|
|
@$(NASM) $< -o $@
|
2019-05-25 10:35:31 -05:00
|
|
|
|
|
|
|
%.o: %.s
|
|
|
|
@$(AS) $< -o $@
|
2019-02-09 12:52:45 -06:00
|
|
|
|
|
|
|
clean:
|
2019-08-26 13:32:19 -05:00
|
|
|
@rm -rf initrd/* kernel/*.o drivers/*/*.o drivers/*/*/*.o cpu/*/*.o fs/*.o libc/libc.a kernel/cstart.o cpu/memory.h os.iso */*.elf sysroot/boot/initrd.tar
|
2020-07-25 16:54:37 -05:00
|
|
|
|
|
|
|
doc: $(C_SOURCES) $(C_HEADERS)
|
2020-07-26 07:21:15 -05:00
|
|
|
@doxygen kernel/Doxyfile > /dev/null
|
2020-07-26 15:38:29 -05:00
|
|
|
@doxygen libc/Doxyfile > /dev/null
|