It depends on where you installed your cross-compiler. I used the prefix /home/my_username/opt since that is where I install things I compiled without using portage (it makes it easy to remove). So I just added this to my path,
making sure that I don't mess up my host compiler and compiled and installed there.
If the path to the compiler is not in your system's $PATH, I recommend adding it.
My Makefile has almost these exact lines in it:
Code: Select all
TARGET := i586-elf
CC := $(TARGET)-gcc
LD := $(TARGET)-ld
$(TARGET) is the CPU and executable format you intend to use. GCC and binutils by default compiler their programs to TARGET_PREFIX-TOOL_NAME, so this won't mess up your system's compiler which is most likely just invoked by "gcc."
Once you have the compiler set up, add some rules in your Makefile to compile. Here is a simplified version of the rule I use to compile plain C files:
Now, since you have compiled for the system you intend to target, you don't have to mess with emulation flags and PE operations and all that.