Merge pull request #3511 from dibdot/travelmate
[feed/packages.git] / lang / python / 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 # For PYTHON_VERSION
11 include ./files/python-version.mk
12
13 # This file provides the necsessary host build variables
14 include ./files/python-host.mk
15
16 # For PyPackage
17 include ./files/python-package.mk
18
19 PKG_NAME:=python
20 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
21 PKG_RELEASE:=2
22
23 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
24 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
25 PKG_MD5SUM:=57dffcee9cee8bb2ab5f82af1d8e9a69
26
27 PKG_LICENSE:=PSF
28 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
29
30 PKG_INSTALL:=1
31 PKG_BUILD_PARALLEL:=1
32 HOST_BUILD_PARALLEL:=1
33
34 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
35 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
36
37 PKG_BUILD_DEPENDS:=python/host
38 HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host
39
40 include $(INCLUDE_DIR)/host-build.mk
41 include $(INCLUDE_DIR)/package.mk
42
43 define Package/python/Default
44 SUBMENU:=Python
45 SECTION:=lang
46 CATEGORY:=Languages
47 TITLE:=Python $(PYTHON_VERSION) programming language
48 URL:=https://www.python.org/
49 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
50 endef
51
52 define Package/python/Default/description
53 Python is a dynamic object-oriented programming language that can be used
54 for many kinds of software development. It offers strong support for
55 integration with other languages and tools, comes with extensive standard
56 libraries, and can be learned in a few days. Many Python programmers
57 report substantial productivity gains and feel the language encourages
58 the development of higher quality, more maintainable code.
59 endef
60
61 define Package/python-base
62 $(call Package/python/Default)
63 TITLE:=Python $(PYTHON_VERSION) interpreter
64 DEPENDS:=+libpthread +zlib
65 endef
66
67 define Package/python-base/description
68 This package contains only the interpreter and the bare minimum
69 for the interpreter to start.
70 endef
71
72 define Package/python-light
73 $(call Package/python/Default)
74 TITLE:=Python $(PYTHON_VERSION) light installation
75 DEPENDS:=+python-base +libffi +libbz2
76 endef
77
78 define Package/python-light/description
79 This package is essentially the python-base package plus
80 a few of the rarely used (and big) libraries stripped out
81 into separate packages.
82 endef
83
84 PYTHON_LIB_FILES_DEL:=
85 PYTHON_PACKAGES:=
86 PYTHON_PACKAGES_DEPENDS:=
87 define PyBasePackage
88 PYTHON_PACKAGES+=$(1)
89 ifeq ($(3),)
90 PYTHON_PACKAGES_DEPENDS+=$(1)
91 endif
92 PYTHON_LIB_FILES_DEL+=$(2)
93 define PyPackage/$(1)/filespec
94 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
95 endef
96 endef
97
98 include ./files/python-package-*.mk
99
100 define Package/python
101 $(call Package/python/Default)
102 DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES_DEPENDS),+$(package))
103 endef
104
105 define Package/python/description
106 This package contains the (almost) full Python install.
107 It's python-light + all other packages.
108 endef
109
110 MAKE_FLAGS+=\
111 CROSS_COMPILE=yes \
112 LD="$(TARGET_CC)" \
113 PGEN=pgen2
114
115 EXTRA_CFLAGS+= \
116 -DNDEBUG -fno-inline
117 EXTRA_LDFLAGS+= \
118 -L$(PKG_BUILD_DIR)
119
120 ENABLE_IPV6:=
121 ifeq ($(CONFIG_IPV6),y)
122 ENABLE_IPV6 += --enable-ipv6
123 endif
124
125 CONFIGURE_ARGS+= \
126 --sysconfdir=/etc \
127 --enable-shared \
128 --without-cxx-main \
129 --with-threads \
130 --with-system-ffi="$(STAGING_DIR)/usr" \
131 --without-pymalloc \
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/ $(1)/usr/lib/pkgconfig
144 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
145 $(INSTALL_DATA) \
146 ./files/python-package.mk \
147 ./files/python-host.mk \
148 ./files/python-version.mk \
149 $(STAGING_DIR)/mk/
150 $(CP) \
151 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
152 $(1)/usr/include/
153 $(CP) \
154 $(HOST_PYTHON_LIB_DIR) \
155 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
156 $(1)/usr/lib/
157 $(CP) \
158 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
159 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
160 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
161 $(1)/usr/lib/pkgconfig
162 $(CP) \
163 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
164 $(1)/usr/lib/python$(PYTHON_VERSION)/
165 endef
166
167 PYTHON_BASE_LIB_FILES:= \
168 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
169 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
170 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
171 /usr/lib/python$(PYTHON_VERSION)/abc.py \
172 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
173 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
174 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
175 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
176 /usr/lib/python$(PYTHON_VERSION)/os.py \
177 /usr/lib/python$(PYTHON_VERSION)/re.py \
178 /usr/lib/python$(PYTHON_VERSION)/site.py \
179 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
180 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
181 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
182 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
183 /usr/lib/python$(PYTHON_VERSION)/stat.py \
184 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
185 /usr/lib/python$(PYTHON_VERSION)/types.py \
186 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
187 /usr/lib/python$(PYTHON_VERSION)/warnings.py
188
189 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
190
191 define PyPackage/python-base/filespec
192 +|/usr/bin/python$(PYTHON_VERSION)
193 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
194 endef
195
196 define PyPackage/python-light/filespec
197 +|/usr/lib/python$(PYTHON_VERSION)
198 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
199 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
200 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
201 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
202 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
203 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
204 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
205 -|/usr/lib/python$(PYTHON_VERSION)/test
206 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
207 -|/usr/lib/python$(PYTHON_VERSION)/*/test
208 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
209 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
210 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
211 endef
212
213 define PyPackage/python-base/install
214 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
215 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
216 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
217 endef
218
219 define PyPackage/python/filespec
220 -|$(PYTHON_PKG_DIR)
221 endef
222
223 HOST_CONFIGURE_ARGS+= \
224 --without-cxx-main \
225 --without-pymalloc \
226 --with-threads \
227 --prefix=$(HOST_PYTHON_DIR) \
228 --exec-prefix=$(HOST_PYTHON_DIR) \
229 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
230 --with-system-ffi=$(STAGING_DIR_HOSTPKG) \
231 CONFIG_SITE= \
232 CFLAGS="$(HOST_CFLAGS)"
233
234 define Host/Install
235 $(MAKE) -C $(HOST_BUILD_DIR) install
236 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
237 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
238 endef
239
240 $(eval $(call HostBuild))
241
242 $(foreach package, $(PYTHON_PACKAGES), \
243 $(eval $(call PyPackage,$(package))) \
244 $(eval $(call BuildPackage,$(package))) \
245 )
246
247 $(eval $(call PyPackage,python-base))
248 $(eval $(call PyPackage,python-light))
249 $(eval $(call PyPackage,python))
250
251 $(eval $(call BuildPackage,python-base))
252 $(eval $(call BuildPackage,python-light))
253 $(eval $(call BuildPackage,python))