OUTPUT=kernel.img all : $(OUTPUT) #PREFIX=i686-pc-linux-gnu- PREFIX= NEWLIBPATH=/usr/lib/newlib/i686-linux-gnu CC=$(PREFIX)gcc CXX=$(PREFIX)g++ LD=$(PREFIX)ld OBJDUMP=$(PREFIX)objdump STRIP=$(PREFIX)strip CFLAGS=-I. -m32 -fno-builtin -nostdlib -I../include/common -I../include/kernel -I$(NEWLIBPATH)/include -Os -std=c99 -flto ASFLAGS=-m32 #-Wa,-a,-ad CXXFLAGS:=$(CFLAGS) -fno-rtti -fno-exceptions #LIBGCC:=/usr/lib/gcc/x86_64-linux-gnu/4.6/32/libgcc.a #LDFLAGS:=-L/usr/lib/newlib/i686-linux-gnu/lib $(NEWLIBPATH)/lib/crt0.o $(NEWLIBPATH)/lib/crt1.o $(NEWLIBPATH)/lib/libc.a $(NEWLIBPATH)/lib/libm.a $(LIBGCC) #--gc-sections # cnstdlib.o stuff.o # cnstdlib.o # $(LD) -m elf_i386 -T link.ld --oformat elf32-i386 -o $@ $^ $(LDFLAGS) # loader.o #loader.o D3Stuff:=DrawFunctions.o Rasterizer.o #3d.o CFLAGS:=$(CFLAGS) -DRASTERIZER kernel.elf : loader.o main.o mystdlib.o $(D3Stuff) $(LD) -flto -dead-strip -nostdlib --nmagic -m elf_i386 -T linker.ld -o $@ $^ $(LDFLAGS) # $(STRIP) --strip-unneeded $@ $(OBJDUMP) -S --disassemble -j .text -j .bootsector -j .data -j .bss $@ > kernel.dump pad : pad.c gcc -o $@ $^ $(OUTPUT) : kernel.elf pad # objcopy --only-section=.bootsector -O binary kernel.elf kernel.img objcopy --set-section-flags .bootsector=alloc,load,code --change-section-address .text-0xff8400 --change-section-address .data-0xff8400 -j .bss -j .data -j .bootsector -j .text -O binary kernel.elf kernel.img ls -lah kernel.img ./pad run : $(OUTPUT) hexdump -C $^ qemu-system-i386 -hda $^ clean : rm -rf *~ *.o $(OUTPUT) kernel.elf