aboutsummaryrefslogtreecommitdiff
path: root/tools/depends/target/python27/crosscompile.patch
blob: 94caaa7fa94e0b4d4d47ab296bc09c3393fb6a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -240,6 +240,7 @@
 ##########################################################################
 # Parser
 PGEN=		Parser/pgen$(EXE)
+PGEN_FOR_BUILD=$(NATIVE_PGEN)
 
 PSRCS=		\
 		Parser/acceler.c \
@@ -514,9 +515,9 @@
 	    *\ -s*|s*) quiet="-q";; \
 	    *) quiet="";; \
 	esac; \
-	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
+	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'    \
 		_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
-		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+		PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
 
 # Build static library
 # avoid long command lines, same as LIBRARY_OBJS
@@ -1114,12 +1115,12 @@
 		$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
 			$(DESTDIR)$(LIBDEST)/distutils/tests ; \
 	fi
-	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
+	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
 		$(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST) -f \
 		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
 		$(DESTDIR)$(LIBDEST)
-	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
 		$(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST) -f \
 		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
@@ -1247,11 +1248,13 @@
 # Install the dynamically loadable modules
 # This goes into $(exec_prefix)
 sharedinstall: sharedmods
+	CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
 	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
+		--skip-build \
 	   	--prefix=$(prefix) \
-		--install-scripts=$(BINDIR) \
-		--install-platlib=$(DESTSHARED) \
-		--root=$(DESTDIR)/
+		--install-scripts=$(DESTDIR)$(BINDIR) \
+		--install-platlib=$(DESTDIR)$(DESTSHARED) \
+		--root=/
 	-rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py*
 
 # Here are a couple of targets for MacOSX again, to install a full
--- a/configure.ac
+++ b/configure.ac
@@ -328,7 +328,6 @@
 	*)
 		# for now, limit cross builds to known configurations
 		MACHDEP="unknown"
-		AC_MSG_ERROR([cross build not supported for $host])
 	esac
 	ac_sys_release=
     else
@@ -374,7 +373,6 @@
 	*)
 		# for now, limit cross builds to known configurations
 		MACHDEP="unknown"
-		AC_MSG_ERROR([cross build not supported for $host])
 	esac
 	_PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
 fi
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
 from distutils.command.install_lib import install_lib
 from distutils.spawn import find_executable
 
-cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
+cross_compiling = ("_PYTHON_HOST_PLATFORM" in os.environ) or ('CROSS_COMPILE_TARGET' in os.environ)
 
 def get_platform():
     # cross build
@@ -178,6 +178,7 @@
 
     def build_extensions(self):
 
+        return
         # Detect which modules should be compiled
         missing = self.detect_modules()
 
@@ -342,6 +343,9 @@
 
         # Don't try to load extensions for cross builds
         if cross_compiling:
+            self.announce(
+                 'WARNING: skipping import check for cross-compiled: "%s"' %
+                 ext.name)
             return
 
         try:
@@ -496,7 +500,7 @@
                     for directory in reversed(options.dirs):
                         add_dir_to_list(dir_list, directory)
 
-        if os.path.normpath(sys.prefix) != '/usr' \
+        if os.path.normpath(sys.prefix) != '/usr' and not cross_compiling \
                 and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
             # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
             # (PYTHONFRAMEWORK is set) to avoid # linking problems when
@@ -572,6 +576,11 @@
         if host_platform in ['darwin', 'beos']:
             math_libs = []
 
+        # Insert libraries and headers from embedded root file system (RFS)
+        #if 'CROSS_COMPILE_TARGET' in os.environ:
+        #    lib_dirs += [os.environ['RFS'] + '/usr/lib']
+        #    inc_dirs += [os.environ['RFS'] + '/usr/include']
+
         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
 
         #
@@ -2051,8 +2060,13 @@
 
                 # 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))
+                if cross_compiling:
+                    cmd = "cd %s && env CFLAGS='' '%s/configure' --host=%s --build=%s %s" \
+                          % (ffi_builddir, ffi_srcdir, os.environ.get('HOSTARCH'),
+                             os.environ.get('BUILDARCH'), " ".join(config_args))
+                else:
+                    cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
+                          % (ffi_builddir, ffi_srcdir, " ".join(config_args))
 
                 res = os.system(cmd)
                 if res or not os.path.exists(ffi_configfile):