Fix the whole python building process to do proper crosscompiling for all python

modules in openwrt. Thanks to ryd for helping to make this possible.
(Only numpy is completly broken now because it has dependencies which
where pervioulsy taken from the build system)



git-svn-id: svn://svn.openwrt.org/openwrt/packages@12821 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
lars
2008-10-02 15:33:26 +00:00
parent 40daf3db15
commit 1a7ebdeb62
22 changed files with 409 additions and 176 deletions

View File

@ -14,14 +14,12 @@ PKG_RELEASE:=2
PKG_SOURCE:=Python-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)/
PKG_MD5SUM:=70084ffa561660f07de466c2c8c4842d
#PKG_MD5SUM:=afb5451049eda91fbde10bd5a4b7fadc
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=python libexpat libopenssl zlib
include $(INCLUDE_DIR)/package.mk
-include $(if $(DUMP),,./python-package.mk)
-include $(if $(DUMP),,./files/python-package.mk)
define Package/python/Default
SUBMENU:=Python
@ -32,19 +30,19 @@ define Package/python/Default
endef
define Package/python/Default/description
Python is a dynamic object-oriented programming language that can be used
for many kinds of software development. It offers strong support for
integration with other languages and tools, comes with extensive standard
libraries, and can be learned in a few days. Many Python programmers
report substantial productivity gains and feel the language encourages
Python is a dynamic object-oriented programming language that can be used
for many kinds of software development. It offers strong support for
integration with other languages and tools, comes with extensive standard
libraries, and can be learned in a few days. Many Python programmers
report substantial productivity gains and feel the language encourages
the development of higher quality, more maintainable code.
endef
define Package/python
$(call Package/python/Default)
TITLE+= (full)
DEPENDS:= +libpthread +zlib
PROVIDES:=python-core
TITLE+= (full)
DEPENDS:=+libpthread +zlib
PROVIDES:=python-core
endef
define Package/python/description
@ -55,27 +53,27 @@ endef
define Package/python-mini
$(call Package/python/Default)
TITLE+= (minimal)
DEPENDS:= +libpthread +zlib
PROVIDES:=python-core
TITLE+= (minimal)
DEPENDS:=+libpthread +zlib
PROVIDES:=python-core
endef
define Package/python-mini/description
$(call Package/python/Default/description)
.
This package contains only a minimal Python install.
.
This package contains only a minimal Python install.
endef
define Package/python-doc
$(call Package/python/Default)
TITLE:=Python interactive documentation
DEPENDS+= python-core
TITLE:=Python interactive documentation
DEPENDS+= python-core
endef
define Package/python-expat
$(call Package/python/Default)
TITLE:=Python support for expat
DEPENDS+= python-core +libexpat
TITLE:=Python support for expat
DEPENDS+= python-core +libexpat
endef
define Package/python-openssl
@ -97,8 +95,8 @@ MAKE_OPTS:=\
CFLAGS="$(TARGET_CFLAGS) -fno-inline" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LD="$(TARGET_CC)" \
HOSTPYTHON=./hostpython \
HOSTPGEN=./hostpgen
HOSTPYTHON=$(PKG_INSTALL_DIR)/host/bin/python \
HOSTPGEN=./hostpgen \
define Build/Configure
endef
@ -109,15 +107,16 @@ define Build/Compile
rm -rf config.cache; \
CONFIG_SITE= \
OPT="$(HOST_CFLAGS)" \
./configure --without-cxx-main --without-threads; \
);
$(MAKE) -C $(PKG_BUILD_DIR) python Parser/pgen
(cd $(PKG_BUILD_DIR); \
mv python ./hostpython; \
mv Parser/pgen ./hostpgen; \
./configure --without-cxx-main --without-threads --prefix=$(PKG_INSTALL_DIR)/host; \
);
$(MAKE) -C $(PKG_BUILD_DIR) \
python Parser/pgen
$(MAKE) -C $(PKG_BUILD_DIR) \
HOSTPYTHON=$(PKG_BUILD_DIR)/python \
sharedmods install
(cd $(PKG_BUILD_DIR);mv Parser/pgen hostpgen)
$(MAKE) -C $(PKG_BUILD_DIR) distclean
#echo "readline readline.c -lreadline -lncurses" >> $(PKG_BUILD_DIR)/Modules/Setup.local
$(call Build/Configure/Default, \
--sysconfdir=/etc \
--disable-shared \
@ -125,8 +124,6 @@ define Build/Compile
--without-cxx-main \
--with-threads \
ac_cv_lib_readline_readline=no \
HOSTPYTHON=./hostpython \
HOSTPGEN=./hostpgen \
OPT="$(TARGET_CFLAGS)" \
)
$(MAKE) -C $(PKG_BUILD_DIR) \
@ -137,18 +134,33 @@ endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/mk $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
$(INSTALL_DATA) ./python-package.mk $(1)/mk/
$(CP) $(PKG_BUILD_DIR)/hostpython $(1)/usr/bin/
ln -sf hostpython $(1)/usr/bin/python
ln -sf $(STAGING_DIR)/usr/bin/hostpython $(2)/bin/
ln -sf $(STAGING_DIR)/usr/bin/python $(2)/bin/
$(INSTALL_DATA) ./files/python-package.mk $(1)/mk/
$(CP) \
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
$(1)/usr/include/
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION) \
$(PKG_INSTALL_DIR)/host/lib/python$(PYTHON_VERSION) \
$(PKG_BUILD_DIR)/libpython$(PYTHON_VERSION).a \
$(1)/usr/lib/
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
$(1)/usr/lib/python$(PYTHON_VERSION)/
$(CP) \
$(PKG_INSTALL_DIR)/host/bin/python \
$(1)/usr/bin/hostpython
(cd $(2)/bin; \
ln -sf ../../usr/bin/hostpython python$(PYTHON_VERSION); \
ln -sf python$(PYTHON_VERSION) python)
$(CP) \
$(PKG_INSTALL_DIR)/host/bin/python$(PYTHON_VERSION)-config \
$(2)/bin/
$(SED) 's,^#!.*,#!/usr/bin/env python2.5,g' $(2)/bin/python$(PYTHON_VERSION)-config
(cd $(2)/bin; \
ln -sf python$(PYTHON_VERSION)-config python-config;)
endef
define PyPackage/python/filespec

View File

@ -13,7 +13,7 @@ PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
PYTHON:=$(PYTHON_BIN_DIR)/python
PYTHON:=python$(PYTHON_VERSION)
PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages

View File

@ -0,0 +1,110 @@
diff -urN Python-2.5.1.orig/Include/pyerrors.h Python-2.5.1/Include/pyerrors.h
--- Python-2.5.1.orig/Include/pyerrors.h 2008-08-10 13:46:48.000000000 +0200
+++ Python-2.5.1/Include/pyerrors.h 2008-08-10 13:51:05.000000000 +0200
@@ -239,6 +239,9 @@
PyAPI_FUNC(int) PyErr_CheckSignals(void);
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
+/* In signalmodule.c */
+int PySignal_SetWakeupFd(int fd);
+
/* Support for adding program text to SyntaxErrors */
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
diff -urN Python-2.5.1.orig/Modules/signalmodule.c Python-2.5.1/Modules/signalmodule.c
--- Python-2.5.1.orig/Modules/signalmodule.c 2008-08-10 13:46:48.000000000 +0200
+++ Python-2.5.1/Modules/signalmodule.c 2008-08-10 13:50:02.000000000 +0200
@@ -12,6 +12,8 @@
#include <signal.h>
+#include <sys/stat.h>
+
#ifndef SIG_ERR
#define SIG_ERR ((PyOS_sighandler_t)(-1))
#endif
@@ -75,6 +77,8 @@
PyObject *func;
} Handlers[NSIG];
+static int wakeup_fd = -1;
+
static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
static PyObject *DefaultHandler;
@@ -112,6 +116,7 @@
static void
signal_handler(int sig_num)
{
+ const char dummy_byte = '\0';
#ifdef WITH_THREAD
#ifdef WITH_PTH
if (PyThread_get_thread_ident() != main_thread) {
@@ -125,6 +130,8 @@
is_tripped++;
Handlers[sig_num].tripped = 1;
Py_AddPendingCall(checksignals_witharg, NULL);
+ if (wakeup_fd != -1)
+ write(wakeup_fd, &dummy_byte, 1);
#ifdef WITH_THREAD
}
#endif
@@ -264,6 +271,50 @@
anything else -- the callable Python object used as a handler");
+static PyObject *
+signal_set_wakeup_fd(PyObject *self, PyObject *args)
+{
+ struct stat buf;
+ int fd, old_fd;
+ if (!PyArg_ParseTuple(args, "i:set_wakeup_fd", &fd))
+ return NULL;
+#ifdef WITH_THREAD
+ if (PyThread_get_thread_ident() != main_thread) {
+ PyErr_SetString(PyExc_ValueError,
+ "set_wakeup_fd only works in main thread");
+ return NULL;
+ }
+#endif
+ if (fd != -1 && fstat(fd, &buf) != 0) {
+ PyErr_SetString(PyExc_ValueError, "invalid fd");
+ return NULL;
+ }
+ old_fd = wakeup_fd;
+ wakeup_fd = fd;
+ return PyLong_FromLong(old_fd);
+}
+
+PyDoc_STRVAR(set_wakeup_fd_doc,
+"set_wakeup_fd(fd) -> fd\n\
+\n\
+Sets the fd to be written to (with '\\0') when a signal\n\
+comes in. A library can use this to wakeup select or poll.\n\
+The previous fd is returned.\n\
+\n\
+The fd must be non-blocking.");
+
+/* C API for the same, without all the error checking */
+int
+PySignal_SetWakeupFd(int fd)
+{
+ int old_fd = wakeup_fd;
+ if (fd < 0)
+ fd = -1;
+ wakeup_fd = fd;
+ return old_fd;
+}
+
+
/* List of functions defined in the module */
static PyMethodDef signal_methods[] = {
#ifdef HAVE_ALARM
@@ -271,6 +322,7 @@
#endif
{"signal", signal_signal, METH_VARARGS, signal_doc},
{"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc},
+ {"set_wakeup_fd", signal_set_wakeup_fd, METH_VARARGS, set_wakeup_fd_doc},
#ifdef HAVE_PAUSE
{"pause", (PyCFunction)signal_pause,
METH_NOARGS,pause_doc},