+export CROSS_COMPILE = i686-elf-
export AS = yasm
-export CC = i686-elf-gcc
+export CC = gcc
export QEMU = qemu-system-i386 -monitor stdio
export GIT_REV = $(shell git describe --long HEAD)
+export REAL_CC = $(CROSS_COMPILE)$(CC)
MAKEFLAGS += -rR
default: kernel/kernel.elf bootloader
default: LOADER.BIN loader.elf
loader.elf: $(STAGE3_OBJ)
- $(CC) $(LDFLAGS_BASE) $(LDFLAGS) -Wl,--oformat=elf32-i386 $^ -o $@
+ $(REAL_CC) $(LDFLAGS_BASE) $(LDFLAGS) -Wl,--oformat=elf32-i386 $^ -o $@
LOADER.BIN: $(STAGE3_OBJ)
- $(CC) $(LDFLAGS_BASE) $(LDFLAGS) $^ -o $@
+ $(REAL_CC) $(LDFLAGS_BASE) $(LDFLAGS) $^ -o $@
# Implicit rules
%.o: %.c
- $(CC) $(CFLAGS_BASE) $(CFLAGS) -c $< -o $@
+ $(REAL_CC) $(CFLAGS_BASE) $(CFLAGS) -c $< -o $@
%.o: %.s
$(AS) $(ASFLAGS_BASE) $(ASFLAGS) $< -o $@
LDFLAGS_BASE = -ffreestanding -nostdlib -lgcc -g -flto
kernel.elf kernel.dbg: $(KERNEL_OBJ)
- $(CC) $(LDFLAGS_BASE) $(LDFLAGS) -T linker.ld $^ -o $@
- i686-elf-objcopy --only-keep-debug kernel.elf kernel.dbg
- i686-elf-objcopy --add-gnu-debuglink=kernel.dbg kernel.elf
- i686-elf-strip --strip-unneeded kernel.elf
+ $(REAL_CC) $(LDFLAGS_BASE) $(LDFLAGS) -T linker.ld $^ -o $@
+ $(CROSS_COMPILE)objcopy --only-keep-debug kernel.elf kernel.dbg
+ $(CROSS_COMPILE)objcopy --add-gnu-debuglink=kernel.dbg kernel.elf
+ $(CROSS_COMPILE)strip --strip-unneeded kernel.elf
clean:
-rm $(KERNEL_OBJ) kernel.elf kernel.dbg
# Implicit rules
%.o: %.c
- $(CC) $(CFLAGS_BASE) $(CFLAGS) -c $< -o $@
+ $(REAL_CC) $(CFLAGS_BASE) $(CFLAGS) -c $< -o $@
%.o: %.s
$(AS) $(ASFLAGS_BASE) $(ASFLAGS) $< -o $@