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