1- # Use g++ i686 Cross Compiler
1+ # Use the i686 Cross Compiler
22GCC_FOLDER = ~/GCC_SRC
33C = $(GCC_FOLDER ) /bin/i686-elf-gcc
4+ CXX = $(GCC_FOLDER ) /bin/i686-elf-g++
45AS = $(GCC_FOLDER ) /bin/i686-elf-as
5- LD = $(C )
6+ LD = $(CXX )
67
78# Compiler flags
89C_FLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra -v
10+ CXX_FLAGS = -ffreestanding -O2 -Wall -Wextra -fno-exceptions -fno-rtti
911LD_FLAGS = -ffreestanding -O2 -nostdlib -lgcc
1012
1113# Objects
@@ -18,24 +20,26 @@ objects = boot.o kernel.o
1820% .o : % .c
1921 $(C ) -o $@ -c $< $(C_FLAGS )
2022
21- myos.bin : linker.ld $(objects )
23+ % .o : % .cpp
24+ $(CXX ) -o $@ -c $< $(CXX_FLAGS )
25+
26+ custom-os.bin : linker.ld $(objects )
2227 $(LD ) -T $< -o $@ $(LD_FLAGS ) $(objects )
23- # i686-elf-gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc
2428
25- install : myos .bin
29+ install : custom-os .bin
2630 mkdir -p isodir/boot/grub
27- cp myos .bin isodir/boot/myos .bin
31+ cp custom-os .bin isodir/boot/custom-os .bin
2832 echo ' set timeout=0' > isodir/boot/grub/grub.cfg
2933 echo ' set default=0' >> isodir/boot/grub/grub.cfg
3034 echo ' ' >> isodir/boot/grub/grub.cfg
3135 echo ' menuentry "My Operating System" {' >> isodir/boot/grub/grub.cfg
32- echo ' multiboot /boot/myos .bin' >> isodir/boot/grub/grub.cfg
36+ echo ' multiboot /boot/custom-os .bin' >> isodir/boot/grub/grub.cfg
3337 echo ' }' >> isodir/boot/grub/grub.cfg
34- grub-mkrescue -o myos .iso isodir
38+ grub-mkrescue -o custom-os .iso isodir
3539 rm -rf isodir
3640
3741clean :
38- rm -f $(objects ) myos .bin myos .iso isodir
42+ rm -f $(objects ) custom-os .bin custom-os .iso isodir
3943
4044run :
41- qemu-system-i386 -cdrom myos .iso
45+ qemu-system-i386 -cdrom custom-os .iso
0 commit comments