summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2004-10-08 21:48:43 +0000
committerMike Frysinger <vapier@gentoo.org>2004-10-08 21:48:43 +0000
commit0efea03fab00aa667709f296fbd43ce3296aabbc (patch)
tree39b71a416690f45c86f6943db82e431eceb0d919
parent5226455eb4e707042afdcd5a0d102a67e5fd8e28 (diff)
update python ... this one should work a lot better than the old one
-rw-r--r--make/python.mk52
-rw-r--r--sources/python-cross-compile.patch117
2 files changed, 153 insertions, 16 deletions
diff --git a/make/python.mk b/make/python.mk
index 0be3a74a9..e49cc12aa 100644
--- a/make/python.mk
+++ b/make/python.mk
@@ -3,15 +3,13 @@
# python
#
#############################################################
-PYTHON_VERSION=2.3.2
-PYTHON_SOURCE:=Python-$(PYTHON_VERSION).tgz
+PYTHON_VERSION=2.3.4
+PYTHON_SOURCE:=Python-$(PYTHON_VERSION).tar.bz2
PYTHON_SITE:=http://python.org/ftp/python/$(PYTHON_VERSION)
PYTHON_DIR:=$(BUILD_DIR)/Python-$(PYTHON_VERSION)
-PYTHON_CAT:=zcat
+PYTHON_CAT:=bzcat
PYTHON_BINARY:=python
-PYTHON_INSTALL_DIR:=$(BUILD_DIR)/python_install
-PYTHON_TARGET_BINARY:=$(PYTHON_INSTALL_DIR)/bin/python
-
+PYTHON_TARGET_BINARY:=usr/bin/python
$(DL_DIR)/$(PYTHON_SOURCE):
$(WGET) -P $(DL_DIR) $(PYTHON_SITE)/$(PYTHON_SOURCE)
@@ -22,36 +20,58 @@ $(PYTHON_DIR)/.unpacked: $(DL_DIR)/$(PYTHON_SOURCE)
$(PYTHON_CAT) $(DL_DIR)/$(PYTHON_SOURCE) | tar -C $(BUILD_DIR) -xvf -
touch $(PYTHON_DIR)/.unpacked
-$(PYTHON_DIR)/.configured: $(PYTHON_DIR)/.unpacked
+$(PYTHON_DIR)/.patched: $(PYTHON_DIR)/.unpacked
+ $(SOURCE_DIR)/patch-kernel.sh $(PYTHON_DIR) $(SOURCE_DIR) python*.patch
+ touch $(PYTHON_DIR)/.patched
+
+$(PYTHON_DIR)/.hostpython: $(PYTHON_DIR)/.patched
+ (cd $(PYTHON_DIR); rm -rf config.cache; \
+ OPT="-O1" \
+ ./configure \
+ --with-cxx=no \
+ $(DISABLE_NLS); \
+ make python Parser/pygen; \
+ mv python hostpython; \
+ mv Parser/pgen Parser/hostpgen; \
+ make distclean \
+ );
+ touch $(PYTHON_DIR)/.hostpython
+
+$(PYTHON_DIR)/.configured: $(PYTHON_DIR)/.hostpython
(cd $(PYTHON_DIR); rm -rf config.cache; \
$(TARGET_CONFIGURE_OPTS) \
+ OPT="$(TARGET_OPTIMIZATION)" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--prefix=/usr \
--sysconfdir=/etc \
+ --with-cxx=no \
$(DISABLE_NLS) \
);
- touch $(PYTHON_DIR)/.configured
+ touch $(PYTHON_DIR)/.configured
$(PYTHON_DIR)/$(PYTHON_BINARY): $(PYTHON_DIR)/.configured
- LD_LIBRARY_PATH=$(STAGING_DIR)/lib
- $(MAKE) CC=$(TARGET_CC) -C $(PYTHON_DIR)
+ $(MAKE) CC=$(TARGET_CC) -C $(PYTHON_DIR) DESTDIR=$(TARGET_DIR) \
+ HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen
$(TARGET_DIR)/$(PYTHON_TARGET_BINARY): $(PYTHON_DIR)/$(PYTHON_BINARY)
-
-python: uclibc $(TARGET_DIR)/$(PYTHON_TARGET_BINARY)
- $(MAKE) CC=$(TARGET_CC) -C $(PYTHON_DIR) install
- rm $(PYTHON_INSTALL_DIR)/bin/idle
- rm $(PYTHON_INSTALL_DIR)/bin/pydoc
+ LD_LIBRARY_PATH=$(STAGING_DIR)/lib
+ $(MAKE) CC=$(TARGET_CC) -C $(PYTHON_DIR) install \
+ DESTDIR=$(TARGET_DIR) CROSS_COMPILE=yes \
+ HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen
+ rm $(TARGET_DIR)/usr/bin/idle
+ rm $(TARGET_DIR)/usr/bin/pydoc
+ find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -o -name '*.pyo' | xargs rm
rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
$(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+python: uclibc $(TARGET_DIR)/$(PYTHON_TARGET_BINARY)
+
python-clean:
-$(MAKE) -C $(PYTHON_DIR) distclean
rm $(PYTHON_DIR)/.configured
python-dirclean:
rm -rf $(PYTHON_DIR)
-
diff --git a/sources/python-cross-compile.patch b/sources/python-cross-compile.patch
new file mode 100644
index 000000000..f7465cc3c
--- /dev/null
+++ b/sources/python-cross-compile.patch
@@ -0,0 +1,117 @@
+--- Python-2.3.4/Makefile.pre.in.orig 2003-11-18 14:54:00.000000000 -0500
++++ Python-2.3.4/Makefile.pre.in 2004-07-29 21:44:47.075924464 -0400
+@@ -159,6 +159,7 @@
+
+ PYTHON= python$(EXE)
+ BUILDPYTHON= python$(BUILDEXE)
++HOSTPYTHON= ./$(BUILDPYTHON)
+
+ # === Definitions added by makesetup ===
+
+@@ -186,6 +187,8 @@
+ # Parser
+ PGEN= Parser/pgen$(EXE)
+
++HOSTPGEN= $(PGEN)
++
+ POBJS= \
+ Parser/acceler.o \
+ Parser/grammar1.o \
+@@ -314,8 +317,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)' CROSS_COMPILE='yes' OPT='$(OPT)' DESTDIR='$(DESTDIR)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
++ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CROSS_COMPILE='yes' OPT='$(OPT)' DESTDIR='$(DESTDIR)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
+ esac
+
+ # buildno should really depend on something like LIBRARY_SRC
+@@ -432,7 +435,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)
+@@ -705,19 +708,19 @@
+ done
+ $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
++ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+ -x 'badsyntax|site-packages' $(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 '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
+
+@@ -812,7 +815,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)' \
++ $(HOSTPYTHON) -E $(srcdir)/setup.py install \
+ --prefix=$(prefix) \
+ --install-scripts=$(BINDIR) \
+ --install-platlib=$(DESTSHARED) \
+--- Python-2.3.4/setup.py.orig 2004-07-29 21:32:12.993562408 -0400
++++ Python-2.3.4/setup.py 2004-07-29 21:47:12.174866072 -0400
+@@ -213,6 +213,7 @@
+ try:
+ imp.load_dynamic(ext.name, ext_filename)
+ except ImportError, why:
++ 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
+@@ -233,6 +234,9 @@
+ 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" '
+@@ -245,8 +245,9 @@
+
+ def detect_modules(self):
+ # Ensure that /usr/local is always used
+- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++ add_dir_to_list(self.compiler.library_dirs, os.getenv('DESTDIR') + '/lib')
++ add_dir_to_list(self.compiler.library_dirs, os.getenv('DESTDIR') + '/usr/lib')
++ add_dir_to_list(self.compiler.include_dirs, os.getenv('DESTDIR') + '/usr/include')
+
+ # fink installs lots of goodies in /sw/... - make sure we
+ # check there
+@@ -254,11 +255,6 @@
+ add_dir_to_list(self.compiler.library_dirs, '/sw/lib')
+ add_dir_to_list(self.compiler.include_dirs, '/sw/include')
+
+- if os.path.normpath(sys.prefix) != '/usr':
+- add_dir_to_list(self.compiler.library_dirs,
+- sysconfig.get_config_var("LIBDIR"))
+- add_dir_to_list(self.compiler.include_dirs,
+- sysconfig.get_config_var("INCLUDEDIR"))
+
+ try:
+ have_unicode = unicode