Merge pull request #572 from commodo/python3-sync-build
python3: sync build rules with python's
This commit is contained in:
commit
d2743c9d0f
2 changed files with 85 additions and 78 deletions
|
@ -31,7 +31,7 @@ HOST_BUILD_PARALLEL:=1
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
|
||||||
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
|
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
|
||||||
|
|
||||||
PKG_BUILD_DEPENDS:=python3/host
|
PKG_BUILD_DEPENDS:=libffi/host python3/host
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/host-build.mk
|
include $(INCLUDE_DIR)/host-build.mk
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
@ -54,69 +54,62 @@ define Package/python3/Default/description
|
||||||
the development of higher quality, more maintainable code.
|
the development of higher quality, more maintainable code.
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/python3
|
define Package/python3-base
|
||||||
$(call Package/python3/Default)
|
$(call Package/python3/Default)
|
||||||
|
TITLE:=Python $(PYTHON_VERSION) interpreter
|
||||||
DEPENDS:=+libpthread +zlib +libffi
|
DEPENDS:=+libpthread +zlib +libffi
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/python3/description
|
define Package/python3-base/description
|
||||||
$(call Package/python3/Default/description)
|
This package contains only the interpreter and the bare minimum
|
||||||
.
|
for the interpreter to start.
|
||||||
This package contains only the interpreter and the bare minimum for the interpreter to start.
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
MAKE_FLAGS:=\
|
define Package/python3
|
||||||
$(TARGET_CONFIGURE_OPTS) \
|
$(call Package/python3/Default)
|
||||||
DESTDIR="$(PKG_INSTALL_DIR)" \
|
DEPENDS:=+python3-base +libncursesw +libbz2 +libgdbm +libsqlite3 +libdb47 +libopenssl
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/python3/description
|
||||||
|
This package contains the (almost) full Python install.
|
||||||
|
endef
|
||||||
|
|
||||||
|
MAKE_FLAGS+=\
|
||||||
CROSS_COMPILE=yes \
|
CROSS_COMPILE=yes \
|
||||||
CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
|
LD="$(TARGET_CC)" \
|
||||||
LDFLAGS="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR)" \
|
PGEN=pgen3
|
||||||
LD="$(TARGET_CC)"
|
|
||||||
|
EXTRA_CFLAGS+= \
|
||||||
|
-DNDEBUG -fno-inline
|
||||||
|
EXTRA_LDFLAGS+= \
|
||||||
|
-L$(PKG_BUILD_DIR)
|
||||||
|
|
||||||
ENABLE_IPV6:=
|
ENABLE_IPV6:=
|
||||||
ifeq ($(CONFIG_IPV6),y)
|
ifeq ($(CONFIG_IPV6),y)
|
||||||
ENABLE_IPV6 += --enable-ipv6
|
ENABLE_IPV6 += --enable-ipv6
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#=======================================================================
|
CONFIGURE_ARGS+= \
|
||||||
# Notes: adding these so that I don't forget, and can track why stuff
|
|
||||||
# was did as was did
|
|
||||||
# - Arguments below were moved to ./files/config.site file, and disabled
|
|
||||||
# ac_cv_have_chflags=no \
|
|
||||||
# ac_cv_have_lchflags=no \
|
|
||||||
# ac_cv_py_format_size_t=no \
|
|
||||||
# ac_cv_have_long_long_format=yes \
|
|
||||||
# ac_cv_buggy_getaddrinfo=no \
|
|
||||||
# - --without-ensurepip added, because the build wants to ensure that
|
|
||||||
# it works; that's a good idea, but for now, it requires special
|
|
||||||
# setup, and we can do that later
|
|
||||||
# - --without-pymalloc added, becase in Python 3, modules are suffixed
|
|
||||||
# with m; e.g. so some paths are python3.4m instead of python3.4
|
|
||||||
# all this is detailed here:
|
|
||||||
# http://legacy.python.org/dev/peps/pep-3149/
|
|
||||||
#=======================================================================
|
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
-$(MAKE) -C $(PKG_BUILD_DIR) distclean
|
|
||||||
(cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
|
|
||||||
$(CP) ./files/config.site $(PKG_BUILD_DIR)
|
|
||||||
$(call Build/Configure/Default, \
|
|
||||||
--sysconfdir=/etc \
|
--sysconfdir=/etc \
|
||||||
--enable-shared \
|
--enable-shared \
|
||||||
--without-cxx-main \
|
--without-cxx-main \
|
||||||
--with-threads \
|
--with-threads \
|
||||||
--with-system-ffi="$(STAGING_DIR)/usr" \
|
--with-system-ffi="$(STAGING_DIR)/usr" \
|
||||||
--without-ensurepip \
|
|
||||||
--without-pymalloc \
|
--without-pymalloc \
|
||||||
|
--without-ensurepip \
|
||||||
$(ENABLE_IPV6) \
|
$(ENABLE_IPV6) \
|
||||||
CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
|
CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
|
||||||
OPT="$(TARGET_CFLAGS)" \
|
OPT="$(TARGET_CFLAGS)"
|
||||||
)
|
|
||||||
|
define Build/Prepare
|
||||||
|
$(call Build/Prepare/Default)
|
||||||
|
$(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/InstallDev
|
define Build/InstallDev
|
||||||
$(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
|
|
||||||
$(INSTALL_DIR) $(STAGING_DIR)/mk/
|
$(INSTALL_DIR) $(STAGING_DIR)/mk/
|
||||||
|
$(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
|
||||||
$(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
|
$(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
|
||||||
$(CP) \
|
$(CP) \
|
||||||
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
|
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
|
||||||
|
@ -128,14 +121,9 @@ define Build/InstallDev
|
||||||
$(CP) \
|
$(CP) \
|
||||||
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
|
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
|
||||||
$(1)/usr/lib/python$(PYTHON_VERSION)/
|
$(1)/usr/lib/python$(PYTHON_VERSION)/
|
||||||
|
|
||||||
$(CP) \
|
|
||||||
$(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
|
|
||||||
$(2)/bin/
|
|
||||||
$(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Py3Package/python3/filespec
|
define Py3Package/python3-base/filespec
|
||||||
+|/usr/bin/python$(PYTHON_VERSION)
|
+|/usr/bin/python$(PYTHON_VERSION)
|
||||||
+|/usr/lib/python$(PYTHON_VERSION)/encodings
|
+|/usr/lib/python$(PYTHON_VERSION)/encodings
|
||||||
+|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
|
+|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
|
||||||
|
@ -153,7 +141,25 @@ define Py3Package/python3/filespec
|
||||||
+|/usr/lib/python$(PYTHON_VERSION)/stat.py
|
+|/usr/lib/python$(PYTHON_VERSION)/stat.py
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Py3Package/python3/install
|
define Py3Package/python3/filespec
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION)
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/idlelib
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/lib2to3
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/tkinter
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/turtledemo
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/test
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/*/test
|
||||||
|
-|/usr/lib/python$(PYTHON_VERSION)/*/tests
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Py3Package/python3-base/install
|
||||||
# Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
|
# Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
|
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
@ -161,39 +167,30 @@ define Py3Package/python3/install
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
|
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Host/Configure
|
HOST_CONFIGURE_ARGS+= \
|
||||||
-$(MAKE) -C $(HOST_BUILD_DIR) distclean
|
|
||||||
(cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
|
|
||||||
(cd $(HOST_BUILD_DIR); \
|
|
||||||
rm -rf config.cache; \
|
|
||||||
CONFIG_SITE= \
|
|
||||||
OPT="$(HOST_CFLAGS)" \
|
|
||||||
./configure \
|
|
||||||
--without-cxx-main \
|
--without-cxx-main \
|
||||||
--without-ensurepip \
|
|
||||||
--without-pymalloc \
|
--without-pymalloc \
|
||||||
|
--without-ensurepip \
|
||||||
--with-threads \
|
--with-threads \
|
||||||
--prefix=$(STAGING_DIR_HOST); \
|
--prefix=$(STAGING_DIR_HOST) \
|
||||||
)
|
CONFIG_SITE= \
|
||||||
endef
|
OPT="$(HOST_CFLAGS)"
|
||||||
|
|
||||||
define Host/Compile
|
define Host/Compile
|
||||||
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
|
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
|
||||||
python Parser/pgen
|
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
|
||||||
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
|
|
||||||
sharedmods
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Host/Install
|
define Host/Install
|
||||||
$(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
|
$(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
|
||||||
$(MAKE) -C $(HOST_BUILD_DIR) \
|
$(MAKE) -C $(HOST_BUILD_DIR) install
|
||||||
install
|
$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen3
|
||||||
$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
$(eval $(call HostBuild))
|
$(eval $(call HostBuild))
|
||||||
|
|
||||||
|
$(eval $(call Py3Package,python3-base))
|
||||||
$(eval $(call Py3Package,python3))
|
$(eval $(call Py3Package,python3))
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,python3-base))
|
||||||
$(eval $(call BuildPackage,python3))
|
$(eval $(call BuildPackage,python3))
|
||||||
|
|
|
@ -17,10 +17,12 @@ PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
|
||||||
|
|
||||||
PYTHON3:=python$(PYTHON3_VERSION)
|
PYTHON3:=python$(PYTHON3_VERSION)
|
||||||
|
|
||||||
|
HOST_PYTHON3_LIB_DIR:=$(STAGING_DIR_HOST)/lib/python$(PYTHON3_VERSION)
|
||||||
HOST_PYTHON3_BIN:=$(STAGING_DIR_HOST)/bin/python3
|
HOST_PYTHON3_BIN:=$(STAGING_DIR_HOST)/bin/python3
|
||||||
|
|
||||||
|
PYTHON3PATH="$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR)"
|
||||||
define HostPython3
|
define HostPython3
|
||||||
( export PYTHONPATH="$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR)"; \
|
( export PYTHONPATH="$(PYTHON3PATH)"; \
|
||||||
export PYTHONOPTIMIZE=""; \
|
export PYTHONOPTIMIZE=""; \
|
||||||
export PYTHONDONTWRITEBYTECODE=1; \
|
export PYTHONDONTWRITEBYTECODE=1; \
|
||||||
$(1) \
|
$(1) \
|
||||||
|
@ -28,12 +30,19 @@ define HostPython3
|
||||||
)
|
)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
|
||||||
|
# flags are inherited from the Python base package (via sysconfig module)
|
||||||
|
ifdef CONFIG_USE_MIPS16
|
||||||
|
TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
|
||||||
|
endif
|
||||||
|
|
||||||
define Py3Package
|
define Py3Package
|
||||||
$(call shexport,Py3Package/$(1)/filespec)
|
$(call shexport,Py3Package/$(1)/filespec)
|
||||||
|
|
||||||
define Package/$(1)/install
|
define Package/$(1)/install
|
||||||
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
|
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
|
||||||
@echo "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" | ( \
|
@echo "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" | ( \
|
||||||
IFS='|'; \
|
IFS='|'; \
|
||||||
while read fop fspec fperm; do \
|
while read fop fspec fperm; do \
|
||||||
if [ "$$$$$$$$fop" = "+" ]; then \
|
if [ "$$$$$$$$fop" = "+" ]; then \
|
||||||
|
@ -80,6 +89,7 @@ define Build/Compile/Py3Mod
|
||||||
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
|
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
|
||||||
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
|
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
|
||||||
_PYTHON_HOST_PLATFORM="linux-$(ARCH)" \
|
_PYTHON_HOST_PLATFORM="linux-$(ARCH)" \
|
||||||
|
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
|
||||||
$(3) \
|
$(3) \
|
||||||
, \
|
, \
|
||||||
./setup.py $(2) \
|
./setup.py $(2) \
|
||||||
|
|
Loading…
Reference in a new issue