pkg-autotools: move the libtool patching call out of the autoreconf hook
[buildroot-gz.git] / package / python3 / python3.mk
blob2c1ef2a568190e6bec74b5a6814e18e0400d5da6
1 ################################################################################
3 # python3
5 ################################################################################
7 PYTHON3_VERSION_MAJOR = 3.4
8 PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).1
9 PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.xz
10 PYTHON3_SITE = http://python.org/ftp/python/$(PYTHON3_VERSION)
11 PYTHON3_LICENSE = Python software foundation license v2, others
12 PYTHON3_LICENSE_FILES = LICENSE
14 # Python needs itself and a "pgen" program to build itself, both being
15 # provided in the Python sources. So in order to cross-compile Python,
16 # we need to build a host Python first. This host Python is also
17 # installed in $(HOST_DIR), as it is needed when cross-compiling
18 # third-party Python modules.
20 HOST_PYTHON3_CONF_OPTS += \
21 --without-ensurepip \
22 --without-cxx-main \
23 --disable-sqlite3 \
24 --disable-tk \
25 --with-expat=system \
26 --disable-curses \
27 --disable-codecs-cjk \
28 --disable-nis \
29 --enable-unicodedata \
30 --disable-test-modules \
31 --disable-idle3 \
32 --disable-pyo-build
34 # Make sure that LD_LIBRARY_PATH overrides -rpath.
35 # This is needed because libpython may be installed at the same time that
36 # python is called.
37 HOST_PYTHON3_CONF_ENV += \
38 LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
40 PYTHON3_DEPENDENCIES = host-python3 libffi
42 HOST_PYTHON3_DEPENDENCIES = host-expat host-zlib
44 PYTHON3_INSTALL_STAGING = YES
46 ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
47 PYTHON3_DEPENDENCIES += readline
48 endif
50 ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
51 PYTHON3_DEPENDENCIES += ncurses
52 else
53 PYTHON3_CONF_OPTS += --disable-curses
54 endif
56 ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL),y)
57 PYTHON3_DEPENDENCIES += mpdecimal
58 PYTHON3_CONF_OPTS += --with-libmpdec=system
59 else
60 PYTHON3_CONF_OPTS += --with-libmpdec=none
61 endif
63 ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
64 PYTHON3_DEPENDENCIES += expat
65 PYTHON3_CONF_OPTS += --with-expat=system
66 else
67 PYTHON3_CONF_OPTS += --with-expat=none
68 endif
70 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
71 PYTHON3_CONF_OPTS += --enable-old-stdlib-cache
72 endif
74 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
75 PYTHON3_CONF_OPTS += --disable-pyc-build
76 endif
78 ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
79 PYTHON3_DEPENDENCIES += sqlite
80 else
81 PYTHON3_CONF_OPTS += --disable-sqlite3
82 endif
84 ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
85 PYTHON3_DEPENDENCIES += openssl
86 endif
88 ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK),y)
89 PYTHON3_CONF_OPTS += --disable-codecs-cjk
90 endif
92 ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
93 PYTHON3_CONF_OPTS += --disable-unicodedata
94 endif
96 ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
97 PYTHON3_DEPENDENCIES += bzip2
98 endif
100 ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
101 PYTHON3_DEPENDENCIES += zlib
102 endif
104 PYTHON3_CONF_ENV += \
105 ac_cv_have_long_long_format=yes \
106 ac_cv_file__dev_ptmx=yes \
107 ac_cv_file__dev_ptc=yes \
108 ac_cv_working_tzset=yes
110 PYTHON3_CONF_OPTS += \
111 --without-ensurepip \
112 --without-cxx-main \
113 --with-system-ffi \
114 --disable-pydoc \
115 --disable-test-modules \
116 --disable-lib2to3 \
117 --disable-tk \
118 --disable-nis \
119 --disable-idle3 \
120 --disable-pyo-build
122 # This is needed to make sure the Python build process doesn't try to
123 # regenerate those files with the pgen program. Otherwise, it builds
124 # pgen for the target, and tries to run it on the host.
126 define PYTHON3_TOUCH_GRAMMAR_FILES
127 touch $(@D)/Include/graminit.h $(@D)/Python/graminit.c
128 endef
130 PYTHON3_POST_PATCH_HOOKS += PYTHON3_TOUCH_GRAMMAR_FILES
133 # Remove useless files. In the config/ directory, only the Makefile
134 # and the pyconfig.h files are needed at runtime.
136 define PYTHON3_REMOVE_USELESS_FILES
137 rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
138 rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)m-config
139 rm -f $(TARGET_DIR)/usr/bin/python3-config
140 rm -f $(TARGET_DIR)/usr/bin/smtpd.py.3
141 for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
142 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
143 rm -f $$i ; \
144 done
145 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/__pycache__/
146 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/lib-dynload/sysconfigdata/__pycache__
147 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/collections/__pycache__
148 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/importlib/__pycache__
149 endef
151 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
154 # Make sure libpython gets stripped out on target
156 define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
157 chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
158 endef
160 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
162 PYTHON3_AUTORECONF = YES
164 define PYTHON3_INSTALL_SYMLINK
165 ln -fs python3 $(TARGET_DIR)/usr/bin/python
166 endef
168 ifneq ($(BR2_PACKAGE_PYTHON),y)
169 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
170 endif
172 # Some packages may have build scripts requiring python3, whatever is the
173 # python version chosen for the target.
174 # Only install the python symlink in the host tree if python3 is enabled
175 # for the target.
176 ifeq ($(BR2_PACKAGE_PYTHON3),y)
177 define HOST_PYTHON3_INSTALL_SYMLINK
178 ln -fs python3 $(HOST_DIR)/usr/bin/python
179 ln -fs python3-config $(HOST_DIR)/usr/bin/python-config
180 endef
182 HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK
183 endif
185 # Provided to other packages
186 PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/sysconfigdata/:$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/
188 $(eval $(autotools-package))
189 $(eval $(host-autotools-package))
191 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
192 define PYTHON3_FINALIZE_TARGET
193 find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | xargs -0 rm -f
194 endef
195 endif
197 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
198 define PYTHON3_FINALIZE_TARGET
199 find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | xargs -0 rm -f
200 endef
201 endif
203 TARGET_FINALIZE_HOOKS += PYTHON3_FINALIZE_TARGET