Merge pull request #1630 from hiviah/tor-0.2.6
[feed/packages.git] / lang / python / Makefile
1 #
2 # Copyright (C) 2006-2015 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:=6
16
17 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
18 PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
19 PKG_MD5SUM:=c685ef0b8e9f27b5e3db5db12b268ac6
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
33 include $(INCLUDE_DIR)/host-build.mk
34 include $(INCLUDE_DIR)/package.mk
35
36 define Package/python/Default
37 SUBMENU:=Python
38 SECTION:=lang
39 CATEGORY:=Languages
40 TITLE:=Python $(PYTHON_VERSION) programming language
41 URL:=http://www.python.org/
42 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
43 endef
44
45 define Package/python/Default/description
46 Python is a dynamic object-oriented programming language that can be used
47 for many kinds of software development. It offers strong support for
48 integration with other languages and tools, comes with extensive standard
49 libraries, and can be learned in a few days. Many Python programmers
50 report substantial productivity gains and feel the language encourages
51 the development of higher quality, more maintainable code.
52 endef
53
54 define Package/python-base
55 $(call Package/python/Default)
56 TITLE:=Python $(PYTHON_VERSION) interpreter
57 DEPENDS:=+libpthread +zlib
58 endef
59
60 define Package/python-base/description
61 This package contains only the interpreter and the bare minimum
62 for the interpreter to start.
63 endef
64
65 define Package/python-light
66 $(call Package/python/Default)
67 TITLE:=Python $(PYTHON_VERSION) light installation
68 DEPENDS:=+python-base +libffi +libbz2
69 endef
70
71 define Package/python-light/description
72 This package is essentially the python-base package plus
73 a few of the rarely used (and big) libraries stripped out
74 into separate packages.
75 endef
76
77 # Define newline here, since it's not defined in OpenWRT
78 define newline
79
80
81 endef
82
83 PYTHON_LIB_FILES_DEL:=
84 PYTHON_PACKAGES:=
85 define PyBasePackage
86 PYTHON_PACKAGES+=$(1)
87 PYTHON_LIB_FILES_DEL+=$(2)
88 define PyPackage/$(1)/filespec
89 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
90 endef
91 endef
92
93 include ./files/python-package-*.mk
94
95 define Package/python
96 $(call Package/python/Default)
97 DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES),+$(package))
98 endef
99
100 define Package/python/description
101 This package contains the (almost) full Python install.
102 It's python-light + all other packages.
103 endef
104
105 MAKE_FLAGS+=\
106 CROSS_COMPILE=yes \
107 LD="$(TARGET_CC)" \
108 PGEN=pgen2
109
110 EXTRA_CFLAGS+= \
111 -DNDEBUG -fno-inline
112 EXTRA_LDFLAGS+= \
113 -L$(PKG_BUILD_DIR)
114
115 ENABLE_IPV6:=
116 ifeq ($(CONFIG_IPV6),y)
117 ENABLE_IPV6 += --enable-ipv6
118 endif
119
120 CONFIGURE_ARGS+= \
121 --sysconfdir=/etc \
122 --enable-shared \
123 --without-cxx-main \
124 --with-threads \
125 --with-system-ffi="$(STAGING_DIR)/usr" \
126 --without-pymalloc \
127 $(ENABLE_IPV6) \
128 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
129 OPT="$(TARGET_CFLAGS)"
130
131 define Build/Prepare
132 $(call Build/Prepare/Default)
133 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
134 endef
135
136 define Build/InstallDev
137 $(INSTALL_DIR) $(STAGING_DIR)/mk/
138 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
139 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
140 $(INSTALL_DATA) ./files/python-package.mk $(STAGING_DIR)/mk/
141 $(CP) \
142 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
143 $(1)/usr/include/
144 $(CP) \
145 $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
146 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
147 $(1)/usr/lib/
148 $(CP) \
149 $(STAGING_DIR_HOST)/lib/pkgconfig/python.pc \
150 $(STAGING_DIR_HOST)/lib/pkgconfig/python2.pc \
151 $(STAGING_DIR_HOST)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
152 $(1)/usr/lib/pkgconfig
153 $(CP) \
154 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
155 $(1)/usr/lib/python$(PYTHON_VERSION)/
156 endef
157
158 PYTHON_BASE_LIB_FILES:= \
159 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
160 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
161 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
162 /usr/lib/python$(PYTHON_VERSION)/abc.py \
163 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
164 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
165 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
166 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
167 /usr/lib/python$(PYTHON_VERSION)/os.py \
168 /usr/lib/python$(PYTHON_VERSION)/re.py \
169 /usr/lib/python$(PYTHON_VERSION)/site.py \
170 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
171 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
172 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
173 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
174 /usr/lib/python$(PYTHON_VERSION)/stat.py \
175 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
176 /usr/lib/python$(PYTHON_VERSION)/types.py \
177 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
178 /usr/lib/python$(PYTHON_VERSION)/warnings.py
179
180 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
181
182 define PyPackage/python-base/filespec
183 +|/usr/bin/python$(PYTHON_VERSION)
184 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
185 endef
186
187 define PyPackage/python-light/filespec
188 +|/usr/lib/python$(PYTHON_VERSION)
189 -|/usr/lib/python$(PYTHON_VERSION)/config
190 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
191 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
192 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
193 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
194 -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
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 --with-system-expat=$(STAGING_DIR_HOST) \
225 --prefix=$(STAGING_DIR_HOST) \
226 --with-ensurepip=upgrade \
227 CONFIG_SITE= \
228 CFLAGS="$(HOST_CFLAGS)"
229
230 define Host/Install
231 $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
232 $(MAKE) -C $(HOST_BUILD_DIR) install
233 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen2
234 endef
235
236 $(eval $(call HostBuild))
237
238 $(foreach package, $(PYTHON_PACKAGES), \
239 $(eval $(call PyPackage,$(package))) \
240 $(eval $(call BuildPackage,$(package))) \
241 )
242
243 $(eval $(call PyPackage,python-base))
244 $(eval $(call PyPackage,python-light))
245 $(eval $(call PyPackage,python))
246
247 $(eval $(call BuildPackage,python-base))
248 $(eval $(call BuildPackage,python-light))
249 $(eval $(call BuildPackage,python))