Merge pull request #2126 from lynxis/libmicrohttpd
[feed/packages.git] / lang / 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-package.mk
12
13 PYTHON_VERSION:=$(PYTHON3_VERSION)
14 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
15
16 PKG_NAME:=python3
17 PKG_RELEASE:=3
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_MD5SUM:=e9ea6f2623fffcdd871b7b19113fde80
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 PKG_INSTALL:=1
28 PKG_BUILD_PARALLEL:=1
29 HOST_BUILD_PARALLEL:=1
30
31 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
32 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
33
34 PKG_BUILD_DEPENDS:=libbz2/host expat/host python3/host
35 HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host
36
37 include $(INCLUDE_DIR)/host-build.mk
38 include $(INCLUDE_DIR)/package.mk
39
40 define Package/python3/Default
41 SUBMENU:=Python
42 SECTION:=lang
43 CATEGORY:=Languages
44 TITLE:=Python $(PYTHON_VERSION) programming language
45 URL:=https://www.python.org/
46 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
47 endef
48
49 define Package/python3/Default/description
50 Python is a dynamic object-oriented programming language that can be used
51 for many kinds of software development. It offers strong support for
52 integration with other languages and tools, comes with extensive standard
53 libraries, and can be learned in a few days. Many Python programmers
54 report substantial productivity gains and feel the language encourages
55 the development of higher quality, more maintainable code.
56 endef
57
58 define Package/python3-base
59 $(call Package/python3/Default)
60 TITLE:=Python $(PYTHON_VERSION) interpreter
61 DEPENDS:=+libpthread +zlib
62 endef
63
64 define Package/python3-base/description
65 This package contains only the interpreter and the bare minimum
66 for the interpreter to start.
67 endef
68
69 define Package/python3-light
70 $(call Package/python3/Default)
71 TITLE:=Python $(PYTHON_VERSION) light installation
72 DEPENDS:=+python3-base +libffi +libbz2
73 endef
74
75 define Package/python3-light/description
76 This package is essentially the python3-base package plus
77 a few of the rarely used (and big) libraries stripped out
78 into separate packages.
79 endef
80
81 PYTHON3_LIB_FILES_DEL:=
82 PYTHON3_PACKAGES:=
83 PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
84 define Py3BasePackage
85 PYTHON3_PACKAGES+=$(1)
86 PYTHON3_LIB_FILES_DEL+=$(2)
87 define Py3Package/$(1)/filespec
88 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
89 endef
90 endef
91
92 include ./files/python3-package-*.mk
93
94 define Package/python3
95 $(call Package/python3/Default)
96 DEPENDS:=+python3-light $(foreach package,$(filter-out python3-dev python3-lib2to3,$(PYTHON3_PACKAGES)),+$(package))
97 endef
98
99 define Package/python3/description
100 This package contains the (almost) full Python install.
101 It's python3-light + all other packages.
102 endef
103
104 MAKE_FLAGS+=\
105 CROSS_COMPILE=yes \
106 LD="$(TARGET_CC)" \
107 FREEZE_IMPORTLIB=_freeze_importlib \
108 PGEN=pgen3
109
110 ifeq ($(ARCH),i386)
111 MAKE_FLAGS+=PYTHON_DECIMAL_WITH_MACHINE=ansi32
112 endif
113
114 EXTRA_CFLAGS+= \
115 -DNDEBUG -fno-inline
116 EXTRA_LDFLAGS+= \
117 -L$(PKG_BUILD_DIR)
118
119 ENABLE_IPV6:=
120 ifeq ($(CONFIG_IPV6),y)
121 ENABLE_IPV6 += --enable-ipv6
122 endif
123
124 CONFIGURE_ARGS+= \
125 --sysconfdir=/etc \
126 --enable-shared \
127 --without-cxx-main \
128 --with-threads \
129 --with-system-ffi="$(STAGING_DIR)/usr" \
130 --without-pymalloc \
131 --without-ensurepip \
132 $(ENABLE_IPV6) \
133 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
134 OPT="$(TARGET_CFLAGS)"
135
136 define Build/Prepare
137 $(call Build/Prepare/Default)
138 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
139 endef
140
141 define Build/InstallDev
142 $(INSTALL_DIR) $(STAGING_DIR)/mk/
143 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
144 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
145 $(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
146 $(CP) \
147 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
148 $(1)/usr/include/
149 $(CP) \
150 $(STAGING_DIR)/host/lib/python$(PYTHON_VERSION) \
151 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
152 $(1)/usr/lib/
153 $(CP) \
154 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
155 $(1)/usr/lib/python$(PYTHON_VERSION)/
156 endef
157
158 PYTHON3_BASE_LIB_FILES:= \
159 /usr/lib/python$(PYTHON_VERSION)/encodings \
160 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
161 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
162 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
163 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
164 /usr/lib/python$(PYTHON_VERSION)/abc.py \
165 /usr/lib/python$(PYTHON_VERSION)/codecs.py \
166 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
167 /usr/lib/python$(PYTHON_VERSION)/io.py \
168 /usr/lib/python$(PYTHON_VERSION)/os.py \
169 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
170 /usr/lib/python$(PYTHON_VERSION)/site.py \
171 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
172 /usr/lib/python$(PYTHON_VERSION)/stat.py
173
174 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
175
176 define Py3Package/python3-base/filespec
177 +|/usr/bin/python$(PYTHON_VERSION)
178 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
179 endef
180
181 define Py3Package/python3-light/filespec
182 +|/usr/lib/python$(PYTHON_VERSION)
183 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
184 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
185 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
186 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
187 -|/usr/lib/python$(PYTHON_VERSION)/tkinter
188 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
189 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
190 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
191 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
192 -|/usr/lib/python$(PYTHON_VERSION)/test
193 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
194 -|/usr/lib/python$(PYTHON_VERSION)/*/test
195 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
196 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
197 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
198 endef
199
200 define Py3Package/python3-base/install
201 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
202 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
203 $(INSTALL_DIR) $(1)/usr/bin
204 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
205 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
206 endef
207
208 define Py3Package/python3/filespec
209 -|$(PYTHON3_PKG_DIR)
210 endef
211
212 HOST_CFLAGS+= \
213 -I/usr/include/ncursesw \
214 -I/usr/include/ncurses
215
216 HOST_CONFIGURE_ARGS+= \
217 --without-cxx-main \
218 --without-pymalloc \
219 --with-threads \
220 --prefix=$(STAGING_DIR)/host \
221 --exec-prefix=$(STAGING_DIR)/host \
222 --sysconfdir=$(STAGING_DIR_HOST)/host/etc \
223 --localstatedir=$(STAGING_DIR)/host/var \
224 --sbindir=$(STAGING_DIR)/host/bin \
225 --with-system-expat=$(STAGING_DIR)/host \
226 --with-system-ffi=$(STAGING_DIR)/host \
227 --with-ensurepip=upgrade \
228 CONFIG_SITE= \
229 CFLAGS="$(HOST_CFLAGS)"
230
231 define Host/Compile
232 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
233 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
234 endef
235
236 define Host/Install
237 $(INSTALL_DIR) $(STAGING_DIR)/host/bin/
238 $(MAKE) -C $(HOST_BUILD_DIR) install
239 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR)/host/bin/pgen3
240 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(STAGING_DIR)/host/bin/_freeze_importlib
241 endef
242
243 $(eval $(call HostBuild))
244
245 $(foreach package, $(PYTHON3_PACKAGES), \
246 $(eval $(call Py3Package,$(package))) \
247 $(eval $(call BuildPackage,$(package))) \
248 )
249
250 $(eval $(call Py3Package,python3-base))
251 $(eval $(call Py3Package,python3-light))
252 $(eval $(call Py3Package,python3))
253
254 $(eval $(call BuildPackage,python3-base))
255 $(eval $(call BuildPackage,python3-light))
256 $(eval $(call BuildPackage,python3))