Skip to contentSkip to conversation

nodejs: use the standard configure/make options

PATCH New Samuel Martin 2 participants 4 messages Apr 14, 2014 – Apr 15, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 nodejs: use the standard configure/make options

Also cleanup leading whitespace.

Note that overloading LD in required to avoid linker failures.

---
changes v1 -> v2:
- rebase
- remove {C,LD}FLAGS, duplicating the ones from
{HOST,TARGET}_CONFIGURE_OPTS (ThomasP)
- update commit log

---
 package/nodejs/nodejs.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/nodejs/nodejs.mk +9 -3
index a44bfbd..46b3056 100644
@@ -23,7 +23,8 @@ define HOST_NODEJS_CONFIGURE_CMDS
 	# NPM is non-functional without it, and host-openssl isn't part of
 	# buildroot.
 	(cd $(@D); \
-                ./configure \
+		$(HOST_CONFIGURE_OPTS) \
+		./configure \
 		--prefix=$(HOST_DIR)/usr \
 		--without-snapshot \
 		--without-dtrace \
@@ -75,7 +76,9 @@ define NODEJS_CONFIGURE_CMDS
 endef
 
 define NODEJS_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		$(TARGET_CONFIGURE_OPTS) \
+		LD="$(TARGET_CXX)"
 endef
 
 #
@@ -107,7 +110,10 @@ endef
 endif
 
 define NODEJS_INSTALL_TARGET_CMDS
-	$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) DESTDIR=$(TARGET_DIR) install
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) install \
+		DESTDIR=$(TARGET_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		LD="$(TARGET_CXX)"
 	$(NODEJS_INSTALL_MODULES)
 endef
 
Signature · 1 line
1.9.2
#1 lore raw

PATCH v2 2/3 nodejs: force python interpreter

nodejs build system is based on python, and it does not support python3.

This patch makes sure python2 is used for the build.

Note that, setting PYTHON=... at configure time or in the make environment is not enough to override all the hard-coded python call, so we have to sed some python scripts to avoid being screwed.

---
changes v1 -> v2:
- rebase

---
 package/nodejs/nodejs.mk | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
package/nodejs/nodejs.mk +18 -6
index 46b3056..b5973b5 100644
@@ -17,6 +17,10 @@ ifeq ($(BR2_PACKAGE_OPENSSL),y)
 	NODEJS_DEPENDENCIES += openssl
 endif
 
+# nodejs build system is based on python, but only support python-2.6 or
+# python-2.7. So, we have to enforce PYTHON interpreter to be python2.
+# However, few build scripts hard-code 'python' as the interpreter to be
+# invoked; so we have to manually fix them.
 define HOST_NODEJS_CONFIGURE_CMDS
 	# Build with the static, built-in OpenSSL which is supplied as part of
 	# the nodejs source distribution.  This is needed on the host because
@@ -24,20 +28,23 @@ define HOST_NODEJS_CONFIGURE_CMDS
 	# buildroot.
 	(cd $(@D); \
 		$(HOST_CONFIGURE_OPTS) \
-		./configure \
+		PYTHON=$(HOST_DIR)/usr/bin/python2 \
+		$(HOST_DIR)/usr/bin/python2 ./configure \
 		--prefix=$(HOST_DIR)/usr \
 		--without-snapshot \
 		--without-dtrace \
 		--without-etw \
 	)
+	$(SED) "s@'python',@'$(HOST_DIR)/usr/bin/python2',@" \
+		$(@D)/deps/v8/tools/gyp/v8.gyp
 endef
 
 define HOST_NODEJS_BUILD_CMDS
-	$(HOST_MAKE_ENV) $(MAKE) -C $(@D)
+	$(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 $(MAKE) -C $(@D)
 endef
 
 define HOST_NODEJS_INSTALL_CMDS
-	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) install
+	$(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 $(MAKE) -C $(@D) install
 endef
 
 ifeq ($(BR2_i386),y)
@@ -62,7 +69,8 @@ define NODEJS_CONFIGURE_CMDS
 	(cd $(@D); \
 		$(TARGET_CONFIGURE_OPTS) \
 		LD="$(TARGET_CXX)" \
-		./configure \
+		PYTHON=$(HOST_DIR)/usr/bin/python2 \
+		$(HOST_DIR)/usr/bin/python2 ./configure \
 		--prefix=/usr \
 		--without-snapshot \
 		$(if $(BR2_PACKAGE_OPENSSL),--shared-openssl,--without-ssl) \
@@ -73,10 +81,13 @@ define NODEJS_CONFIGURE_CMDS
 		$(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
 		--dest-os=linux \
 	)
+	$(SED) "s@'python',@'$(HOST_DIR)/usr/bin/python2',@" \
+		$(@D)/deps/v8/tools/gyp/v8.gyp
 endef
 
 define NODEJS_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+	$(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
+		$(MAKE) -C $(@D) \
 		$(TARGET_CONFIGURE_OPTS) \
 		LD="$(TARGET_CXX)"
 endef
@@ -110,7 +121,8 @@ endef
 endif
 
 define NODEJS_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) install \
+	$(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
+		$(MAKE) -C $(@D) install \
 		DESTDIR=$(TARGET_DIR) \
 		$(TARGET_CONFIGURE_OPTS) \
 		LD="$(TARGET_CXX)"
Signature · 1 line
1.9.2
#2 lore raw

PATCH v2 3/3 host-python-pyrex: use the HOST_*_NEEDS_HOST_PYTHON infrastructure

In reply to Samuel Martin

python-pyrex does not support python3.

So, using the *_NEEDS_HOST_PYTHON infrastructure will make sure we won't try building it for python3. Besides, it will automatically take care of adding the right host-python package to the dependency list.

---
changes v1 -> v2:
- rebase
- update commit log (ThomasP)

---
 package/python-pyrex/python-pyrex.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/python-pyrex/python-pyrex.mk +1 -1
index 73cb163..7f424ad 100644
@@ -7,9 +7,9 @@
 PYTHON_PYREX_VERSION = 0.9.9
 PYTHON_PYREX_SOURCE = Pyrex-$(PYTHON_PYREX_VERSION).tar.gz
 PYTHON_PYREX_SITE = http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
-PYTHON_PYREX_DEPENDENCIES = host-python
 PYTHON_PYREX_LICENSE = Apache-v2
 PYTHON_PYREX_LICENSE_FILES = LICENSE.txt
 PYTHON_PYREX_SETUP_TYPE = distutils
+HOST_PYTHON_PYREX_NEEDS_HOST_PYTHON = python2
 
 $(eval $(host-python-package))
Signature · 1 line
1.9.2
#3 lore raw

PATCH v2 1/3 nodejs: use the standard configure/make options

In reply to Samuel Martin

Dear Samuel Martin,

Quoted 5 lines · Samuel Martin

Also cleanup leading whitespace.

Note that overloading LD in required to avoid linker failures.

Thanks, I've applied your 3 patches.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com