2014-09-24 08:08:37 +00:00
|
|
|
#
|
2016-04-14 08:41:48 +00:00
|
|
|
# Copyright (C) 2007-2016 OpenWrt.org
|
2014-09-24 08:08:37 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2018-01-10 07:29:41 +00:00
|
|
|
# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
|
|
|
|
python3_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
|
|
|
|
include $(python3_mk_path)python3-host.mk
|
2014-09-24 08:08:37 +00:00
|
|
|
|
2014-10-14 08:52:06 +00:00
|
|
|
PYTHON3_DIR:=$(STAGING_DIR)/usr
|
|
|
|
PYTHON3_BIN_DIR:=$(PYTHON3_DIR)/bin
|
|
|
|
PYTHON3_INC_DIR:=$(PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
|
|
|
|
PYTHON3_LIB_DIR:=$(PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
|
2014-09-24 08:08:37 +00:00
|
|
|
|
2014-10-14 08:52:06 +00:00
|
|
|
PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
|
2014-09-24 08:08:37 +00:00
|
|
|
|
2014-10-14 08:52:06 +00:00
|
|
|
PYTHON3:=python$(PYTHON3_VERSION)
|
2014-09-24 08:08:37 +00:00
|
|
|
|
2015-01-19 18:22:41 +00:00
|
|
|
PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
|
2014-09-24 08:08:37 +00:00
|
|
|
|
2015-11-18 16:57:16 +00:00
|
|
|
# These configure args are needed in detection of path to Python header files
|
|
|
|
# using autotools.
|
|
|
|
CONFIGURE_ARGS += \
|
|
|
|
_python_sysroot="$(STAGING_DIR)" \
|
|
|
|
_python_prefix="/usr" \
|
|
|
|
_python_exec_prefix="/usr"
|
|
|
|
|
2014-11-27 21:47:28 +00:00
|
|
|
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
|
|
|
|
|
2014-10-14 08:52:06 +00:00
|
|
|
define Py3Package
|
2015-01-19 18:22:41 +00:00
|
|
|
|
2017-03-02 16:02:14 +00:00
|
|
|
define Package/$(1)-src
|
|
|
|
$(call Package/$(1))
|
2018-01-17 15:30:48 +00:00
|
|
|
DEPENDS:=
|
2019-05-27 16:43:26 +00:00
|
|
|
CONFLICTS:=
|
|
|
|
PROVIDES:=
|
|
|
|
EXTRA_DEPENDS:=
|
2017-03-02 16:02:14 +00:00
|
|
|
TITLE+= (sources)
|
2019-05-27 16:43:26 +00:00
|
|
|
USERID:=
|
2019-07-09 12:12:06 +00:00
|
|
|
MENU:=
|
2017-03-02 16:02:14 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Package/$(1)-src/description
|
|
|
|
$(call Package/$(1)/description).
|
|
|
|
(Contains the Python3 sources for this package).
|
|
|
|
endef
|
|
|
|
|
2015-01-19 18:22:41 +00:00
|
|
|
# Add default PyPackage filespec none defined
|
|
|
|
ifndef Py3Package/$(1)/filespec
|
|
|
|
define Py3Package/$(1)/filespec
|
|
|
|
+|$(PYTHON3_PKG_DIR)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2017-01-04 09:27:36 +00:00
|
|
|
ifndef Py3Package/$(1)/install
|
|
|
|
define Py3Package/$(1)/install
|
|
|
|
if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
|
2017-03-07 12:50:19 +00:00
|
|
|
$(INSTALL_DIR) $$(1)/usr/bin ; \
|
|
|
|
$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
|
2017-01-04 09:27:36 +00:00
|
|
|
fi
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2017-05-19 14:16:38 +00:00
|
|
|
ifndef Package/$(1)/install
|
2014-10-14 08:52:06 +00:00
|
|
|
$(call shexport,Py3Package/$(1)/filespec)
|
2014-09-24 08:08:37 +00:00
|
|
|
|
|
|
|
define Package/$(1)/install
|
2019-02-18 08:23:45 +00:00
|
|
|
$$(call Py3Package/$(1)/install,$$(1))
|
2019-03-31 11:11:15 +00:00
|
|
|
SED="$(SED)" \
|
2018-01-10 07:52:18 +00:00
|
|
|
$(SHELL) $(python3_mk_path)python-package-install.sh "3" \
|
2018-01-10 07:43:00 +00:00
|
|
|
"$(PKG_INSTALL_DIR)" "$$(1)" \
|
|
|
|
"$(HOST_PYTHON3_BIN)" "$$(2)" \
|
|
|
|
"$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)"
|
2014-09-24 08:08:37 +00:00
|
|
|
endef
|
2017-03-02 16:02:14 +00:00
|
|
|
|
|
|
|
define Package/$(1)-src/install
|
|
|
|
$$(call Package/$(1)/install,$$(1),sources)
|
|
|
|
endef
|
2017-05-19 14:16:38 +00:00
|
|
|
endif # Package/$(1)/install
|
2014-09-24 08:08:37 +00:00
|
|
|
endef
|
|
|
|
|
2017-01-04 09:27:36 +00:00
|
|
|
# $(1) => commands to execute before running pythons script
|
|
|
|
# $(2) => python script and its arguments
|
2014-09-24 08:08:37 +00:00
|
|
|
# $(3) => additional variables
|
2017-01-04 09:27:36 +00:00
|
|
|
define Build/Compile/HostPy3RunTarget
|
2014-10-14 08:52:06 +00:00
|
|
|
$(call HostPython3, \
|
2017-01-04 09:27:36 +00:00
|
|
|
$(if $(1),$(1);) \
|
2014-10-18 21:45:59 +00:00
|
|
|
CC="$(TARGET_CC)" \
|
|
|
|
CCSHARED="$(TARGET_CC) $(FPIC)" \
|
2017-01-04 09:27:36 +00:00
|
|
|
CXX="$(TARGET_CXX)" \
|
2014-10-19 07:21:03 +00:00
|
|
|
LD="$(TARGET_CC)" \
|
|
|
|
LDSHARED="$(TARGET_CC) -shared" \
|
2014-09-24 08:08:37 +00:00
|
|
|
CFLAGS="$(TARGET_CFLAGS)" \
|
2014-10-19 07:03:44 +00:00
|
|
|
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
|
2014-10-19 07:21:03 +00:00
|
|
|
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
|
2015-01-19 18:22:41 +00:00
|
|
|
_PYTHON_HOST_PLATFORM=linux2 \
|
2014-11-27 21:47:28 +00:00
|
|
|
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
|
2014-09-24 08:08:37 +00:00
|
|
|
$(3) \
|
|
|
|
, \
|
2017-01-04 09:27:36 +00:00
|
|
|
$(2) \
|
2014-09-24 08:08:37 +00:00
|
|
|
)
|
2017-01-04 09:27:36 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1) => build subdir
|
|
|
|
# $(2) => additional arguments to setup.py
|
|
|
|
# $(3) => additional variables
|
|
|
|
define Build/Compile/Py3Mod
|
|
|
|
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
|
|
|
|
$(call Build/Compile/HostPy3RunTarget, \
|
|
|
|
cd $(PKG_BUILD_DIR)/$(strip $(1)), \
|
|
|
|
./setup.py $(2), \
|
|
|
|
$(3))
|
2014-09-24 08:08:37 +00:00
|
|
|
endef
|
2015-01-19 18:22:41 +00:00
|
|
|
|
2019-02-21 11:52:07 +00:00
|
|
|
PYTHON3_PKG_SETUP_DIR ?=
|
2019-04-05 08:44:55 +00:00
|
|
|
PYTHON3_PKG_SETUP_GLOABL_ARGS ?=
|
2019-02-19 09:00:09 +00:00
|
|
|
PYTHON3_PKG_SETUP_ARGS ?= --single-version-externally-managed
|
|
|
|
PYTHON3_PKG_SETUP_VARS ?=
|
2018-01-15 20:10:49 +00:00
|
|
|
|
2017-01-04 09:27:36 +00:00
|
|
|
define Py3Build/Compile/Default
|
2019-05-29 13:45:16 +00:00
|
|
|
$(if $(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS),
|
|
|
|
$(call Build/Compile/HostPy3PipInstall,$(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS))
|
2017-07-19 07:19:10 +00:00
|
|
|
)
|
2019-02-21 11:52:07 +00:00
|
|
|
$(call Build/Compile/Py3Mod, \
|
|
|
|
$(PYTHON3_PKG_SETUP_DIR), \
|
2019-04-05 08:44:55 +00:00
|
|
|
$(PYTHON3_PKG_SETUP_GLOBAL_ARGS) \
|
2017-01-04 09:27:36 +00:00
|
|
|
install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
|
2018-01-15 20:10:49 +00:00
|
|
|
$(PYTHON3_PKG_SETUP_ARGS), \
|
|
|
|
$(PYTHON3_PKG_SETUP_VARS) \
|
2017-01-04 09:27:36 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2017-07-04 17:58:37 +00:00
|
|
|
Py3Build/Compile=$(Py3Build/Compile/Default)
|
|
|
|
|
2017-01-04 09:27:36 +00:00
|
|
|
ifeq ($(BUILD_VARIANT),python3)
|
|
|
|
define Build/Compile
|
2017-07-04 17:58:37 +00:00
|
|
|
$(call Py3Build/Compile)
|
2017-01-04 09:27:36 +00:00
|
|
|
endef
|
|
|
|
endif # python3
|