环境

Python:2.7.13

开发板: TQ2440

工具链: arm-none-linux-gnueabi-gcc 4.8.3

 

概述

前面已经把Python3移植到TQ2440上面的,现在我们移植Python2,基本跟Python3移植步骤类似。

 

正文

一、工具链

参考 javascript:void(0)

 

二、配置

下面是配置脚本mk1_conf.sh:

 1 #!/bin/bash
 2 
 3 /home/pengdonglin/disk_ext/Python/Python2/Python-2.7.13/configure --prefix=`pwd` \
 4     --host=arm-linux \
 5     --build=x86_64-linux-gnu \
 6     --enable-ipv6 \
 7     --enable-shared \
 8     ac_cv_file__dev_ptmx="yes" \
 9     ac_cv_file__dev_ptc="no" \
10     LDFLAGS="-L/home/pengdonglin/disk_ext/TQ2440/rootfs/SQlite3/lib \
11     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Readline/lib \
12     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Termcap/lib \
13     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Zlib/lib"\
14     CPPFLAGS="-I/home/pengdonglin/disk_ext/TQ2440/rootfs/SQlite3/include \
15     -I/home/pengdonglin/disk_ext/TQ2440/rootfs/Readline/include \
16     -I/home/pengdonglin/disk_ext/TQ2440/rootfs/Termcap/include \
17     -I/home/pengdonglin/disk_ext/TQ2440/rootfs/Zlib/include"\
18     LDLAST="-L/home/pengdonglin/disk_ext/TQ2440/rootfs/SQlite3/lib \
19     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Readline/lib \
20     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Termcap/lib \
21     -L/home/pengdonglin/disk_ext/TQ2440/rootfs/Zlib/lib"

配置完成之后,修改Modules/Setup,打开readline,将下面这行取消注释:

readline readline.c -lreadline -ltermcap
修改Makefile,将:
SVNVERSION=>---svnversion $(srcdir)
修改为:
SVNVERSION=

三、编译

下面是编译脚本mk2_mk.sh
 1 #!/bin/bash
 2 
 3 make HOSTPYTHON=/home/pengdonglin/disk_ext/Python/Python2/x86_64/python \
 4     HOSTPGEN=/home/pengdonglin/disk_ext/Python/Python2/x86_64/Parser/pgen \
 5     BLDSHARED="arm-linux-gcc -shared" \
 6     CROSS_COMPILE=arm-linux- \
 7     CROSS_COMPILE_TARGET=yes \
 8     HOSTARCH=arm-linux \
 9     BUILDARCH=x86_64-linux-gnu \
10     -j4

四、安装

下面是安装脚本mk3_install.sh
1 #!/bin/bash
2 
3 make install HOSTPYTHON=/home/pengdonglin/disk_ext/Python/Python2/x86_64/python \
4     BLDSHARED="arm-linux-gcc -shared" \
5     CROSS_COMPILE=arm-linux- \
6     CROSS_COMPILE_TARGET=yes \
7     prefix=`pwd

五、测试

[root@tq2440 ~]# python2 /usr/lib/python2.7/test/test___all__.py
test_all (__main__.AllTest) ... BaseHTTPServer
Bastion
CGIHTTPServer
ConfigParser
Cookie
DocXMLRPCServer
HTMLParser
MimeWriter
... ...
ok
----------------------------------------------------------------------
Ran 1 test in 38.408s
OK

 

完。