交叉编译 小米路由器mini 的 python(MIPS)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了交叉编译 小米路由器mini 的 python(MIPS)相关的知识,希望对你有一定的参考价值。
看了很多文章,要么说的是用opkg安装python,要么说的是小米路由器的交叉编译,就是没有mini的。学习了这篇文章(http://me.deepgully.com/post/5638916786880512),编译了小米路由mini的python。
已编译好的:http://download.csdn.net/detail/kowity/9611919
小米路由mini版的路由是mips的,跟小米路由的arm版不一样,所以脚本做了一些修改。先下载小米路由器mini版的开发包,里面有编译工具链:http://bigota.miwifi.com/xiaoqiang/sdk/tools/package/sdk_package_r1c.zip。将压缩包里面的 toolchain 复制到 /opt/xiaomi
先编译依赖库
- #!/bin/bash
- # rm -r -f /opt/xiaomi
- # wget -c http://bigota.miwifi.com/xiaoqiang/sdk/tools/package/sdk_package_r1c.zip
- # unzip sdk_package_r1c.zip
- # cp -r -f sdk_package_r1c/include/* sdk_package_r1c/toolchain/include/
- # cp -r -f sdk_package_r1c/lib/* sdk_package_r1c/toolchain/lib/
- # mv -f sdk_package_r1c/toolchain /opt/xiaomi
- export XIAOMI_ROOT_PATH=/opt/xiaomi
- export PATH="${XIAOMI_ROOT_PATH}/bin:${PATH}"
- rm -r -f readline-4.2
- wget -c http://ftp.gnu.org/gnu/readline/readline-4.2.tar.gz
- tar xvzf readline-4.2.tar.gz
- cd readline-4.2
- export CC=mipsel-openwrt-linux-uclibc-gcc RANLIB=mipsel-openwrt-linux-uclibc-ranlib AR=mipsel-openwrt-linux-uclibc-ar
- ./configure --host=mipsel-openwrt-linux-uclibc --build=mipsel-linux --prefix=${XIAOMI_ROOT_PATH}
- make
- sudo make install
- mipsel-openwrt-linux-uclibc-ranlib ${XIAOMI_ROOT_PATH}/lib/libreadline.a
- cd ..
- rm -r -f libffi-3.1
- wget -c ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz
- tar xvzf libffi-3.1.tar.gz
- cd libffi-3.1
- ./configure --host=mipsel-openwrt-linux-uclibc --build=mipsel-linux --prefix=${XIAOMI_ROOT_PATH}
- make
- sudo make install
- mipsel-openwrt-linux-uclibc-ranlib ${XIAOMI_ROOT_PATH}/lib/libffi.a
- cd ..
- rm -r -f termcap-1.3.1
- wget -c http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
- tar xvzf termcap-1.3.1.tar.gz
- cd termcap-1.3.1
- export CC=mipsel-openwrt-linux-uclibc-gcc RANLIB=mipsel-openwrt-linux-uclibc-ranlib AR=mipsel-openwrt-linux-uclibc-ar
- ./configure --host=mipsel-openwrt-linux-uclibc --build=mipsel-linux --prefix=${XIAOMI_ROOT_PATH}
- make
- sudo make install
- mipsel-openwrt-linux-uclibc-ranlib ${XIAOMI_ROOT_PATH}/lib/libtermcap.a
- cd ..
再编译python
- #!/bin/bash
- wget -c http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
- rm -r -f python
- mkdir python
- cd python
- cp ../Python-2.7.5.tar.bz2 .
- tar -jxf Python-2.7.5.tar.bz2
- wget -c http://bugs.python.org/file31991/Python-2.7.5-xcompile.patch
- cp Python-2.7.5-xcompile.patch Python-2.7.5/
- wget -c http://7xrt07.com1.z0.glb.clouddn.com/setup.py.2.5.xcompile.patch
- cp setup.py.xcompile.patch Python-2.7.5/
- mkdir backup
- cd Python-2.7.5
- make distclean
- rm -rf python_for_build Parser/pgen_for_build
- cp Makefile.pre.in ../backup/
- cp Modules/Setup.dist ../backup/Modules/
- cp configure ../backup/
- cp setup.py ../backup/
- unset CC
- unset CXX
- ./configure
- make --jobs=2 python Parser/pgen
- mv python python_for_build
- mv Parser/pgen Parser/pgen_for_build
- cp python_for_build ../backup/
- cp Parser/pgen_for_build ../backup/
- patch -p3 < Python-2.7.5-xcompile.patch
- patch < setup.py.xcompile.patch
- make distclean
- RFS=/opt/xiaomi
- export PATH="${RFS}/lib:${RFS}/usr/lib:${PATH}"
- export LDFLAGS="-L${RFS}/usr/lib -L${RFS}/lib"
- ./configure --host=mipsel-openwrt-linux-uclibc --build=mipsel-linux --prefix=/\
- --disable-ipv6 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes
- if [ $? != 0 ]; then
- echo "(E) Configure FAILED!"
- exit 5
- fi
- make --jobs=2 \
- CFLAGS="-g0 -Os -s -I${RFS}/include -I${RFS}/usr/include -L${RFS}/usr/lib -L${RFS}/lib -fdata-sections -ffunction-sections" \
- LDFLAGS="-L${RFS}/usr/lib -L${RFS}/lib"
- if [ $? != 0 ]; then
- echo "(E) Make FAILED!"
- exit 5
- fi
- mipsel-openwrt-linux-strip --strip-unneeded python
- echo "(I) Installing Python ..."
- sudo make install DESTDIR=${RFS}/python PATH="${PATH}"
- if [ $? != 0 ]; then
- echo "(E) Installation FAILED!"
- exit 5
- fi
- rm -r -f ${RFS}/python/lib/python2.7/test
- rm -r -f ${RFS}/python/lib/python2.7/unitest
- rm -r -f ${RFS}/python/lib/python2.7/lib-tk
- rm -r -f ${RFS}/python/lib/python2.7/idlelib
- rm -r -f ${RFS}/python/lib/python2.7/2to3
- echo "(I) Python cross-compilation and installation is done!"
- exit 0
将生成的python目录复制到小米路由器就ok了
http://blog.csdn.net/kowity/article/details/52302849
以上是关于交叉编译 小米路由器mini 的 python(MIPS)的主要内容,如果未能解决你的问题,请参考以下文章