diff options
| author | Alexey Gavrilov <rebovas@yahoo.com> | 2023-08-08 18:38:07 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <rebovas@yahoo.com> | 2023-08-08 18:38:07 +0700 |
| commit | 06d05938cc828901703112b99740c2e90a392b88 (patch) | |
| tree | 665168f9bf0ec29378e954e625bf5dbbf7475371 /makefile | |
First commit
Diffstat (limited to 'makefile')
| -rw-r--r-- | makefile | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/makefile b/makefile new file mode 100644 index 0000000..1e07743 --- /dev/null +++ b/makefile @@ -0,0 +1,30 @@ +CC = gcc# compiler +LD = ld# linker +ASM = nasm# assembler +# what is the flag -O2 +CFLAGS = -c -Wall -ffreestanding -nostdinc -nostdlib -lgcc# c compiler flags +# flag elf32 allow decrease object file size +AFLAGS = -f elf64# asm compiler flags +BDIR = build# build directory + +.PHONY: install + +install: build + @echo "Creating an iso image of OS" + cp ./$(BDIR)/kernel.bin ./iso/os/ + grub-mkrescue -o ./$(BDIR)/kernel.iso ./iso + +build: + mkdir $(BDIR) + @echo "Compile source files..." + $(CC) $(CFLAGS) -o ./$(BDIR)/kernel.o ./kernel/kernel.c + $(ASM) $(AFLAGS) -o ./$(BDIR)/boot.o ./kernel/boot.s + @echo "Link object files..." + $(LD) -m elf_x86_64 -o ./$(BDIR)/kernel.bin -T ./kernel/linker.ld ./$(BDIR)/*.o + @echo "Project was built" + +clean: + rm -rf ./build + +run: + qemu-system-i386 -cdrom ./$(BDIR)/kernel.iso |
