noddos: Noddos v0.5.0 with mDNS / DNS-SD support
[feed/packages.git] / lang / python / python3 / Makefile
1 #
2 # Copyright (C) 2006-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 # The file included below defines PYTHON_VERSION
11 include ./files/python3-version.mk
12
13 PYTHON_VERSION:=$(PYTHON3_VERSION)
14 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
15
16 PKG_NAME:=python3
17 PKG_RELEASE:=4
18 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
19
20 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
21 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
22 PKG_HASH:=a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041
23
24 PKG_LICENSE:=PSF
25 PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
26
27 # This file provides the necsessary host build variables
28 include ./files/python3-host.mk
29
30 # For Py3Package
31 include ./files/python3-package.mk
32
33 PKG_INSTALL:=1
34 PKG_BUILD_PARALLEL:=1
35 HOST_BUILD_PARALLEL:=1
36
37 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
38 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
39
40 PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
41
42 PKG_BUILD_DEPENDS:=python3/host
43 HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host
44
45 include $(INCLUDE_DIR)/host-build.mk
46 include $(INCLUDE_DIR)/package.mk
47
48 define Package/python3/Default
49 SUBMENU:=Python
50 SECTION:=lang
51 CATEGORY:=Languages
52 TITLE:=Python $(PYTHON_VERSION) programming language
53 URL:=https://www.python.org/
54 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
55 endef
56
57 define Package/python3/Default/description
58 Python is a dynamic object-oriented programming language that can be used
59 for many kinds of software development. It offers strong support for
60 integration with other languages and tools, comes with extensive standard
61 libraries, and can be learned in a few days. Many Python programmers
62 report substantial productivity gains and feel the language encourages
63 the development of higher quality, more maintainable code.
64 endef
65
66 define Package/python3-base
67 $(call Package/python3/Default)
68 TITLE:=Python $(PYTHON_VERSION) interpreter
69 DEPENDS:=+libpthread +zlib
70 endef
71
72 define Package/python3-base/description
73 This package contains only the interpreter and the bare minimum
74 for the interpreter to start.
75 endef
76
77 define Package/python3-light
78 $(call Package/python3/Default)
79 TITLE:=Python $(PYTHON_VERSION) light installation
80 DEPENDS:=+python3-base +libffi +libbz2
81 endef
82
83 define Package/python3-light/description
84 This package is essentially the python3-base package plus
85 a few of the rarely used (and big) libraries stripped out
86 into separate packages.
87 endef
88
89 PYTHON3_LIB_FILES_DEL:=
90 PYTHON3_PACKAGES:=
91 PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
92 PYTHON3_PACKAGES_DEPENDS:=
93 define Py3BasePackage
94 PYTHON3_PACKAGES+=$(1)
95 ifeq ($(3),)
96 PYTHON3_PACKAGES_DEPENDS+=$(1)
97 endif
98 PYTHON3_LIB_FILES_DEL+=$(2)
99 define Py3Package/$(1)/filespec
100 ifneq ($(2),)
101 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
102 -|/usr/lib/python$(PYTHON_VERSION)/*/test
103 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
104 endif
105 endef
106 endef
107
108 include ./files/python3-package-*.mk
109
110 define Package/python3
111 $(call Package/python3/Default)
112 DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package))
113 endef
114
115 define Package/python3/description
116 This package contains the (almost) full Python install.
117 It's python3-light + all other packages.
118 endef
119
120 MAKE_FLAGS+=\
121 CROSS_COMPILE=yes \
122 LD="$(TARGET_CC)" \
123 PGEN=pgen3
124
125 EXTRA_CFLAGS+= \
126 -DNDEBUG -fno-inline
127 EXTRA_LDFLAGS+= \
128 -L$(PKG_BUILD_DIR)
129
130 ENABLE_IPV6:=
131 ifeq ($(CONFIG_IPV6),y)
132 ENABLE_IPV6 += --enable-ipv6
133 endif
134
135 PYTHON_FOR_BUILD:= \
136 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
137 _PYTHON_HOST_PLATFORM=linux2 \
138 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
139 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
140 $(HOST_PYTHON3_BIN)
141
142 CONFIGURE_ARGS+= \
143 --sysconfdir=/etc \
144 --enable-shared \
145 --without-cxx-main \
146 --with-threads \
147 --with-system-ffi \
148 --with-ensurepip=no \
149 --without-pymalloc \
150 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
151 $(ENABLE_IPV6) \
152 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
153 OPT="$(TARGET_CFLAGS)"
154
155 define Build/Prepare
156 $(call Build/Prepare/Default)
157 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
158 endef
159
160 ifdef CONFIG_PACKAGE_python3-setuptools
161 define Build/Compile/python3-setuptools
162 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
163 --ignore-installed \
164 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
165 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
166 endef
167 endif # CONFIG_PACKAGE_python3-setuptools
168
169 ifdef CONFIG_PACKAGE_python3-pip
170 define Build/Compile/python3-pip
171 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
172 --ignore-installed \
173 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
174 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
175 endef
176 endif # CONFIG_PACKAGE_python3-pip
177
178 define Build/Compile
179 $(call Build/Compile/Default)
180 # Use host pip to install python-setuptools
181 $(call Build/Compile/python3-setuptools)
182 $(call Build/Compile/python3-pip)
183 endef
184
185 define Build/InstallDev
186 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
187 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
188 $(CP) \
189 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
190 $(1)/usr/include/
191 $(CP) \
192 $(HOST_PYTHON3_LIB_DIR) \
193 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
194 $(1)/usr/lib/
195 $(CP) \
196 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
197 $(1)/usr/lib/python$(PYTHON_VERSION)/
198 endef
199
200 PYTHON3_BASE_LIB_FILES:= \
201 /usr/lib/python$(PYTHON_VERSION)/encodings \
202 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
203 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
204 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
205 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
206 /usr/lib/python$(PYTHON_VERSION)/abc.py \
207 /usr/lib/python$(PYTHON_VERSION)/codecs.py \
208 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
209 /usr/lib/python$(PYTHON_VERSION)/io.py \
210 /usr/lib/python$(PYTHON_VERSION)/os.py \
211 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
212 /usr/lib/python$(PYTHON_VERSION)/site.py \
213 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
214 /usr/lib/python$(PYTHON_VERSION)/stat.py
215
216 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
217
218 define Py3Package/python3-base/filespec
219 +|/usr/bin/python$(PYTHON_VERSION)
220 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
221 endef
222
223 define Py3Package/python3-light/filespec
224 +|/usr/lib/python$(PYTHON_VERSION)
225 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
226 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
227 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
228 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
229 -|/usr/lib/python$(PYTHON_VERSION)/tkinter
230 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
231 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
232 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
233 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
234 -|/usr/lib/python$(PYTHON_VERSION)/test
235 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
236 -|/usr/lib/python$(PYTHON_VERSION)/*/test
237 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
238 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
239 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
240 endef
241
242 define Py3Package/python3-base/install
243 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
244 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
245 $(INSTALL_DIR) $(1)/usr/bin
246 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
247 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
248 endef
249
250 define Py3Package/python3/filespec
251 -|$(PYTHON3_PKG_DIR)
252 endef
253
254 HOST_LDFLAGS += \
255 -Wl,--no-as-needed -lrt \
256 $$$$(pkg-config --static --libs libcrypto libssl)
257
258 HOST_CONFIGURE_ARGS+= \
259 --without-cxx-main \
260 --without-pymalloc \
261 --with-threads \
262 --prefix=$(HOST_PYTHON3_DIR) \
263 --exec-prefix=$(HOST_PYTHON3_DIR) \
264 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
265 --with-system-ffi=no \
266 --with-ensurepip=install \
267 CONFIG_SITE=
268
269 define Host/Compile
270 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
271 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
272 endef
273
274 define Host/Install
275 $(MAKE) -C $(HOST_BUILD_DIR) install
276
277 $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/ $(STAGING_DIR)/mk/
278 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3
279 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_PYTHON3_DIR)/bin/_freeze_importlib
280
281 # Install these mk files in the Host/Install phase ;
282 # The Build/InstallDev rule is activated only for target builds.
283 # But if someone needs only the host Python, then
284 # these files need to be installed in this phase, and not Build/InstallDev
285 $(INSTALL_DATA) \
286 ./files/python3-package.mk \
287 ./files/python3-host.mk \
288 ./files/python3-version.mk \
289 ./files/python3-package-install.sh \
290 $(STAGING_DIR)/mk/
291 endef
292
293 $(eval $(call HostBuild))
294
295 $(foreach package, $(PYTHON3_PACKAGES), \
296 $(eval $(call Py3Package,$(package))) \
297 $(eval $(call BuildPackage,$(package))) \
298 $(eval $(call BuildPackage,$(package)-src)) \
299 )
300
301 $(eval $(call Py3Package,python3-base))
302 $(eval $(call Py3Package,python3-light))
303 $(eval $(call Py3Package,python3))
304
305 $(eval $(call BuildPackage,python3-base))
306 $(eval $(call BuildPackage,python3-light))
307 $(eval $(call BuildPackage,python3))
308
309 $(eval $(call BuildPackage,python3-base-src))
310 $(eval $(call BuildPackage,python3-light-src))
311 $(eval $(call BuildPackage,python3-src))