Browse Source

Merge pull request #572 from commodo/python3-sync-build

python3: sync build rules with python's
Steven Barth 10 years ago
parent
commit
d2743c9d0f
2 changed files with 85 additions and 78 deletions
  1. 73
    76
      lang/python3/Makefile
  2. 12
    2
      lang/python3/files/python3-package.mk

+ 73
- 76
lang/python3/Makefile View File

@@ -31,7 +31,7 @@ HOST_BUILD_PARALLEL:=1
31 31
 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
32 32
 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
33 33
 
34
-PKG_BUILD_DEPENDS:=python3/host
34
+PKG_BUILD_DEPENDS:=libffi/host python3/host
35 35
 
36 36
 include $(INCLUDE_DIR)/host-build.mk
37 37
 include $(INCLUDE_DIR)/package.mk
@@ -54,69 +54,62 @@ define Package/python3/Default/description
54 54
  the development of higher quality, more maintainable code.
55 55
 endef
56 56
 
57
-define Package/python3
57
+define Package/python3-base
58 58
 $(call Package/python3/Default)
59
+  TITLE:=Python $(PYTHON_VERSION) interpreter
59 60
   DEPENDS:=+libpthread +zlib +libffi
60 61
 endef
61 62
 
63
+define Package/python3-base/description
64
+  This package contains only the interpreter and the bare minimum
65
+  for the interpreter to start.
66
+endef
67
+
68
+define Package/python3
69
+$(call Package/python3/Default)
70
+  DEPENDS:=+python3-base +libncursesw +libbz2 +libgdbm +libsqlite3 +libdb47 +libopenssl
71
+endef
72
+
62 73
 define Package/python3/description
63
-$(call Package/python3/Default/description)
64
-  .
65
-  This package contains only the interpreter and the bare minimum for the interpreter to start.
74
+  This package contains the (almost) full Python install.
66 75
 endef
67 76
 
68
-MAKE_FLAGS:=\
69
-	$(TARGET_CONFIGURE_OPTS) \
70
-	DESTDIR="$(PKG_INSTALL_DIR)" \
77
+MAKE_FLAGS+=\
71 78
 	CROSS_COMPILE=yes \
72
-	CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
73
-	LDFLAGS="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR)" \
74
-	LD="$(TARGET_CC)"
79
+	LD="$(TARGET_CC)" \
80
+	PGEN=pgen3
81
+
82
+EXTRA_CFLAGS+= \
83
+	-DNDEBUG -fno-inline
84
+EXTRA_LDFLAGS+= \
85
+	-L$(PKG_BUILD_DIR)
75 86
 
76 87
 ENABLE_IPV6:=
77 88
 ifeq ($(CONFIG_IPV6),y)
78 89
 	ENABLE_IPV6 += --enable-ipv6
79 90
 endif
80 91
 
81
-#=======================================================================
82
-# Notes: adding these so that I don't forget, and can track why stuff
83
-#        was did as was did
84
-# - Arguments below were moved to ./files/config.site file, and disabled
85
-#          ac_cv_have_chflags=no \
86
-#          ac_cv_have_lchflags=no \
87
-#          ac_cv_py_format_size_t=no \
88
-#          ac_cv_have_long_long_format=yes \
89
-#          ac_cv_buggy_getaddrinfo=no \
90
-# - --without-ensurepip added, because the build wants to ensure that
91
-#   it works; that's a good idea, but for now, it requires special 
92
-#   setup, and we can do that later
93
-# - --without-pymalloc added, becase in Python 3, modules are suffixed
94
-#   with m; e.g. so some paths are python3.4m instead of python3.4 
95
-#   all this is detailed here:
96
-#     http://legacy.python.org/dev/peps/pep-3149/
97
-#=======================================================================
98
-
99
-define Build/Configure
100
-	-$(MAKE) -C $(PKG_BUILD_DIR) distclean
101
-	(cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
102
-	$(CP) ./files/config.site $(PKG_BUILD_DIR)
103
-	$(call Build/Configure/Default, \
104
-		--sysconfdir=/etc \
105
-		--enable-shared \
106
-		--without-cxx-main \
107
-		--with-threads \
108
-		--with-system-ffi="$(STAGING_DIR)/usr" \
109
-		--without-ensurepip \
110
-		--without-pymalloc \
111
-		$(ENABLE_IPV6) \
112
-		CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
113
-		OPT="$(TARGET_CFLAGS)" \
114
-	)
92
+CONFIGURE_ARGS+= \
93
+	--sysconfdir=/etc \
94
+	--enable-shared \
95
+	--without-cxx-main \
96
+	--with-threads \
97
+	--with-system-ffi="$(STAGING_DIR)/usr" \
98
+	--without-pymalloc \
99
+	--without-ensurepip \
100
+	$(ENABLE_IPV6) \
101
+	CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
102
+	OPT="$(TARGET_CFLAGS)"
103
+
104
+define Build/Prepare
105
+	$(call Build/Prepare/Default)
106
+	$(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
115 107
 endef
116 108
 
117 109
 define Build/InstallDev
118
-	$(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
119 110
 	$(INSTALL_DIR) $(STAGING_DIR)/mk/
111
+	$(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
112
+	$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
120 113
 	$(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
121 114
 	$(CP) \
122 115
 		$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
@@ -128,14 +121,9 @@ define Build/InstallDev
128 121
 	$(CP) \
129 122
 		$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
130 123
 		$(1)/usr/lib/python$(PYTHON_VERSION)/
131
-
132
-	$(CP) \
133
-		$(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
134
-		$(2)/bin/
135
-	$(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
136 124
 endef
137 125
 
138
-define Py3Package/python3/filespec
126
+define Py3Package/python3-base/filespec
139 127
 +|/usr/bin/python$(PYTHON_VERSION)
140 128
 +|/usr/lib/python$(PYTHON_VERSION)/encodings
141 129
 +|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
@@ -153,7 +141,25 @@ define Py3Package/python3/filespec
153 141
 +|/usr/lib/python$(PYTHON_VERSION)/stat.py
154 142
 endef
155 143
 
156
-define Py3Package/python3/install
144
+define Py3Package/python3/filespec
145
++|/usr/lib/python$(PYTHON_VERSION)
146
+-|/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION)
147
+-|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
148
+-|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
149
+-|/usr/lib/python$(PYTHON_VERSION)/idlelib
150
+-|/usr/lib/python$(PYTHON_VERSION)/lib2to3
151
+-|/usr/lib/python$(PYTHON_VERSION)/tkinter
152
+-|/usr/lib/python$(PYTHON_VERSION)/turtledemo
153
+-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
154
+-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
155
+-|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
156
+-|/usr/lib/python$(PYTHON_VERSION)/test
157
+-|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
158
+-|/usr/lib/python$(PYTHON_VERSION)/*/test
159
+-|/usr/lib/python$(PYTHON_VERSION)/*/tests
160
+endef
161
+
162
+define Py3Package/python3-base/install
157 163
 	# Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
158 164
 	$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
159 165
 	$(INSTALL_DIR) $(1)/usr/bin
@@ -161,39 +167,30 @@ define Py3Package/python3/install
161 167
 	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
162 168
 endef
163 169
 
164
-define Host/Configure
165
-	-$(MAKE) -C $(HOST_BUILD_DIR) distclean
166
-	(cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
167
-	(cd $(HOST_BUILD_DIR); \
168
-		rm -rf config.cache; \
169
-		CONFIG_SITE= \
170
-		OPT="$(HOST_CFLAGS)" \
171
-		./configure \
172
-			--without-cxx-main \
173
-			--without-ensurepip \
174
-			--without-pymalloc \
175
-			--with-threads \
176
-			--prefix=$(STAGING_DIR_HOST); \
177
-	)
178
-endef
170
+HOST_CONFIGURE_ARGS+= \
171
+	--without-cxx-main \
172
+	--without-pymalloc \
173
+	--without-ensurepip \
174
+	--with-threads \
175
+	--prefix=$(STAGING_DIR_HOST) \
176
+	CONFIG_SITE= \
177
+	OPT="$(HOST_CFLAGS)"
179 178
 
180 179
 define Host/Compile
181
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
182
-		python Parser/pgen
183
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
184
-		sharedmods
180
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
181
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
185 182
 endef
186 183
 
187 184
 define Host/Install
188 185
 	$(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
189
-	$(MAKE) -C $(HOST_BUILD_DIR) \
190
-		install
191
-	$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
186
+	$(MAKE) -C $(HOST_BUILD_DIR) install
187
+	$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen3
192 188
 endef
193 189
 
194
-
195 190
 $(eval $(call HostBuild))
196 191
 
192
+$(eval $(call Py3Package,python3-base))
197 193
 $(eval $(call Py3Package,python3))
198 194
 
195
+$(eval $(call BuildPackage,python3-base))
199 196
 $(eval $(call BuildPackage,python3))

+ 12
- 2
lang/python3/files/python3-package.mk View File

@@ -17,10 +17,12 @@ PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
17 17
 
18 18
 PYTHON3:=python$(PYTHON3_VERSION)
19 19
 
20
+HOST_PYTHON3_LIB_DIR:=$(STAGING_DIR_HOST)/lib/python$(PYTHON3_VERSION)
20 21
 HOST_PYTHON3_BIN:=$(STAGING_DIR_HOST)/bin/python3
21 22
 
23
+PYTHON3PATH="$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR)"
22 24
 define HostPython3
23
-	(	export PYTHONPATH="$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR)"; \
25
+	(	export PYTHONPATH="$(PYTHON3PATH)"; \
24 26
 		export PYTHONOPTIMIZE=""; \
25 27
 		export PYTHONDONTWRITEBYTECODE=1; \
26 28
 		$(1) \
@@ -28,12 +30,19 @@ define HostPython3
28 30
 	)
29 31
 endef
30 32
 
33
+PKG_USE_MIPS16:=0
34
+# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
35
+# flags are inherited from the Python base package (via sysconfig module)
36
+ifdef CONFIG_USE_MIPS16
37
+  TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
38
+endif
39
+
31 40
 define Py3Package
32 41
   $(call shexport,Py3Package/$(1)/filespec)
33 42
 
34 43
   define Package/$(1)/install
35 44
 	find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
36
-	@echo "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" | ( \
45
+	@echo "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" | ( \
37 46
 		IFS='|'; \
38 47
 		while read fop fspec fperm; do \
39 48
 		  if [ "$$$$$$$$fop" = "+" ]; then \
@@ -80,6 +89,7 @@ define Build/Compile/Py3Mod
80 89
 		CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
81 90
 		LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
82 91
 		_PYTHON_HOST_PLATFORM="linux-$(ARCH)" \
92
+		__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
83 93
 		$(3) \
84 94
 		, \
85 95
 		./setup.py $(2) \