Hello Torsten,
unluckily the original patch has disappeared from sourceforge; but since this
question has been popping up at least once a week, I'm posting to the
Foxboard mailing list as well.
Here are the instructions:
- import Axis SDK environment defs (adjust your paths):
cd /home/fox/devboard-R2_01 && . init_env
- create a directory to save the attached files in and move there
- the Makefile target "prepare" downloads Python, applies the patch and
creates the staging directories; it is needed only once, and you invoke it
with "make prepare"
- everything is now ready, so Python compiles like any other program:
make cris-axis-linux-gnu
make clean
make
- a complete Python distribution ends up in /tmp/python_fox; take just what
you need (it's big) and copy it to the Fox (or maybe on a USB key)
CAVEAT: I've never tried compiling with uClibc, so I don't know if it works
or not.
HTH,
Ant9000
AXIS_USABLE_LIBS = UCLIBC GLIBC
include $(AXIS_TOP_DIR)/tools/build/Rules.axis
PROGS = build/python
DEST = $(AXIS_TOP_DIR)/target/$(AXIS_BUILDTYPE)/usr/bin
#CC, CXX, AR, RANLIB, LD, CFLAGS, CXXFLAGS, LDFLAGS ?
.PHONY: prepare
all: $(PROGS)
$(PROGS):
echo Building for $(AXIS_BUILDTYPE)
rm -rf build/*
cd build; \
../Python/configure -host=$(AXIS_BUILDTYPE) -build=i686-pc-linux-gnu
-prefix=/usr && \
make EXTRA_CFLAGS="${CFLAGS}" HOSTPYTHON=../build_host/python
HOSTPGEN=../build_host/Parser/pgen BLDSHARED='cris-axis-linux-gnu-gcc -shared'
CROSS_COMPILE=yes && \
make install EXTRA_CFLAGS="${CFLAGS}" HOSTPYTHON=../build_host/python
BLDSHARED='cris-axis-linux-gnu-gcc -shared' CROSS_COMPILE=yes
prefix=/tmp/python_fox/
prepare:
[ -f Python-2.5.1.tar.bz2 ] || wget
"http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tar.bz2"
[ -d Python-2.5.1 ] || ( tar jxvf Python-2.5.1.tar.bz2; rm
Python-2.5.1/configure )
[ -d Python ] || ln -s Python-2.5.1 Python
[ -d build_host ] || mkdir build_host
[ -d build ] || mkdir build
if [ ! -f Python/configure ]; then \
cd Python; \
patch -p1 < ../python25_xcompile_ant9000.patch; \
autoconf < configure.in; \
fi
rm -rf build_host/*
cd build_host && ../Python/configure && make python Parser/pgen
clean:
rm -rf build/*
--- Python-2.5.1/configure.in.orig 2007-03-12 11:50:51.000000000 +0100
+++ Python-2.5.1/configure.in 2007-11-02 00:21:51.000000000 +0100
@@ -3347,25 +3347,25 @@
AC_MSG_CHECKING(for /dev/ptmx)
-if test -r /dev/ptmx
-then
+#if test -r /dev/ptmx
+#then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DEV_PTMX, 1,
[Define if we have /dev/ptmx.])
-else
- AC_MSG_RESULT(no)
-fi
+#else
+# AC_MSG_RESULT(no)
+#fi
AC_MSG_CHECKING(for /dev/ptc)
-
-if test -r /dev/ptc
-then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_DEV_PTC, 1,
- [Define if we have /dev/ptc.])
-else
+#
+#if test -r /dev/ptc
+#then
+# AC_MSG_RESULT(yes)
+# AC_DEFINE(HAVE_DEV_PTC, 1,
+# [Define if we have /dev/ptc.])
+#else
AC_MSG_RESULT(no)
-fi
+#fi
AC_MSG_CHECKING(for %zd printf() format support)
AC_TRY_RUN([#include <stdio.h>
@@ -3368,39 +3368,40 @@
#fi
AC_MSG_CHECKING(for %zd printf() format support)
-AC_TRY_RUN([#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
-
-int main()
-{
- char buffer[256];
-
-#ifdef HAVE_SSIZE_T
-typedef ssize_t Py_ssize_t;
-#elif SIZEOF_VOID_P == SIZEOF_LONG
-typedef long Py_ssize_t;
-#else
-typedef int Py_ssize_t;
-#endif
-
- if(sprintf(buffer, "%zd", (size_t)123) < 0)
- return 1;
-
- if (strcmp(buffer, "123"))
- return 1;
-
- if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
- return 1;
-
- if (strcmp(buffer, "-123"))
- return 1;
-
- return 0;
-}],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
- AC_MSG_RESULT(no))
+#AC_TRY_RUN([#include <stdio.h>
+##include <stddef.h>
+##include <string.h>
+#
+#int main()
+#{
+# char buffer[256];
+#
+##ifdef HAVE_SSIZE_T
+#typedef ssize_t Py_ssize_t;
+##elif SIZEOF_VOID_P == SIZEOF_LONG
+#typedef long Py_ssize_t;
+##else
+#typedef int Py_ssize_t;
+##endif
+#
+# if(sprintf(buffer, "%zd", (size_t)123) < 0)
+# return 1;
+#
+# if (strcmp(buffer, "123"))
+# return 1;
+#
+# if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
+# return 1;
+#
+# if (strcmp(buffer, "-123"))
+# return 1;
+#
+# return 0;
+#}],
+#[AC_MSG_RESULT(yes)
+# AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
+# AC_MSG_RESULT(no))
+AC_MSG_RESULT(no)
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
diff -u -r Python-2.5.orig/Makefile.pre.in Python-2.5/Makefile.pre.in
--- Python-2.5.orig/Makefile.pre.in 2006-07-30 12:20:10.000000000 -0400
+++ Python-2.5/Makefile.pre.in 2006-10-02 10:12:04.000000000 -0400
@@ -170,6 +170,7 @@
PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
+HOSTPYTHON= ./$(BUILDPYTHON)
# === Definitions added by makesetup ===
@@ -197,6 +198,8 @@
# Parser
PGEN= Parser/pgen$(EXE)
+HOSTPGEN= $(PGEN)
+
POBJS= \
Parser/acceler.o \
Parser/grammar1.o \
@@ -345,8 +348,8 @@
# Build the shared modules
sharedmods: $(BUILDPYTHON)
case $$MAKEFLAGS in \
- *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
+ *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
esac
# Build static library
@@ -470,7 +473,7 @@
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
- -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+ -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
$(PGEN): $(PGENOBJS)
$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
@@ -772,20 +775,20 @@
done; \
done
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
@@ -885,7 +888,8 @@
# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILE='$(CROSS_COMPILE)' \
+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
diff -u -r Python-2.5.orig/setup.py Python-2.5/setup.py
--- Python-2.5.orig/setup.py 2006-08-09 19:42:18.000000000 -0400
+++ Python-2.5/setup.py 2006-10-02 10:33:44.000000000 -0400
@@ -15,7 +15,7 @@
from distutils.command.install_lib import install_lib
# This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+disabled_module_list = ['_ctypes']
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
@@ -203,32 +203,40 @@
self.announce('WARNING: skipping import check for Cygwin-based "%s"'
% ext.name)
return
+ if os.environ.get('CROSS_COMPILE') == 'yes':
+ return
+
ext_filename = os.path.join(
self.build_lib,
self.get_ext_filename(self.get_ext_fullname(ext.name)))
try:
imp.load_dynamic(ext.name, ext_filename)
except ImportError, why:
- self.announce('*** WARNING: renaming "%s" since importing it'
- ' failed: %s' % (ext.name, why), level=3)
- assert not self.inplace
- basename, tail = os.path.splitext(ext_filename)
- newname = basename + "_failed" + tail
- if os.path.exists(newname):
- os.remove(newname)
- os.rename(ext_filename, newname)
-
- # XXX -- This relies on a Vile HACK in
- # distutils.command.build_ext.build_extension(). The
- # _built_objects attribute is stored there strictly for
- # use here.
- # If there is a failure, _built_objects may not be there,
- # so catch the AttributeError and move on.
- try:
- for filename in self._built_objects:
- os.remove(filename)
- except AttributeError:
- self.announce('unable to remove files (ignored)')
+ if os.environ.get('CROSS_COMPILE') != "yes":
+ self.announce('*** WARNING: renaming "%s" since importing it'
+ ' failed: %s' % (ext.name, why), level=3)
+ assert not self.inplace
+ basename, tail = os.path.splitext(ext_filename)
+ newname = basename + "_failed" + tail
+ if os.path.exists(newname):
+ os.remove(newname)
+ os.rename(ext_filename, newname)
+
+ # XXX -- This relies on a Vile HACK in
+ # distutils.command.build_ext.build_extension(). The
+ # _built_objects attribute is stored there strictly for
+ # use here.
+ # If there is a failure, _built_objects may not be there,
+ # so catch the AttributeError and move on.
+ try:
+ for filename in self._built_objects:
+ os.remove(filename)
+ except AttributeError:
+ self.announce('unable to remove files (ignored)')
+ else:
+ self.announce('WARNING: "%s" failed importing, but we leave it '
+ 'because we are cross-compiling' %
+ ext.name)
except:
exc_type, why, tb = sys.exc_info()
self.announce('*** WARNING: importing extension "%s" '
@@ -569,7 +577,7 @@
if (ssl_incs is not None and
ssl_libs is not None and
- openssl_ver >= 0x00907000):
+ openssl_ver >= 0x00907000 and False):
# The _hashlib module wraps optimized implementations
# of hash functions from the OpenSSL library.
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
@@ -586,7 +594,7 @@
sources = ['md5module.c', 'md5.c'],
depends = ['md5.h']) )
- if (openssl_ver < 0x00908000):
+ if (True or openssl_ver < 0x00908000):
# OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
exts.append( Extension('_sha256', ['sha256module.c']) )
exts.append( Extension('_sha512', ['sha512module.c']) )