Merge pull request #1984 from jefferyto/host-python-package
[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 HOST_BUILD_DEPENDS:=bzip2/host expat/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:=http://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 # Define newline here, since it's not defined in OpenWRT
79 define newline
80
81
82 endef
83
84 PYTHON_LIB_FILES_DEL:=
85 PYTHON_PACKAGES:=
86 define PyBasePackage
87 PYTHON_PACKAGES+=$(1)
88 PYTHON_LIB_FILES_DEL+=$(2)
89 define PyPackage/$(1)/filespec
90 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
91 endef
92 endef
93
94 include ./files/python-package-*.mk
95
96 define Package/python
97 $(call Package/python/Default)
98 DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES),+$(package))
99 endef
100
101 define Package/python/description
102 This package contains the (almost) full Python install.
103 It's python-light + all other packages.
104 endef
105
106 MAKE_FLAGS+=\
107 CROSS_COMPILE=yes \
108 LD="$(TARGET_CC)" \
109 PGEN=pgen2
110
111 EXTRA_CFLAGS+= \
112 -DNDEBUG -fno-inline
113 EXTRA_LDFLAGS+= \
114 -L$(PKG_BUILD_DIR)
115
116 ENABLE_IPV6:=
117 ifeq ($(CONFIG_IPV6),y)
118 ENABLE_IPV6 += --enable-ipv6
119 endif
120
121 CONFIGURE_ARGS+= \
122 --sysconfdir=/etc \
123 --enable-shared \
124 --without-cxx-main \
125 --with-threads \
126 --with-system-ffi="$(STAGING_DIR)/usr" \
127 --without-pymalloc \
128 $(ENABLE_IPV6) \
129 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
130 OPT="$(TARGET_CFLAGS)"
131
132 define Build/Prepare
133 $(call Build/Prepare/Default)
134 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
135 endef
136
137 define Build/InstallDev
138 $(INSTALL_DIR) $(STAGING_DIR)/mk/
139 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
140 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
141 $(INSTALL_DATA) \
142 ./files/python-package.mk \
143 ./files/python-host.mk \
144 $(STAGING_DIR)/mk/
145 $(CP) \
146 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
147 $(1)/usr/include/
148 $(CP) \
149 $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
150 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
151 $(1)/usr/lib/
152 $(CP) \
153 $(STAGING_DIR_HOST)/lib/pkgconfig/python.pc \
154 $(STAGING_DIR_HOST)/lib/pkgconfig/python2.pc \
155 $(STAGING_DIR_HOST)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
156 $(1)/usr/lib/pkgconfig
157 $(CP) \
158 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
159 $(1)/usr/lib/python$(PYTHON_VERSION)/
160 endef
161
162 PYTHON_BASE_LIB_FILES:= \
163 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
164 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
165 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
166 /usr/lib/python$(PYTHON_VERSION)/abc.py \
167 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
168 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
169 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
170 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
171 /usr/lib/python$(PYTHON_VERSION)/os.py \
172 /usr/lib/python$(PYTHON_VERSION)/re.py \
173 /usr/lib/python$(PYTHON_VERSION)/site.py \
174 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
175 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
176 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
177 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
178 /usr/lib/python$(PYTHON_VERSION)/stat.py \
179 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
180 /usr/lib/python$(PYTHON_VERSION)/types.py \
181 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
182 /usr/lib/python$(PYTHON_VERSION)/warnings.py
183
184 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
185
186 define PyPackage/python-base/filespec
187 +|/usr/bin/python$(PYTHON_VERSION)
188 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
189 endef
190
191 define PyPackage/python-light/filespec
192 +|/usr/lib/python$(PYTHON_VERSION)
193 -|/usr/lib/python$(PYTHON_VERSION)/config
194 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
195 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
196 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
197 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
198 -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
199 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
200 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
201 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
202 -|/usr/lib/python$(PYTHON_VERSION)/test
203 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
204 -|/usr/lib/python$(PYTHON_VERSION)/*/test
205 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
206 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
207 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
208 endef
209
210 define PyPackage/python-base/install
211 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
212 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
213 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
214 endef
215
216 define PyPackage/python/filespec
217 -|$(PYTHON_PKG_DIR)
218 endef
219
220 HOST_CFLAGS+= \
221 -I/usr/include/ncursesw \
222 -I/usr/include/ncurses
223
224 HOST_CONFIGURE_ARGS+= \
225 --without-cxx-main \
226 --without-pymalloc \
227 --with-threads \
228 --with-system-expat=$(STAGING_DIR_HOST) \
229 --prefix=$(STAGING_DIR_HOST) \
230 --with-ensurepip=upgrade \
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))