From: Duje Mihanović Date: Fri, 1 Jul 2022 19:31:58 +0000 (+0200) Subject: all: Add $(CROSS_COMPILE) support X-Git-Url: http://git.dujemihanovic.xyz/projects?a=commitdiff_plain;h=1cc2b297473acc92fdd7dc372ce13858ec569760;p=nameless-os.git all: Add $(CROSS_COMPILE) support --- diff --git a/Makefile b/Makefile index 993a455..4e5ae9a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ +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 diff --git a/boot/x86/stage3/Makefile b/boot/x86/stage3/Makefile index 81a4290..b5b02f0 100644 --- a/boot/x86/stage3/Makefile +++ b/boot/x86/stage3/Makefile @@ -8,14 +8,14 @@ LDFLAGS_BASE = -ffreestanding -nostdlib -g -lgcc -T stage3.ld -flto 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 $@ diff --git a/kernel/Makefile b/kernel/Makefile index 8c9b27b..48115dd 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -10,17 +10,17 @@ CFLAGS_BASE = -fgnu89-inline -ffreestanding -nostdlib -Iinclude \ 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 $@