1 Patch taken from https://bugs.python.org/issue22724 and augmented with
3 https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch
4 to fix the whole cross-compilation circus.
7 Makefile.pre.in | 14 +++++++-------
10 3 files changed, 17 insertions(+), 11 deletions(-)
12 diff --git a/Makefile.pre.in b/Makefile.pre.in
13 index 2a14f3323b..6239fc32fc 100644
16 @@ -492,7 +492,7 @@ $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
17 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
19 platform: $(BUILDPYTHON) pybuilddir.txt
20 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
21 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
23 # Create build directory and generate the sysconfig build-time data there.
24 # pybuilddir.txt contains the name of the build dir and is used for
25 @@ -503,7 +503,7 @@ platform: $(BUILDPYTHON) pybuilddir.txt
26 # or removed in case of failure.
27 pybuilddir.txt: $(BUILDPYTHON)
28 @echo "none" > ./pybuilddir.txt
29 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
30 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
31 if test $$? -ne 0 ; then \
32 echo "generate-posix-vars failed" ; \
33 rm -f ./pybuilddir.txt ; \
34 @@ -525,7 +525,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
36 $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
37 _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
38 - $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
39 + $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
41 # Build static library
42 # avoid long command lines, same as LIBRARY_OBJS
43 @@ -928,7 +928,7 @@ install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKI
44 upgrade) ensurepip="--upgrade" ;; \
45 install|*) ensurepip="" ;; \
47 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
48 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
49 $$ensurepip --root=$(DESTDIR)/ ; \
52 @@ -939,7 +939,7 @@ altinstall: commoninstall
53 upgrade) ensurepip="--altinstall --upgrade --no-default-pip" ;; \
54 install|*) ensurepip="--altinstall --no-default-pip" ;; \
56 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
57 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
58 $$ensurepip --root=$(DESTDIR)/ ; \
61 @@ -1270,7 +1270,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
62 # Install the dynamically loadable modules
63 # This goes into $(exec_prefix)
64 sharedinstall: sharedmods
65 - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
66 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
68 --install-scripts=$(BINDIR) \
69 --install-platlib=$(DESTSHARED) \
70 @@ -1344,7 +1344,7 @@ frameworkinstallextras:
71 # This installs a few of the useful scripts in Tools/scripts
73 SRCDIR=$(srcdir) $(RUNSHARED) \
74 - $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
75 + $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
77 --install-scripts=$(BINDIR) \
79 diff --git a/configure b/configure
80 index 67300fe2b6..6050f588c5 100755
83 @@ -741,6 +741,7 @@ CONFIG_ARGS
91 @@ -2964,7 +2965,8 @@ $as_echo_n "checking for python interpreter for cross build... " >&6; }
93 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
94 $as_echo "$interp" >&6; }
95 - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
96 + PY_BUILD_ENVIRON='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR)'
97 + PYTHON_FOR_BUILD=$interp
99 elif test "$cross_compiling" = maybe; then
100 as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5
101 @@ -2974,6 +2976,7 @@ fi
106 if test "$prefix" != "/"; then
107 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
109 diff --git a/setup.py b/setup.py
110 index cb47a2339c..472e7e2b26 100644
113 @@ -497,8 +497,6 @@ class PyBuildExt(build_ext):
114 if not cross_compiling:
115 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
116 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
117 - if cross_compiling:
118 - self.add_gcc_paths()
119 self.add_multiarch_paths()
121 # Add paths specified in the environment variables LDFLAGS and
122 @@ -556,7 +554,10 @@ class PyBuildExt(build_ext):
123 # be assumed that no additional -I,-L directives are needed.
124 inc_dirs = self.compiler.include_dirs[:]
125 lib_dirs = self.compiler.library_dirs[:]
126 - if not cross_compiling:
127 + if cross_compiling:
134 @@ -621,6 +622,8 @@ class PyBuildExt(build_ext):
135 # Some modules that are normally always on:
136 #exts.append( Extension('_weakref', ['_weakref.c']) )
138 + self.compiler.library_dirs = lib_dirs + [ '.' ]
141 exts.append( Extension('array', ['arraymodule.c']) )