diff --git a/Makefile b/Makefile index 02b8066..4270ac5 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,23 @@ +EXEC=PiegOS + +all:$(EXEC) + +#----- Copy kernel ----- +$(EXEC): kernel/kernel.bin + cp kernel/kernel.bin ./$(EXEC) +#----------------------- -PiegOS: kernel/kernel.bin - cp kernel/kernel.bin ./PiegOS +#----- Gen Kernel ----- kernel/kernel.bin: cd kernel/ && make +#---------------------- + + +#----- Other ----- clean: cd kernel && make clean - rm PiegOS + rm $(EXEC) +#----------------- diff --git a/kernel/GDT/Makefile b/kernel/GDT/Makefile index 6e1b2c8..b4a9400 100644 --- a/kernel/GDT/Makefile +++ b/kernel/GDT/Makefile @@ -1,5 +1,15 @@ -gdt.o: gdt.cpp - g++ -m32 -c -o gdt.o gdt.cpp +EXEC=gdt.o + +all:$(EXEC) + +#----- GDT ----- +$(EXEC): gdt.cpp + $(CXX) -c -o $(EXEC) gdt.cpp +#--------------- + + +#----- Other ----- clean: rm *.o +#---------------- diff --git a/kernel/Makefile b/kernel/Makefile index cb1a351..b323e6e 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,7 +1,12 @@ +CXX=g++ -Wall -m32 +EXEC=kernel.bin +export CXX + +all:$(EXEC) #----- Kernel ----- -kernel.bin:entry.o main.o GDT/gdt.o +$(EXEC):entry.o main.o GDT/gdt.o ld -m elf_i386 --entry=_start -Ttext=0x100000 -o $@ $^ #----------------- @@ -10,7 +15,7 @@ kernel.bin:entry.o main.o GDT/gdt.o entry.o:entry.asm nasm -f elf $^ main.o:main.cpp - g++ -Wall -m32 -c $^ -o $@ + $(CXX) -c $^ -o $@ #----------------------- @@ -24,4 +29,5 @@ GDT/gdt.o: clean: cd ./GDT/ && make clean rm ./*.o - rm ./kernel.bin + rm ./$(EXEC) +#-----------------