Makefile (9462B)
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-version.mk 12 13 PYTHON_VERSION:=$(PYTHON3_VERSION) 14 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO) 15 16 PKG_NAME:=python3 17 PKG_RELEASE:=1 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:=692b4fc3a2ba0d54d1495d4ead5b0b5c 23 PKG_HASH:=a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041 24 25 PKG_LICENSE:=PSF 26 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 27 28 # This file provides the necsessary host build variables 29 include ./files/python3-host.mk 30 31 # For Py3Package 32 include ./files/python3-package.mk 33 34 PKG_INSTALL:=1 35 PKG_BUILD_PARALLEL:=1 36 HOST_BUILD_PARALLEL:=1 37 38 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION) 39 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION) 40 41 PKG_BUILD_DEPENDS:=python3/host 42 HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host 43 44 include $(INCLUDE_DIR)/host-build.mk 45 include $(INCLUDE_DIR)/package.mk 46 47 define Package/python3/Default 48 SUBMENU:=Python 49 SECTION:=lang 50 CATEGORY:=Languages 51 TITLE:=Python $(PYTHON_VERSION) programming language 52 URL:=https://www.python.org/ 53 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com> 54 endef 55 56 define Package/python3/Default/description 57 Python is a dynamic object-oriented programming language that can be used 58 for many kinds of software development. It offers strong support for 59 integration with other languages and tools, comes with extensive standard 60 libraries, and can be learned in a few days. Many Python programmers 61 report substantial productivity gains and feel the language encourages 62 the development of higher quality, more maintainable code. 63 endef 64 65 define Package/python3-base 66 $(call Package/python3/Default) 67 TITLE:=Python $(PYTHON_VERSION) interpreter 68 DEPENDS:=+libpthread +zlib 69 endef 70 71 define Package/python3-base/description 72 This package contains only the interpreter and the bare minimum 73 for the interpreter to start. 74 endef 75 76 define Package/python3-light 77 $(call Package/python3/Default) 78 TITLE:=Python $(PYTHON_VERSION) light installation 79 DEPENDS:=+python3-base +libffi +libbz2 80 endef 81 82 define Package/python3-light/description 83 This package is essentially the python3-base package plus 84 a few of the rarely used (and big) libraries stripped out 85 into separate packages. 86 endef 87 88 PYTHON3_LIB_FILES_DEL:= 89 PYTHON3_PACKAGES:= 90 PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so 91 PYTHON3_PACKAGES_DEPENDS:= 92 define Py3BasePackage 93 PYTHON3_PACKAGES+=$(1) 94 ifeq ($(3),) 95 PYTHON3_PACKAGES_DEPENDS+=$(1) 96 endif 97 PYTHON3_LIB_FILES_DEL+=$(2) 98 define Py3Package/$(1)/filespec 99 ifneq ($(2),) 100 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file))) 101 -|/usr/lib/python$(PYTHON_VERSION)/*/test 102 -|/usr/lib/python$(PYTHON_VERSION)/*/tests 103 endif 104 endef 105 endef 106 107 include ./files/python3-package-*.mk 108 109 define Package/python3 110 $(call Package/python3/Default) 111 DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package)) 112 endef 113 114 define Package/python3/description 115 This package contains the (almost) full Python install. 116 It's python3-light + all other packages. 117 endef 118 119 MAKE_FLAGS+=\ 120 CROSS_COMPILE=yes \ 121 LD="$(TARGET_CC)" \ 122 PGEN=pgen3 123 124 EXTRA_CFLAGS+= \ 125 -DNDEBUG -fno-inline 126 EXTRA_LDFLAGS+= \ 127 -L$(PKG_BUILD_DIR) 128 129 ENABLE_IPV6:= 130 ifeq ($(CONFIG_IPV6),y) 131 ENABLE_IPV6 += --enable-ipv6 132 endif 133 134 PYTHON_FOR_BUILD:= \ 135 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \ 136 _PYTHON_HOST_PLATFORM=linux2 \ 137 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \ 138 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \ 139 $(HOST_PYTHON3_BIN) 140 141 CONFIGURE_ARGS+= \ 142 --sysconfdir=/etc \ 143 --enable-shared \ 144 --without-cxx-main \ 145 --with-threads \ 146 --with-system-ffi \ 147 --with-ensurepip=no \ 148 --without-pymalloc \ 149 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \ 150 $(ENABLE_IPV6) \ 151 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \ 152 OPT="$(TARGET_CFLAGS)" 153 154 define Build/Prepare 155 $(call Build/Prepare/Default) 156 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site 157 endef 158 159 ifdef CONFIG_PACKAGE_python3-setuptools 160 define Build/Compile/python3-setuptools 161 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \ 162 --ignore-installed \ 163 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \ 164 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl 165 endef 166 endif # CONFIG_PACKAGE_python3-setuptools 167 168 ifdef CONFIG_PACKAGE_python3-pip 169 define Build/Compile/python3-pip 170 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \ 171 --ignore-installed \ 172 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \ 173 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl 174 endef 175 endif # CONFIG_PACKAGE_python3-pip 176 177 define Build/Compile 178 $(call Build/Compile/Default) 179 # Use host pip to install python-setuptools 180 $(call Build/Compile/python3-setuptools) 181 $(call Build/Compile/python3-pip) 182 endef 183 184 define Build/InstallDev 185 $(INSTALL_DIR) $(STAGING_DIR)/mk/ 186 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ 187 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/ 188 $(INSTALL_DATA) \ 189 ./files/python3-package.mk \ 190 ./files/python3-host.mk \ 191 ./files/python3-version.mk \ 192 ./files/python3-package-install.sh \ 193 $(STAGING_DIR)/mk/ 194 $(CP) \ 195 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ 196 $(1)/usr/include/ 197 $(CP) \ 198 $(HOST_PYTHON3_LIB_DIR) \ 199 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \ 200 $(1)/usr/lib/ 201 $(CP) \ 202 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \ 203 $(1)/usr/lib/python$(PYTHON_VERSION)/ 204 endef 205 206 PYTHON3_BASE_LIB_FILES:= \ 207 /usr/lib/python$(PYTHON_VERSION)/encodings \ 208 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \ 209 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \ 210 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \ 211 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \ 212 /usr/lib/python$(PYTHON_VERSION)/abc.py \ 213 /usr/lib/python$(PYTHON_VERSION)/codecs.py \ 214 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \ 215 /usr/lib/python$(PYTHON_VERSION)/io.py \ 216 /usr/lib/python$(PYTHON_VERSION)/os.py \ 217 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \ 218 /usr/lib/python$(PYTHON_VERSION)/site.py \ 219 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \ 220 /usr/lib/python$(PYTHON_VERSION)/stat.py 221 222 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES) 223 224 define Py3Package/python3-base/filespec 225 +|/usr/bin/python$(PYTHON_VERSION) 226 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file))) 227 endef 228 229 define Py3Package/python3-light/filespec 230 +|/usr/lib/python$(PYTHON_VERSION) 231 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py 232 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst* 233 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip 234 -|/usr/lib/python$(PYTHON_VERSION)/idlelib 235 -|/usr/lib/python$(PYTHON_VERSION)/tkinter 236 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo 237 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so 238 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so 239 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc 240 -|/usr/lib/python$(PYTHON_VERSION)/test 241 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py 242 -|/usr/lib/python$(PYTHON_VERSION)/*/test 243 -|/usr/lib/python$(PYTHON_VERSION)/*/tests 244 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py 245 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file))) 246 endef 247 248 define Py3Package/python3-base/install 249 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python 250 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/ 251 $(INSTALL_DIR) $(1)/usr/bin 252 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3 253 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/ 254 endef 255 256 define Py3Package/python3/filespec 257 -|$(PYTHON3_PKG_DIR) 258 endef 259 260 HOST_LDFLAGS += \ 261 $$$$(pkg-config --static --libs libcrypto libssl) 262 263 HOST_CONFIGURE_ARGS+= \ 264 --without-cxx-main \ 265 --without-pymalloc \ 266 --with-threads \ 267 --prefix=$(HOST_PYTHON3_DIR) \ 268 --exec-prefix=$(HOST_PYTHON3_DIR) \ 269 --with-system-expat=$(STAGING_DIR_HOSTPKG) \ 270 --with-system-ffi=no \ 271 --with-ensurepip=install \ 272 CONFIG_SITE= 273 274 define Host/Compile 275 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen 276 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods 277 endef 278 279 define Host/Install 280 $(MAKE) -C $(HOST_BUILD_DIR) install 281 282 $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/ 283 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3 284 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_PYTHON3_DIR)/bin/_freeze_importlib 285 endef 286 287 $(eval $(call HostBuild)) 288 289 $(foreach package, $(PYTHON3_PACKAGES), \ 290 $(eval $(call Py3Package,$(package))) \ 291 $(eval $(call BuildPackage,$(package))) \ 292 $(eval $(call BuildPackage,$(package)-src)) \ 293 ) 294 295 $(eval $(call Py3Package,python3-base)) 296 $(eval $(call Py3Package,python3-light)) 297 $(eval $(call Py3Package,python3)) 298 299 $(eval $(call BuildPackage,python3-base)) 300 $(eval $(call BuildPackage,python3-light)) 301 $(eval $(call BuildPackage,python3)) 302 303 $(eval $(call BuildPackage,python3-base-src)) 304 $(eval $(call BuildPackage,python3-light-src)) 305 $(eval $(call BuildPackage,python3-src))