echo export S=${S} > ${S}/../temp/Bash_compile
echo export HOST_SYS=${HOST_SYS} >> ${S}/../temp/Bash_compile
echo export STAGING_DIR_HOST=${STAGING_DIR_HOST} >> ${S}/../temp/Bash_compile
+ echo export STAGING_LIBDIR=${STAGING_LIBDIR} >> ${S}/../temp/Bash_compile
+ echo export STAGING_BASELIBDIR=${STAGING_BASELIBDIR} >> ${S}/../temp/Bash_compile
+ echo export STAGING_INCDIR=${STAGING_INCDIR} >> ${S}/../temp/Bash_compile
+
#echo export cross_compiling=yes >> ${S}/../temp/Bash_compile
echo find \${S} -iname \"*.Rules\" -exec sed -e \'s,:=,?=,g\' -i {} \\\; >> ${S}/../temp/Bash_compile
echo find \${S} -iname \"*.Rules\" -exec sed -e \'s,BUILD_CFLAGS ?=,BUILD_CFLAGS := \$\(BUILD_CFLAGS\),\' -i {} \\\; >> ${S}/../temp/Bash_compile
echo export S=${S} > ${S}/../temp/Bash_install
echo export D=${D} >> ${S}/../temp/Bash_install
echo export HOST_SYS=${HOST_SYS} >> ${S}/../temp/Bash_install
+
+
if [[ ${PN} =~ "-native" ]];
then
echo export STAGING_DIR=${STAGING_DIR} >> ${S}/../temp/Bash_install
-EXTRA_AUTORECONF += "-f -i Modules/_ctypes/libffi"
\ No newline at end of file
+#inherit multilib_header pythonnative
+
+DEPENDS += "gdbm zlib"
+
+SRC_URI += "\
+ file://01-use-proper-tools-for-cross-build.patch \
+ file://03-fix-tkinter-detection.patch \
+ file://04-default-is-optimized.patch \
+ file://05-enable-ctypes-cross-build.patch \
+ file://06-ctypes-libffi-fix-configure.patch \
+ file://06-avoid_usr_lib_termcap_path_in_linking.patch \
+ file://99-ignore-optimization-flag.patch \
+ file://python.spec.patch \
+ "
+
+do_patch () {
+ echo RLM begining of python do_patch
+ cat ${WORKDIR}/01-use-proper-tools-for-cross-build.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/03-fix-tkinter-detection.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/04-default-is-optimized.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/05-enable-ctypes-cross-build.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/06-ctypes-libffi-fix-configure.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/06-avoid_usr_lib_termcap_path_in_linking.patch | patch -s -p1 --fuzz=2
+ cat ${WORKDIR}/99-ignore-optimization-flag.patch | patch -s -p1 --fuzz=2
+
+ cat ${WORKDIR}/python.spec.patch | patch -s -p1 --fuzz=2
+}
+
+PYTHONLSBOPTS = "--with-wctype-functions"
+PYTHONLSBOPTS_linuxstdbase = "ac_cv_sizeof_off_t=8"
+
+EXTRA_OECONF = "\
+ --with-threads \
+ --with-pymalloc \
+ --with-cyclic-gc \
+ --without-cxx \
+ --with-signal-module \
+ --with-wctype-functions \
+ --enable-shared \
+ ${PYTHONLSBOPTS} \
+"
+inherit multilib_header pythonnative
\ No newline at end of file
--- /dev/null
+diff --git a/Makefile.pre.in b/Makefile.pre.in
+index 07690f7..e649032 100644
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -184,6 +184,7 @@ UNICODE_OBJS= @UNICODE_OBJS@
+
+ PYTHON= python$(EXE)
+ BUILDPYTHON= python$(BUILDEXE)
++HOSTPYTHON= $(BUILDPYTHON)
+
+ # The task to run while instrument when building the profile-opt target
+ PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
+@@ -216,7 +217,7 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
+ ##########################################################################
+ # Parser
+ PGEN= Parser/pgen$(EXE)
+-
++HOSTPGEN= $(PGEN)$(EXE)
+ POBJS= \
+ Parser/acceler.o \
+ Parser/grammar1.o \
+@@ -404,14 +405,14 @@ $(BUILDPYTHON): Modules/python.o $(LDLIBRARY)
+ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
+
+ platform: $(BUILDPYTHON)
+- $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
++ $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
+
+
+ # 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
+
+ libpython$(VERSION).so: $(LIBRARY_OBJS)
+@@ -541,7 +542,7 @@ Modules/python.o: $(srcdir)/Modules/python.c
+ $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
+ Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
+ -@$(INSTALL) -d Include
+- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
++ $(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+ -touch Parser/pgen.stamp
+
+ $(PGEN): $(PGENOBJS)
+@@ -937,25 +938,25 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ $(DESTDIR)$(LIBDEST)/distutils/tests ; \
+ fi
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
++ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+ $(DESTDIR)$(LIBDEST)
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
++ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+ $(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
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
++ $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
+
+ # Create the PLATDIR source directory, if one wasn't distributed..
+ $(srcdir)/Lib/$(PLATDIR):
+@@ -1048,7 +1049,7 @@ libainstall: all python-config
+ # Install the dynamically loadable modules
+ # This goes into $(exec_prefix)
+ sharedinstall: sharedmods
+- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
++ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
+ --prefix=$(prefix) \
+ --install-scripts=$(BINDIR) \
+ --install-platlib=$(DESTSHARED) \
+diff --git a/setup.py b/setup.py
+index e00c629..9356856 100644
+--- a/setup.py
++++ b/setup.py
+@@ -313,6 +313,7 @@ class PyBuildExt(build_ext):
+ self.failed.append(ext.name)
+ self.announce('*** WARNING: renaming "%s" since importing it'
+ ' failed: %s' % (ext.name, why), level=3)
++ return
+ assert not self.inplace
+ basename, tail = os.path.splitext(ext_filename)
+ newname = basename + "_failed" + tail
+@@ -369,8 +370,8 @@ class PyBuildExt(build_ext):
+
+ def detect_modules(self):
+ # Ensure that /usr/local is always used
+- add_dir_to_list(self.compiler.library_dirs, '/usr/local/' + sys.lib)
+- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++ #add_dir_to_list(self.compiler.library_dirs, '/usr/local/' + sys.lib)
++ #add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ self.add_multiarch_paths()
+
+ # Add paths specified in the environment variables LDFLAGS and
+@@ -474,6 +475,9 @@ class PyBuildExt(build_ext):
+
+ # XXX Omitted modules: gl, pure, dl, SGI-specific modules
+
++ lib_dirs = [ os.getenv("STAGING_LIBDIR"), os.getenv("STAGING_BASELIBDIR") ]
++ inc_dirs = [ os.getenv("STAGING_INCDIR") ]
++
+ #
+ # The following modules are all pretty straightforward, and compile
+ # on pretty much any POSIXish platform.
--- /dev/null
+diff --git a/setup.py b/setup.py
+index 9356856..e6a277a 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1734,7 +1734,7 @@ class PyBuildExt(build_ext):
+ dotversion = dotversion[:-1] + '.' + dotversion[-1]
+ tcl_include_sub = []
+ tk_include_sub = []
+- for dir in inc_dirs:
++ for dir in [os.getenv("STAGING_INCDIR")]:
+ tcl_include_sub += [dir + os.sep + "tcl" + dotversion]
+ tk_include_sub += [dir + os.sep + "tk" + dotversion]
+ tk_include_sub += tcl_include_sub
+@@ -1753,20 +1753,6 @@ class PyBuildExt(build_ext):
+ if dir not in include_dirs:
+ include_dirs.append(dir)
+
+- # Check for various platform-specific directories
+- if platform == 'sunos5':
+- include_dirs.append('/usr/openwin/include')
+- added_lib_dirs.append('/usr/openwin/' + sys.lib)
+- elif os.path.exists('/usr/X11R6/include'):
+- include_dirs.append('/usr/X11R6/include')
+- added_lib_dirs.append('/usr/X11R6/' + sys.lib)
+- elif os.path.exists('/usr/X11R5/include'):
+- include_dirs.append('/usr/X11R5/include')
+- added_lib_dirs.append('/usr/X11R5/' + sys.lib)
+- else:
+- # Assume default location for X11
+- include_dirs.append('/usr/X11/include')
+- added_lib_dirs.append('/usr/X11/' + sys.lib)
+
+ # If Cygwin, then verify that X is installed before proceeding
+ if platform == 'cygwin':
--- /dev/null
+Upstream-Status: Inappropriate [embedded specific]
+
+Updated original patch for python 2.7.3
+
+Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
+2012/05/01
+
+
+# when compiling for an embedded system, we need every bit of
+# performance we can get. default to optimized with the option
+# of opt-out.
+# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
+
+Index: Python-2.7.3/Python/compile.c
+===================================================================
+--- Python-2.7.3.orig/Python/compile.c
++++ Python-2.7.3/Python/compile.c
+@@ -32,7 +32,7 @@
+ #include "symtable.h"
+ #include "opcode.h"
+
+-int Py_OptimizeFlag = 0;
++int Py_OptimizeFlag = 1;
+
+ #define DEFAULT_BLOCK_SIZE 16
+ #define DEFAULT_BLOCKS 8
+Index: Python-2.7.3/Modules/main.c
+===================================================================
+--- Python-2.7.3.orig/Modules/main.c
++++ Python-2.7.3/Modules/main.c
+@@ -40,7 +40,7 @@ static char **orig_argv;
+ static int orig_argc;
+
+ /* command line options */
+-#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?"
++#define BASE_OPTS "3bBc:dEhiJm:NOQ:RsStuUvVW:xX?"
+
+ #ifndef RISCOS
+ #define PROGRAM_OPTS BASE_OPTS
+@@ -69,8 +69,7 @@ Options and arguments (and corresponding
+ static char *usage_2 = "\
+ if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
+ -m mod : run library module as a script (terminates option list)\n\
+--O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
+--OO : remove doc-strings in addition to the -O optimizations\n\
++-N : do NOT optimize generated bytecode\n\
+ -R : use a pseudo-random salt to make hash() values of various types be\n\
+ unpredictable between separate invocations of the interpreter, as\n\
+ a defense against denial-of-service attacks\n\
+@@ -365,8 +364,8 @@ Py_Main(int argc, char **argv)
+
+ /* case 'J': reserved for Jython */
+
+- case 'O':
+- Py_OptimizeFlag++;
++ case 'N':
++ Py_OptimizeFlag=0;
+ break;
+
+ case 'B':
--- /dev/null
+Upstream-Status: Inappropriate [embedded specific]
+
+# CTypes need to know the actual host we are building on.
+# Signed-Off: Michael Dietrich <mdt@emdete.de>
+
+Index: Python-2.6.1/setup.py
+===================================================================
+--- Python-2.6.1.orig/setup.py
++++ Python-2.6.1/setup.py
+@@ -1656,16 +1656,16 @@ class PyBuildExt(build_ext):
+ ffi_configfile):
+ from distutils.dir_util import mkpath
+ mkpath(ffi_builddir)
+- config_args = []
++ config_args = ['--host=%s' % os.environ["HOST_SYS"], ]
+
+ # Pass empty CFLAGS because we'll just append the resulting
+ # CFLAGS to Python's; -g or -O2 is to be avoided.
+- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
+- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
++ cmd = "(cd %s && autoconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
++ % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))
+
+ res = os.system(cmd)
+ if res or not os.path.exists(ffi_configfile):
+- print "Failed to configure _ctypes module"
++ print "Failed to configure _ctypes module (res=%d) or missing conffile=%s" % ( res, ffi_configfile )
+ return False
+
+ fficonfig = {}
--- /dev/null
+diff --git a/setup.py b/setup.py
+index caf6a2b..b67a993 100644
+--- a/setup.py
++++ b/setup.py
+@@ -679,12 +679,10 @@ class PyBuildExt(build_ext):
+ pass # Issue 7384: Already linked against curses or tinfo.
+ elif curses_library:
+ readline_libs.append(curses_library)
+- elif self.compiler.find_library_file(lib_dirs +
+- ['/usr/'+sys.lib+'/termcap'],
++ elif self.compiler.find_library_file(lib_dirs ,
+ 'termcap'):
+ readline_libs.append('termcap')
+ exts.append( Extension('readline', ['readline.c'],
+- library_dirs=['/usr/'+sys.lib+'/termcap'],
+ extra_link_args=readline_extra_link_args,
+ libraries=readline_libs) )
+ else:
--- /dev/null
+This fixes configure issues with recent autoconf, e.g:
+ autoreconf: Entering directory `Modules/_ctypes/libffi'
+ autoreconf: configure.ac: not using Gettext
+ autoreconf: running: aclocal --force
+ configure.ac:26: error: m4_copy: won't overwrite defined macro: _AC_ARG_VAR_PRECIOUS
+ configure.ac:26: the top level
+
+The problem is still present in python-2.6.5 but fixed in python-svn.
+
+Upstream-Status: Accepted [python-svn]
+
+Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
+Acked-by: Martin Jansa <Martin.Jansa@gmail.com>
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+Signed-off-by: Saul Wold <sgw@linux.intel.com>
+
+
+2011/09/29
+Rebased for python 2.7.2
+Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
+
+
+Index: Python-2.7.2/Modules/_ctypes/libffi/Makefile.am
+===================================================================
+--- Python-2.7.2.orig/Modules/_ctypes/libffi/Makefile.am
++++ Python-2.7.2/Modules/_ctypes/libffi/Makefile.am
+@@ -2,7 +2,7 @@
+
+ AUTOMAKE_OPTIONS = foreign subdir-objects
+
+-SUBDIRS = include testsuite man
++SUBDIRS = include
+
+ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
+ src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
+@@ -34,8 +34,6 @@ EXTRA_DIST = LICENSE ChangeLog.v1 Change
+ libtool-version ChangeLog.libffi m4/libtool.m4 \
+ m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4
+
+-info_TEXINFOS = doc/libffi.texi
+-
+ ## ################################################################
+
+ ##
--- /dev/null
+Upstream-Status: Inappropriate [embedded specific]
+
+# Reinstate the empty -O option to fix weird mixing of native and target
+# binaries and libraries with LD_LIBRARY_PATH when host==target
+#
+# Signed-off-by: Denys Dmytriyenko <denis@denix.org>
+
+Index: Python-2.6.6/Modules/main.c
+===================================================================
+--- Python-2.6.6.orig/Modules/main.c
++++ Python-2.6.6/Modules/main.c
+@@ -327,6 +327,9 @@ Py_Main(int argc, char **argv)
+
+ /* case 'J': reserved for Jython */
+
++ case 'O': /* ignore it */
++ break;
++
+ case 'N':
+ Py_OptimizeFlag=0;
+ break;
--- /dev/null
+diff --git a/packaging/python.spec b/packaging/python.spec
+index 865110b..7341b2f 100644
+--- a/packaging/python.spec
++++ b/packaging/python.spec
+@@ -100,7 +100,7 @@ rm Demo/scripts/newslist.*
+ cp %{S:1001} .
+ export OPT="%{optflags}"
+
+-autoreconf -f -i . # Modules/_ctypes/libffi
++autoreconf -Wcross --verbose -f -i . # Modules/_ctypes/libffi
+ # prevent make from trying to rebuild asdl stuff, which requires existing
+ # python installation
+ touch Parser/asdl* Python/Python-ast.c Include/Python-ast.h
+@@ -112,7 +112,7 @@ touch Parser/asdl* Python/Python-ast.c Include/Python-ast.h
+ --enable-shared \
+ --enable-unicode=ucs4
+
+-make %{?_smp_mflags}
++%{__make} %{?_smp_mflags}
+
+ %install
+ # replace rest of /usr/local/bin/python or /usr/bin/python2.x with /usr/bin/python