Skip to content

Commit

Permalink
Updated Makefile and removed unecessary files
Browse files Browse the repository at this point in the history
  • Loading branch information
Lt1Gt0 committed Dec 9, 2021
1 parent dd39c6f commit 94cc13b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 93 deletions.
1 change: 0 additions & 1 deletion boot/zeros.asm

This file was deleted.

6 changes: 0 additions & 6 deletions kernel/kernel_entry.asm

This file was deleted.

111 changes: 25 additions & 86 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,101 +1,40 @@
###PATH=$PATH:/usr/local/i386elfgcc/bin
###PATH=$PATH:/usr/local/x86_64elfgcc/bin (just incase the path varable isnt setup for this compiler)
##
##CPP_SOURCES = $(wildcard kernel/*.cpp drivers/*.cpp)
##HEADERS = $(wildcard kernel/*.h drivers/*.h)
##OBJS = ${CPP_SOURCES:.cpp=.o}
##
##CPP = i386-elf-gcc
##CPPFLAGS = -ffreestanding -m32 -g
##
##
##all: OS.bin
## $(info ---------- Running OS ----------)
## qemu-system-x86_64 -drive format=raw,file="OS.bin",index=0,if=floppy -m 128M
##setup:
## export PREFIX="/usr/local/i386elfgcc"
## export TARGET=i386-elf
## export PATH="$$PREFIX/bin:$$PATH"
##OS.bin: boot/everything.bin boot/zeros.bin
## $(info ---------- Generating OS binary ----------)
## cat $^ > $@
##boot/zeros.bin: boot/zeros.asm
## $(info ---------- padding ----------)
## nasm $^ -f bin -o $@
##boot/everything.bin: boot/boot.bin kernel/full_kernel.bin
## $(info ---------- Generating a a complete binary file ----------)
## cat $^ > $@
##boot/boot.bin: boot/boot.asm
## $(info ---------- Generating boot file ----------)
## nasm $^ -f bin -o $@
##kernel/full_kernel.bin: kernel/kernel_entry.o kernel/kernel.o
## $(info ---------- Generating full_kernel.bin ----------)
## i386-elf-ld -o $@ -Ttext 0x100 $^ --oformat binary
##kernel/kernel_entry.o: kernel/kernel_entry.asm
## $(info ---------- Generating kernel.o ----------)
## nasm $^ -f elf -o $@
##$(OUT): $(OBJFILES)
## $(CPP) $(CPPFLAGS) -o $@ $^
##%.o: %.cpp ${HEADERS}
## $(info ---------- Generating object files from cpp ----------)
## $(CPP) $(CPPFLAGS) -c $< -o $@
## @echo $^
##clean:
## $(info ---------- Cleaning ----------)
## rm -fr *.bin kernel/*.bin drivers/*.bin boot/*.bin
## rm -fr *.o kernel/*.o drivers/*.o boot/*.o

#PATH=$PATH:/usr/local/i386elfgcc/bin
#PATH=$PATH:/usr/local/x86_64elfgcc/bin (just incase the path varable isnt setup for this compiler)
#PATH=$PATH:/usr/local/x86_64elfgcc/bin

CPP_SOURCES = $(wildcard kernel/*.cpp drivers/*.cpp)
HEADERS = $(wildcard kernel/*.h drivers/*.h)
LINKERS = $(wildcard kernel/*.ld drivers/*.ld)
OBJS = ${CPP_SOURCES:.cpp=.o}

CPP = i386-elf-gcc
CPPFLAGS = -ffreestanding -m32 -g

all: sector_1/bootloader.bin

all: OS.bin
$(info ---------- Running OS ----------)
qemu-system-x86_64 -drive format=raw,file="sector_1/bootloader.bin",index=0,if=floppy -m 128M
kernel/kernel.bin: kernel/kernel.tmp
objcopy -O binary $^ $@
kernel/kernel.tmp: kernel/kernel.o sector_2/ExtendedProgram.o
custom-ld -o kernel/kernel.tmp -Ttext $^
sector_2/ExtendedProgram.o: sector_2/ExtendedProgram.asm
nasm $^ -f elf64 -o $@
kernel/kernel.o: kernel/kernel.cpp
x86_64-elf-gcc -ffreestanding -mno-red-zone -m64 -c $^ -o $@
sector_1/bootloader.bin: sector_1/bootloader.asm sector_2/ExtendedProgram.bin
nasm sector_1/bootloader.asm -f bin -o sector_1/bootloader.bin
cat sector_2/ExtendedProgram.bin >> sector_1/bootloader.bin
qemu-system-x86_64 -drive format=raw,file="OS.bin",index=0,if=floppy -m 128M
OS.bin: boot/bootloader.bin
$(info ---------- Generating OS binary ----------)
cat $^ > $@
boot/bootloader.bin: sector_1/bootloader.asm sector_2/ExtendedProgram.bin
$(info ---------- Generating bootloader ----------)
nasm sector_1/bootloader.asm -f bin -o boot/bootloader.bin
cat sector_2/ExtendedProgram.bin >> boot/bootloader.bin
sector_2/ExtendedProgram.bin: sector_2/ExtendedProgram.asm
nasm $^ -f bin -o $@
#OS.bin: boot/everything.bin boot/zeros.bin
# $(info ---------- Generating OS binary ----------)
# cat $^ > $@
#boot/zeros.bin: boot/zeros.asm
# $(info ---------- padding ----------)
# nasm $^ -f bin -o $@
#boot/everything.bin: boot/boot.bin kernel/full_kernel.bin
# $(info ---------- Generating a a complete binary file ----------)
# cat $^ > $@
#boot/boot.o: boot/boot.asm
# $(info ---------- Generating boot file ----------)
# nasm $^ -f elf64 -o $@
boot/boot.bin: boot/bootloader.asm
$(info ---------- Generating boot file ----------)
nasm $^ -f bin -o $@
#kernel/full_kernel.bin: kernel/kernel_entry.o kernel/kernel.o
# $(info ---------- Generating full_kernel.bin ----------)
# i386-elf-ld -o $@ -Ttext 0x100 $^ --oformat binary
#kernel/kernel_entry.o: kernel/kernel_entry.asm
# $(info ---------- Generating kernel.o ----------)
# nasm $^ -f elf -o $@
#$(OUT): $(OBJFILES)
# $(CPP) $(CPPFLAGS) -o $@ $^
#%.o: %.cpp ${HEADERS}
# $(info ---------- Generating object files from cpp ----------)
# $(CPP) $(CPPFLAGS) -c $< -o $@
# @echo $^
# i386-elf-ld -o $@ -Ttext 0x100 $^ --oformat binary
$(OUT): $(OBJFILES)
$(CPP) $(CPPFLAGS) -o $@ $^
%.o: %.cpp ${HEADERS}
$(info ---------- Generating object files from cpp ----------)
$(CPP) $(CPPFLAGS) -c $< -o $@
@echo $^
clean:
$(info ---------- Cleaning ----------)
rm -fr *.bin kernel/*.bin drivers/*.bin boot/*.bin sector_1/*.bin sector_2/*.bin
rm -fr *.o kernel/*.o drivers/*.o boot/*.o
rm -fr *.bin kernel/*.bin drivers/*.bin boot/*.bin boot/*.bin sector_1/*.bin sector_2/*.bin
rm -fr *.o kernel/*.o drivers/*.o boot/*.o
rm -fr *.tmp sector_1/*.tmp sector_2/*.tmp

0 comments on commit 94cc13b

Please sign in to comment.