From fb521cffaed2e6c88f452f300ec7fcdcfd5d8bac Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 1 Nov 2012 11:48:58 -0700 Subject: [PATCH] Fix node-arch sniffing for node 0.6 and to use the correct node. - Use npm_config_prefix to use the node invoking this npm - node < 0.8 doesn't have 'process.config' --- libusdt-build.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libusdt-build.sh b/libusdt-build.sh index e057fb8..94a7d93 100755 --- a/libusdt-build.sh +++ b/libusdt-build.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -o errexit + # GYP's MAKEFLAGS confuses libusdt's Makefile # unset MAKEFLAGS @@ -10,7 +12,15 @@ unset MAKEFLAGS # node extensions universal on the Mac - for now we'll go with x86_64 # on a 64 bit Mac) # -ARCH=`node -e "console.log(process.config.variables.target_arch == 'x64' ? 'x86_64' : 'i386')"` +# libusdt/Makefile wants ARCH to be either 'x86_64' or 'i386'. +NODE_ARCH=$(file $npm_config_prefix/bin/node | awk '{print $3}') +if [[ "$NODE_ARCH" == "32-bit" ]]; then + ARCH=i386 +elif [[ "$NODE_ARCH" == "64-bit" ]]; then + ARCH=x86_64 +else + echo "ERROR: unknown arch for $npm_config_prefix/bin/node: '$NODE_ARCH'" +fi echo "Building libusdt for ${ARCH}" export ARCH