1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Make kernel in separate directory

This commit is contained in:
Alex Kotov 2020-11-25 14:32:16 +05:00
parent 57c2a09944
commit 3e47427b06
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 78 additions and 65 deletions

View file

@ -1,65 +1,15 @@
CCPREFIX = i686-elf-
AR = $(CCPREFIX)ar
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
GRUBCFG = rootfs/boot/grub/grub.cfg GRUBCFG = rootfs/boot/grub/grub.cfg
KERNEL = rootfs/boot/kernelmq.multiboot2 KERNEL = rootfs/boot/kernelmq.multiboot2
PROCMAN = rootfs/boot/procman PROCMAN = rootfs/boot/procman
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
IMAGE = image.iso IMAGE = image.iso
# Architecture-dependent
OBJS = start.s.o
OBJS += main.c.o
OBJS += init.c.o
OBJS += multiboot.c.o
OBJS += panic.c.o panic.asm.cpp.o
OBJS += pfa.c.o
OBJS += paging.c.o paging.asm.cpp.o
OBJS += pagedir.c.o
# Architecture-independent
OBJS += info.c.o
# Stdlib
OBJS += memset.c.o
OBJS += strlen.c.o
OBJS += itoa.c.o
OBJS += strncpy.c.o
# Built-in drivers
OBJS += console.c.o
OBJS += pic.c.o
OBJS += timer.c.o
# For debugging
OBJS += logger.c.o
OBJS += protected.c.o protected.asm.cpp.o
OBJS += tss.c.o tss.asm.cpp.o
OBJS += tasks.asm.cpp.o
OBJS += interrupt.asm.cpp.o
OBJS += exception.c.o
OBJS += hwint.c.o
OBJS += syscall.c.o
OBJS := $(addprefix src/, $(OBJS))
run: $(IMAGE) run: $(IMAGE)
qemu-system-i386 -cdrom $< -display none -serial stdio qemu-system-i386 -cdrom $< -display none -serial stdio
clean: clean:
rm -f $(OBJS) rm -f $(KERNEL) $(PROCMAN)
rm -f $(IMAGE) make -C src clean
rm -f $(KERNEL)
rm -f $(PROCMAN)
make -C procman clean make -C procman clean
$(IMAGE): $(GRUBCFG) $(KERNEL) $(PROCMAN) $(IMAGE): $(GRUBCFG) $(KERNEL) $(PROCMAN)
@ -69,20 +19,14 @@ $(KERNEL): $(OBJS)
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^ $(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
grub-file --is-x86-multiboot2 $@ grub-file --is-x86-multiboot2 $@
$(KERNEL): src/kernelmq.multiboot2
cp $< $@
$(PROCMAN): procman/procman $(PROCMAN): procman/procman
cp procman/procman $(PROCMAN) cp $< $@
src/kernelmq.multiboot2:
make -C src kernelmq.multiboot2
procman/procman: procman/procman:
make -C procman procman make -C procman procman
%.c.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%.s.o: %.s
$(AS) $< -o $@
%.asm.cpp.o: %.asm.cpp
nasm -felf32 -o $@ $<
%.asm.cpp: %.asm
cpp -P $< $@

1
src/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/kernelmq.multiboot2

68
src/Makefile Normal file
View file

@ -0,0 +1,68 @@
CCPREFIX = i686-elf-
AR = $(CCPREFIX)ar
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
KERNEL = kernelmq.multiboot2
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
# Architecture-dependent
OBJS = start.s.o
OBJS += main.c.o
OBJS += init.c.o
OBJS += multiboot.c.o
OBJS += panic.c.o panic.asm.cpp.o
OBJS += pfa.c.o
OBJS += paging.c.o paging.asm.cpp.o
OBJS += pagedir.c.o
# Architecture-independent
OBJS += info.c.o
# Stdlib
OBJS += memset.c.o
OBJS += strlen.c.o
OBJS += itoa.c.o
OBJS += strncpy.c.o
# Built-in drivers
OBJS += console.c.o
OBJS += pic.c.o
OBJS += timer.c.o
# For debugging
OBJS += logger.c.o
OBJS += protected.c.o protected.asm.cpp.o
OBJS += tss.c.o tss.asm.cpp.o
OBJS += tasks.asm.cpp.o
OBJS += interrupt.asm.cpp.o
OBJS += exception.c.o
OBJS += hwint.c.o
OBJS += syscall.c.o
all: $(KERNEL)
clean:
rm -f $(KERNEL) $(OBJS)
$(KERNEL): $(OBJS)
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
grub-file --is-x86-multiboot2 $@
%.c.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%.s.o: %.s
$(AS) $< -o $@
%.asm.cpp.o: %.asm.cpp
nasm -felf32 -o $@ $<
%.asm.cpp: %.asm
cpp -P $< $@