Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created December 23, 2010 06:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save TooTallNate/752643 to your computer and use it in GitHub Desktop.
Save TooTallNate/752643 to your computer and use it in GitHub Desktop.
Runs "configure" for Node.js, with the intent of cross-compiling Node for ARM on an Apple iOS device.
#! /bin/bash
#
# Program : iphone4.2-node-configure
# Authors : Nathan Rajlich (nathan@tootallnate.net)
# Michael Aaron Safyan (michaelsafyan@gmail.com)
# Synopsis : This program runs the "configure" script for Node.js.
# An install prefix of "/opt/iphone-4.2/" is used.
unset CPATH
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
unset OBJC_INCLUDE_PATH
unset LIBS
unset DYLD_FALLBACK_LIBRARY_PATH
unset DYLD_FALLBACK_FRAMEWORK_PATH
export SDKVER="4.2"
export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
if [ ! \( -d "$DEVROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
exit 1
fi
if [ ! \( -d "$SDKROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
exit 1
fi
if [ ! \( -x "./configure" \) ] ; then
echo "This script must be run in the folder containing the \"configure\" script."
exit 1
fi
export PKG_CONFIG_PATH="$SDKROOT/usr/lib/pkgconfig":"/opt/iphone-$SDKVER/lib/pkgconfig":"/usr/local/iphone-$SDKVER/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_PATH"
export PREFIX="/opt/iphone-$SDKVER"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"
export AR="$DEVROOT/usr/bin/ar"
export RANLIB="$DEVROOT/usr/bin/ranlib"
export CPPFLAGS="-miphoneos-version-min=4.1 -std=c99 -pipe -no-cpp-precomp -I$SDKROOT/usr/include -I/opt/iphone-$SDKVER/include -I/usr/local/iphone-$SDKVER/include"
export CFLAGS="-miphoneos-version-min=4.1 -std=c99 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export CXXFLAGS="-miphoneos-version-min=4.1 -std=c99 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export LDFLAGS="-miphoneos-version-min=4.1 -I$SDKROOT/usr/include -I/opt/iphone-$SDKVER/include -I/usr/local/iphone-$SDKVER/include -L$SDKROOT/usr/lib -L/opt/iphone-$SDKVER/lib -L/usr/local/iphone-$SDKVER/lib"
export CPP="$DEVROOT/usr/bin/cpp -E"
export CXXCPP="$DEVROOT/usr/bin/cpp"
export CC="$DEVROOT/usr/bin/arm-apple-darwin10-gcc-4.2.1"
export CXX="$DEVROOT/usr/bin/arm-apple-darwin10-g++-4.2.1"
export LD="$DEVROOT/usr/bin/ld"
export STRIP="$DEVROOT/usr/bin/strip"
./configure \
--prefix="$PREFIX" \
--dest-cpu="arm" \
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment