1、下载binutils-2.15,gcc-3.2.2,glibc-2.3.2,glibc-linuxthreads-2.3.2,linux-2.4.18
2、配置编译binutils
./configure --refix=/opt/mips-toolchain --target=mipsel-linux
make
make install
3、配置编译自举gcc
./configure --prefix=/opt/mips-toolchain --target=mipsel-linux --enable-languages=c --without-headers --with-newlib --disable-shared --disable-threads
make
make install
此处有两个选项需要注意,--wiht-newlib指定gcc不要寻找glibc的头文件,--disable-threads指定gcc不需要pthread的头文件,否则在编译时会自这两处报错,都是找不到对应的头文件
自举gcc安装成功后就可以编译kernel和bootloader了
4、配置内核
进入内核源代码目录,对内核进行配置,目的是产生正确的asm的链接和version.h头文件,然后将linux-2.4.18/include/中的asm和linux目录整个拷贝到/opt/mips-toolchain/include目录下面
5、配置编译glibc
建立glibc-mips目录
在glibc-2.3.2和glibc-mips目录下面分别解压缩glibc-linuxthreads-2.3.2.tar.gz
glibc-2.3.2需要elf-machine-rela-mips-dpatch补丁,网上有些网友说还需要sscanf的补丁,但是我没用到
../glibc-2.3.2/configure --host=mipsel-linux --enable-add-ons=linuxthreads
make
make install_root=/opt/mips-glibc install
install_root指定了glibc的安装目录
将/opt/mips-glibc/usr/local中的lib和include目录拷贝到/opt/mips-toolchain/mipsel-linux中,并将lib目录中的文件拷贝到/usr/local/lib中,为编译完整的gcc做准备
6、配置编译完整的gcc
./configure --prefix=/opt/mips-toolchain --target=mipsel-linux --enable-shared --enable-threads --with-headers=/opt/mips-toolchain/mipsel-linux/include
make
make install
到这里完整的mips toolchain就搭建完成了
2、配置编译binutils
./configure --refix=/opt/mips-toolchain --target=mipsel-linux
make
make install
3、配置编译自举gcc
./configure --prefix=/opt/mips-toolchain --target=mipsel-linux --enable-languages=c --without-headers --with-newlib --disable-shared --disable-threads
make
make install
此处有两个选项需要注意,--wiht-newlib指定gcc不要寻找glibc的头文件,--disable-threads指定gcc不需要pthread的头文件,否则在编译时会自这两处报错,都是找不到对应的头文件
自举gcc安装成功后就可以编译kernel和bootloader了
4、配置内核
进入内核源代码目录,对内核进行配置,目的是产生正确的asm的链接和version.h头文件,然后将linux-2.4.18/include/中的asm和linux目录整个拷贝到/opt/mips-toolchain/include目录下面
5、配置编译glibc
建立glibc-mips目录
在glibc-2.3.2和glibc-mips目录下面分别解压缩glibc-linuxthreads-2.3.2.tar.gz
glibc-2.3.2需要elf-machine-rela-mips-dpatch补丁,网上有些网友说还需要sscanf的补丁,但是我没用到
../glibc-2.3.2/configure --host=mipsel-linux --enable-add-ons=linuxthreads
make
make install_root=/opt/mips-glibc install
install_root指定了glibc的安装目录
将/opt/mips-glibc/usr/local中的lib和include目录拷贝到/opt/mips-toolchain/mipsel-linux中,并将lib目录中的文件拷贝到/usr/local/lib中,为编译完整的gcc做准备
6、配置编译完整的gcc
./configure --prefix=/opt/mips-toolchain --target=mipsel-linux --enable-shared --enable-threads --with-headers=/opt/mips-toolchain/mipsel-linux/include
make
make install
到这里完整的mips toolchain就搭建完成了