Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 1 | ################################################################################ |
| 2 | # Python package infrastructure |
| 3 | # |
| 4 | # This file implements an infrastructure that eases development of |
| 5 | # package .mk files for Python packages. It should be used for all |
| 6 | # packages that use Python setup.py/setuptools as their build system. |
| 7 | # |
| 8 | # See the Buildroot documentation for details on the usage of this |
| 9 | # infrastructure |
| 10 | # |
| 11 | # In terms of implementation, this Python infrastructure requires the |
Thomas De Schampheleire | 60714bb | 2014-07-24 20:07:02 +0200 | [diff] [blame] | 12 | # .mk file to only specify metadata information about the package: |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 13 | # name, version, download URL, etc. |
| 14 | # |
| 15 | # We still allow the package .mk file to override what the different |
| 16 | # steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is |
| 17 | # already defined, it is used as the list of commands to perform to |
| 18 | # build the package, instead of the default Python behaviour. The |
| 19 | # package can also define some post operation hooks. |
| 20 | # |
| 21 | ################################################################################ |
| 22 | |
Andrey Smirnov | d2afa01 | 2017-03-23 08:21:12 -0700 | [diff] [blame] | 23 | define PKG_PYTHON_SYSCONFIGDATA_NAME |
| 24 | $(basename $(notdir $(wildcard $(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/_sysconfigdata_m_linux_*.py))) |
| 25 | endef |
| 26 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 27 | # Target distutils-based packages |
| 28 | PKG_PYTHON_DISTUTILS_ENV = \ |
Samuel Martin | 8445501 | 2014-04-15 00:31:06 +0200 | [diff] [blame] | 29 | PATH=$(BR_PATH) \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 30 | CC="$(TARGET_CC)" \ |
| 31 | CFLAGS="$(TARGET_CFLAGS)" \ |
| 32 | LDFLAGS="$(TARGET_LDFLAGS)" \ |
| 33 | LDSHARED="$(TARGET_CROSS)gcc -shared" \ |
Thomas Petazzoni | 24cbcf1 | 2014-02-18 21:40:03 +0100 | [diff] [blame] | 34 | PYTHONPATH="$(if $(BR2_PACKAGE_PYTHON3),$(PYTHON3_PATH),$(PYTHON_PATH))" \ |
Yegor Yefremov | f5da195 | 2017-04-06 20:46:08 +0200 | [diff] [blame] | 35 | PYTHONNOUSERSITE=1 \ |
Andrey Smirnov | d2afa01 | 2017-03-23 08:21:12 -0700 | [diff] [blame] | 36 | _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 37 | _python_sysroot=$(STAGING_DIR) \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 38 | _python_prefix=/usr \ |
| 39 | _python_exec_prefix=/usr |
| 40 | |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 41 | PKG_PYTHON_DISTUTILS_BUILD_OPTS = \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 42 | --executable=/usr/bin/python |
| 43 | |
Thomas De Schampheleire | 57f2b8d | 2014-09-27 21:32:40 +0200 | [diff] [blame] | 44 | PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS = \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 45 | --prefix=/usr \ |
| 46 | --root=$(TARGET_DIR) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 47 | |
Thomas De Schampheleire | d6c32da | 2014-09-27 21:32:41 +0200 | [diff] [blame] | 48 | PKG_PYTHON_DISTUTILS_INSTALL_STAGING_OPTS = \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 49 | --prefix=/usr \ |
| 50 | --root=$(STAGING_DIR) |
Thomas Petazzoni | 643627f | 2014-07-16 22:23:59 +0200 | [diff] [blame] | 51 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 52 | # Host distutils-based packages |
| 53 | HOST_PKG_PYTHON_DISTUTILS_ENV = \ |
Yegor Yefremov | f5da195 | 2017-04-06 20:46:08 +0200 | [diff] [blame] | 54 | PATH=$(BR_PATH) \ |
| 55 | PYTHONNOUSERSITE=1 |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 56 | |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 57 | HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS = \ |
Arnout Vandecappelle | 048689b | 2017-07-04 16:04:03 +0200 | [diff] [blame] | 58 | --prefix=$(HOST_DIR) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 59 | |
| 60 | # Target setuptools-based packages |
| 61 | PKG_PYTHON_SETUPTOOLS_ENV = \ |
Andrey Smirnov | d2afa01 | 2017-03-23 08:21:12 -0700 | [diff] [blame] | 62 | _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ |
Samuel Martin | 8445501 | 2014-04-15 00:31:06 +0200 | [diff] [blame] | 63 | PATH=$(BR_PATH) \ |
Thomas Petazzoni | 24cbcf1 | 2014-02-18 21:40:03 +0100 | [diff] [blame] | 64 | PYTHONPATH="$(if $(BR2_PACKAGE_PYTHON3),$(PYTHON3_PATH),$(PYTHON_PATH))" \ |
Yegor Yefremov | f5da195 | 2017-04-06 20:46:08 +0200 | [diff] [blame] | 65 | PYTHONNOUSERSITE=1 \ |
Thomas Petazzoni | b07b9d1 | 2013-12-22 18:02:10 +0100 | [diff] [blame] | 66 | _python_sysroot=$(STAGING_DIR) \ |
| 67 | _python_prefix=/usr \ |
| 68 | _python_exec_prefix=/usr |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 69 | |
Thomas De Schampheleire | 57f2b8d | 2014-09-27 21:32:40 +0200 | [diff] [blame] | 70 | PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 71 | --prefix=/usr \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 72 | --executable=/usr/bin/python \ |
| 73 | --single-version-externally-managed \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 74 | --root=$(TARGET_DIR) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 75 | |
Thomas De Schampheleire | d6c32da | 2014-09-27 21:32:41 +0200 | [diff] [blame] | 76 | PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 77 | --prefix=/usr \ |
Thomas Petazzoni | 643627f | 2014-07-16 22:23:59 +0200 | [diff] [blame] | 78 | --executable=/usr/bin/python \ |
| 79 | --single-version-externally-managed \ |
Angelo Compagnucci | e94280e | 2018-11-25 00:21:39 +0100 | [diff] [blame] | 80 | --root=$(STAGING_DIR) |
Thomas Petazzoni | 643627f | 2014-07-16 22:23:59 +0200 | [diff] [blame] | 81 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 82 | # Host setuptools-based packages |
| 83 | HOST_PKG_PYTHON_SETUPTOOLS_ENV = \ |
Yegor Yefremov | f5da195 | 2017-04-06 20:46:08 +0200 | [diff] [blame] | 84 | PATH=$(BR_PATH) \ |
| 85 | PYTHONNOUSERSITE=1 |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 86 | |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 87 | HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \ |
Thomas Petazzoni | c577ad6 | 2018-12-28 18:01:31 +0100 | [diff] [blame] | 88 | --prefix=$(HOST_DIR) \ |
| 89 | --root=/ \ |
| 90 | --single-version-externally-managed |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 91 | |
| 92 | ################################################################################ |
| 93 | # inner-python-package -- defines how the configuration, compilation |
| 94 | # and installation of a Python package should be done, implements a |
| 95 | # few hooks to tune the build process and calls the generic package |
| 96 | # infrastructure to generate the necessary make targets |
| 97 | # |
| 98 | # argument 1 is the lowercase package name |
Thomas De Schampheleire | 5bd9ed6 | 2014-07-24 20:57:41 +0200 | [diff] [blame] | 99 | # argument 2 is the uppercase package name, including a HOST_ prefix |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 100 | # for host packages |
| 101 | # argument 3 is the uppercase package name, without the HOST_ prefix |
| 102 | # for host packages |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 103 | # argument 4 is the type (target or host) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 104 | ################################################################################ |
| 105 | |
| 106 | define inner-python-package |
| 107 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 108 | $(2)_ENV ?= |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 109 | $(2)_BUILD_OPTS ?= |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 110 | $(2)_INSTALL_OPTS ?= |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 111 | |
| 112 | ifndef $(2)_SETUP_TYPE |
| 113 | ifdef $(3)_SETUP_TYPE |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 114 | $(2)_SETUP_TYPE = $$($(3)_SETUP_TYPE) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 115 | else |
Peter Korsgaard | 27bc886 | 2013-12-15 16:17:28 +0100 | [diff] [blame] | 116 | $$(error "$(2)_SETUP_TYPE must be set") |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 117 | endif |
| 118 | endif |
| 119 | |
| 120 | # Distutils |
| 121 | ifeq ($$($(2)_SETUP_TYPE),distutils) |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 122 | ifeq ($(4),target) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 123 | $(2)_BASE_ENV = $$(PKG_PYTHON_DISTUTILS_ENV) |
| 124 | $(2)_BASE_BUILD_TGT = build |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 125 | $(2)_BASE_BUILD_OPTS = $$(PKG_PYTHON_DISTUTILS_BUILD_OPTS) |
Thomas De Schampheleire | 57f2b8d | 2014-09-27 21:32:40 +0200 | [diff] [blame] | 126 | $(2)_BASE_INSTALL_TARGET_OPTS = $$(PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS) |
Thomas De Schampheleire | d6c32da | 2014-09-27 21:32:41 +0200 | [diff] [blame] | 127 | $(2)_BASE_INSTALL_STAGING_OPTS = $$(PKG_PYTHON_DISTUTILS_INSTALL_STAGING_OPTS) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 128 | else |
| 129 | $(2)_BASE_ENV = $$(HOST_PKG_PYTHON_DISTUTILS_ENV) |
| 130 | $(2)_BASE_BUILD_TGT = build |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 131 | $(2)_BASE_BUILD_OPTS = |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 132 | $(2)_BASE_INSTALL_OPTS = $$(HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 133 | endif |
| 134 | # Setuptools |
| 135 | else ifeq ($$($(2)_SETUP_TYPE),setuptools) |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 136 | ifeq ($(4),target) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 137 | $(2)_BASE_ENV = $$(PKG_PYTHON_SETUPTOOLS_ENV) |
Thomas Petazzoni | c7bf337 | 2014-02-18 21:39:54 +0100 | [diff] [blame] | 138 | $(2)_BASE_BUILD_TGT = build |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 139 | $(2)_BASE_BUILD_OPTS = |
Thomas De Schampheleire | 57f2b8d | 2014-09-27 21:32:40 +0200 | [diff] [blame] | 140 | $(2)_BASE_INSTALL_TARGET_OPTS = $$(PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS) |
Thomas De Schampheleire | d6c32da | 2014-09-27 21:32:41 +0200 | [diff] [blame] | 141 | $(2)_BASE_INSTALL_STAGING_OPTS = $$(PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 142 | else |
| 143 | $(2)_BASE_ENV = $$(HOST_PKG_PYTHON_SETUPTOOLS_ENV) |
| 144 | $(2)_BASE_BUILD_TGT = build |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 145 | $(2)_BASE_BUILD_OPTS = |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 146 | $(2)_BASE_INSTALL_OPTS = $$(HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 147 | endif |
Peter Korsgaard | 27bc886 | 2013-12-15 16:17:28 +0100 | [diff] [blame] | 148 | else |
| 149 | $$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'distutils' or 'setuptools'") |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 150 | endif |
| 151 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 152 | # Target packages need both the python interpreter on the target (for |
| 153 | # runtime) and the python interpreter on the host (for |
| 154 | # compilation). However, host packages only need the python |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 155 | # interpreter on the host, whose version may be enforced by setting |
| 156 | # the *_NEEDS_HOST_PYTHON variable. |
| 157 | # |
| 158 | # So: |
| 159 | # - for target packages, we always depend on the default python interpreter |
| 160 | # (the one selected by the config); |
| 161 | # - for host packages: |
| 162 | # - if *_NEEDS_HOST_PYTHON is not set, then we depend on use the default |
| 163 | # interperter; |
| 164 | # - otherwise, we depend on the one requested by *_NEEDS_HOST_PYTHON. |
| 165 | # |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 166 | ifeq ($(4),target) |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 167 | $(2)_DEPENDENCIES += $$(if $$(BR2_PACKAGE_PYTHON3),host-python3 python3,host-python python) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 168 | else |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 169 | ifeq ($$($(2)_NEEDS_HOST_PYTHON),) |
| 170 | $(2)_DEPENDENCIES += $$(if $$(BR2_PACKAGE_PYTHON3),host-python3,host-python) |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 171 | else |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 172 | ifeq ($$($(2)_NEEDS_HOST_PYTHON),python2) |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 173 | $(2)_DEPENDENCIES += host-python |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 174 | else ifeq ($$($(2)_NEEDS_HOST_PYTHON),python3) |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 175 | $(2)_DEPENDENCIES += host-python3 |
| 176 | else |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 177 | $$(error Incorrect value '$$($(2)_NEEDS_HOST_PYTHON)' for $(2)_NEEDS_HOST_PYTHON) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 178 | endif |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 179 | endif # ($$($(2)_NEEDS_HOST_PYTHON),) |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 180 | endif # ($(4),target) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 181 | |
Thomas Petazzoni | f75239d | 2018-12-28 18:01:30 +0100 | [diff] [blame] | 182 | # Setuptools based packages will need setuptools for the host Python |
| 183 | # interpreter (both host and target). |
| 184 | # |
| 185 | # If we have a host package that says "I need Python 3", we install |
| 186 | # setuptools for python3. |
| 187 | # |
| 188 | # If we have a host packge that says "I need Python 2", we install |
| 189 | # setuptools for python2. |
| 190 | # |
| 191 | # If we have a target package, or a host package that doesn't have any |
| 192 | # <pkg>_NEEDS_HOST_PYTHON, and BR2_PACKAGE_PYTHON3 is used, then |
| 193 | # Python 3.x is the default Python interpreter, so we install |
| 194 | # setuptools for python3. |
| 195 | # |
| 196 | # In all other cases, we install setuptools for python2. Those other |
| 197 | # cases are: a target package or host package with |
| 198 | # BR2_PACKAGE_PYTHON=y, or a host-package with neither |
| 199 | # BR2_PACKAGE_PYTHON3=y or BR2_PACKAGE_PYTHON=y. |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 200 | ifeq ($$($(2)_SETUP_TYPE),setuptools) |
Thomas Petazzoni | f75239d | 2018-12-28 18:01:30 +0100 | [diff] [blame] | 201 | ifeq ($(4):$$($(2)_NEEDS_HOST_PYTHON),host:python3) |
| 202 | $(2)_DEPENDENCIES += $$(if $$(filter host-python3-setuptools,$(1)),,host-python3-setuptools) |
| 203 | else ifeq ($(4):$$($(2)_NEEDS_HOST_PYTHON),host:python2) |
| 204 | $(2)_DEPENDENCIES += $$(if $$(filter host-python-setuptools,$(1)),,host-python-setuptools) |
| 205 | else ifeq ($$(BR2_PACKAGE_PYTHON3),y) |
| 206 | $(2)_DEPENDENCIES += $$(if $$(filter host-python3-setuptools,$(1)),,host-python3-setuptools) |
| 207 | else |
| 208 | $(2)_DEPENDENCIES += $$(if $$(filter host-python-setuptools,$(1)),,host-python-setuptools) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 209 | endif |
Thomas Petazzoni | f75239d | 2018-12-28 18:01:30 +0100 | [diff] [blame] | 210 | endif # SETUP_TYPE |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 211 | |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 212 | # Python interpreter to use for building the package. |
| 213 | # |
Bernd Kuhls | 017f53d | 2014-04-12 13:57:15 +0200 | [diff] [blame] | 214 | # We may want to specify the python interpreter to be used for building a |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 215 | # package, especially for host-packages (target packages must be built using |
| 216 | # the same version of the interpreter as the one installed on the target). |
| 217 | # |
| 218 | # So: |
| 219 | # - for target packages, we always use the default python interpreter (which |
| 220 | # is the same version as the one built and installed on the target); |
| 221 | # - for host packages: |
| 222 | # - if *_NEEDS_HOST_PYTHON is not set, then we use use the default |
| 223 | # interperter; |
| 224 | # - otherwise, we use the one requested by *_NEEDS_HOST_PYTHON. |
| 225 | # |
| 226 | ifeq ($(4),target) |
Arnout Vandecappelle | 0f9c0bf | 2017-07-05 13:14:19 +0200 | [diff] [blame] | 227 | $(2)_PYTHON_INTERPRETER = $$(HOST_DIR)/bin/python |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 228 | else |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 229 | ifeq ($$($(2)_NEEDS_HOST_PYTHON),) |
Arnout Vandecappelle | 0f9c0bf | 2017-07-05 13:14:19 +0200 | [diff] [blame] | 230 | $(2)_PYTHON_INTERPRETER = $$(HOST_DIR)/bin/python |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 231 | else |
Arnout Vandecappelle | 0f9c0bf | 2017-07-05 13:14:19 +0200 | [diff] [blame] | 232 | $(2)_PYTHON_INTERPRETER = $$(HOST_DIR)/bin/$$($(2)_NEEDS_HOST_PYTHON) |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 233 | endif |
| 234 | endif |
| 235 | |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 236 | # |
| 237 | # Build step. Only define it if not already defined by the package .mk |
| 238 | # file. |
| 239 | # |
| 240 | ifndef $(2)_BUILD_CMDS |
| 241 | define $(2)_BUILD_CMDS |
| 242 | (cd $$($$(PKG)_BUILDDIR)/; \ |
| 243 | $$($$(PKG)_BASE_ENV) $$($$(PKG)_ENV) \ |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 244 | $$($(2)_PYTHON_INTERPRETER) setup.py \ |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 245 | $$($$(PKG)_BASE_BUILD_TGT) \ |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 246 | $$($$(PKG)_BASE_BUILD_OPTS) $$($$(PKG)_BUILD_OPTS)) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 247 | endef |
| 248 | endif |
| 249 | |
| 250 | # |
| 251 | # Host installation step. Only define it if not already defined by the |
| 252 | # package .mk file. |
| 253 | # |
| 254 | ifndef $(2)_INSTALL_CMDS |
| 255 | define $(2)_INSTALL_CMDS |
| 256 | (cd $$($$(PKG)_BUILDDIR)/; \ |
| 257 | $$($$(PKG)_BASE_ENV) $$($$(PKG)_ENV) \ |
Samuel Martin | 05754fa | 2014-03-05 23:04:42 +0100 | [diff] [blame] | 258 | $$($(2)_PYTHON_INTERPRETER) setup.py install \ |
Thomas De Schampheleire | b199343 | 2014-09-27 21:32:39 +0200 | [diff] [blame] | 259 | $$($$(PKG)_BASE_INSTALL_OPTS) $$($$(PKG)_INSTALL_OPTS)) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 260 | endef |
| 261 | endif |
| 262 | |
| 263 | # |
| 264 | # Target installation step. Only define it if not already defined by |
| 265 | # the package .mk file. |
| 266 | # |
| 267 | ifndef $(2)_INSTALL_TARGET_CMDS |
| 268 | define $(2)_INSTALL_TARGET_CMDS |
| 269 | (cd $$($$(PKG)_BUILDDIR)/; \ |
| 270 | $$($$(PKG)_BASE_ENV) $$($$(PKG)_ENV) \ |
Yegor Yefremov | 549bbba | 2016-05-17 23:19:15 +0200 | [diff] [blame] | 271 | $$($(2)_PYTHON_INTERPRETER) setup.py install --no-compile \ |
Thomas De Schampheleire | 57f2b8d | 2014-09-27 21:32:40 +0200 | [diff] [blame] | 272 | $$($$(PKG)_BASE_INSTALL_TARGET_OPTS) \ |
| 273 | $$($$(PKG)_INSTALL_TARGET_OPTS)) |
Thomas Petazzoni | 643627f | 2014-07-16 22:23:59 +0200 | [diff] [blame] | 274 | endef |
| 275 | endif |
| 276 | |
| 277 | # |
| 278 | # Staging installation step. Only define it if not already defined by |
| 279 | # the package .mk file. |
| 280 | # |
| 281 | ifndef $(2)_INSTALL_STAGING_CMDS |
| 282 | define $(2)_INSTALL_STAGING_CMDS |
| 283 | (cd $$($$(PKG)_BUILDDIR)/; \ |
| 284 | $$($$(PKG)_BASE_ENV) $$($$(PKG)_ENV) \ |
| 285 | $$($(2)_PYTHON_INTERPRETER) setup.py install \ |
Thomas De Schampheleire | d6c32da | 2014-09-27 21:32:41 +0200 | [diff] [blame] | 286 | $$($$(PKG)_BASE_INSTALL_STAGING_OPTS) \ |
| 287 | $$($$(PKG)_INSTALL_STAGING_OPTS)) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 288 | endef |
| 289 | endif |
| 290 | |
| 291 | # Call the generic package infrastructure to generate the necessary |
| 292 | # make targets |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 293 | $(call inner-generic-package,$(1),$(2),$(3),$(4)) |
Thomas Petazzoni | a6bba67 | 2013-12-11 21:26:36 +0100 | [diff] [blame] | 294 | |
| 295 | endef |
| 296 | |
| 297 | ################################################################################ |
| 298 | # python-package -- the target generator macro for Python packages |
| 299 | ################################################################################ |
| 300 | |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 301 | python-package = $(call inner-python-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) |
| 302 | host-python-package = $(call inner-python-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host) |