Last active
August 29, 2015 14:27
-
-
Save gwjjeff/a16e11d5539d4a51072b to your computer and use it in GitHub Desktop.
交叉编译nodejs v0.10.29 ruby v2.2.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2013.05_linux/bin | |
| #GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin | |
| GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin | |
| #GCC_PATH=/var/www/arm_sysroot/usr/bin | |
| CROSS=${GCC_PATH}/arm-linux-gnueabihf- | |
| #CROSS=${GCC_PATH}/ | |
| ARM_MA=armv7l-unknown-linux-gnueabihf | |
| #SYS_ROOT=/var/www/arm_sysroot | |
| #SYS_ROOT=/var/www/arm_sysroot_3.7.3 | |
| #SYS_ROOT=/var/www/buildroot-vanlia/buildroot/output/staging | |
| SYS_ROOT=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/arm-linux-gnueabihf/libc | |
| #USR_ROOT=/var/www/arm_sysroot_3.7.3 | |
| export CC=${CROSS}gcc | |
| export CXX=${CROSS}c++ | |
| export LD=${CROSS}ld | |
| export AR=${CROSS}ar | |
| export AS=${CROSS}as | |
| export NM=${CROSS}nm | |
| export STRIP=${CROSS}strip | |
| export RANLIB=${CROSS}ranlib | |
| #export DLLTOOL=${CROSS}-dlltool | |
| export OBJDUMP=${CROSS}objdump | |
| #export RESCOMP=${CROSS}-windres | |
| #export WINDRES=${CROSS}-windres | |
| export CFLAGS="-g -O2 --sysroot=${SYS_ROOT} -fPIC -DPIC" | |
| #export CFLAGS="-g -O2 --sysroot=${SYS_ROOT}" | |
| export CPPFLAGS="-g -O2 --sysroot=${SYS_ROOT} -I${SYS_ROOT}/include -I${SYS_ROOT}/usr/local/include -fPIC -DPIC" | |
| #export CPPFLAGS="-I${USR_ROOT}/include -I${USR_ROOT}/usr/local/include" | |
| export CXXFLAGS=$CFLAGS | |
| #export LDFLAGS="--sysroot=$SYS_ROOT -L${GCC_PATH}/../arm-linux-gnueabihf/libc/ -L$SYS_ROOT/usr/lib -L$SYS_ROOT/lib -L$SYS_ROOT/usr/local/lib" | |
| #export LDFLAGS="--sysroot=$SYS_ROOT -L$USR_ROOT/usr/lib -L$USR_ROOT/lib -L$USR_ROOT/usr/local/lib" | |
| #export LDFLAGS="--sysroot=$SYS_ROOT -L${GCC_PATH}/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf -L$SYS_ROOT/usr/lib -L$SYS_ROOT/lib -L$SYS_ROOT/usr/local/lib" | |
| export LDFLAGS="--sysroot=$SYS_ROOT -L$SYS_ROOT/usr/lib -L$SYS_ROOT/lib -L$SYS_ROOT/usr/local/lib" | |
| #webrtc | |
| export GYP_DEFINES="target_arch=arm sysroot=${SYS_ROOT} disable_nacl=1 linux_use_tcmalloc=0 armv7=1 arm_neon=2 arm_thumb=1 arm_fpu=vfpv3-d16" | |
| #export GYP_DEFINES="werror= target_arch=$ARCH sysroot=$ROOTFS disable_nacl=1 linux_use_tcmalloc=0 armv7=1 arm_neon=0 arm_thumb=1 arm_fpu=vfpv3-d16" | |
| export PATH="${GCC_PATH}":$PATH | |
| # nodejs v0.10.29 | |
| ./configure --without-snapshot --dest-cpu=arm --dest-os=linux --prefix=/usr/local | |
| # ruby 2.2.2 | |
| # ./configure --without-snapshot --host=arm-linux --prefix=/opt/arm-ruby-2.2.2 --disable-install-rdoc --disable-install-ri --without-ripper | |
| bash --norc | |
| ############################################################################# | |
| ## ref: http://blog.163.com/xs_fantasy/blog/static/101560871201322341714377/ | |
| ## ref: https://gist.github.com/Gioyik/7895192 | |
| ## ref: https://blog.hinablue.me/entry/nodejs-cross-compile-modules-to-arm/ | |
| ############################################################################# | |
| ## see: http://stackoverflow.com/questions/23781983/cannot-find-sys-cdefs-h-when-building-v8-for-android | |
| ## apt-get install libc6-dev-i386 g++-multilib | |
| ## cmds ##################################################################### | |
| ##$ chmod 755 cross.sh | |
| ##$ ./cross.sh | |
| # $ make | |
| # #### ruby这一步有所不同 | |
| # $ DESTDIR=../arm-node-v0.10.29 make install | |
| # $ cd .. | |
| # $ tar zcf arm-node-v0.10.29.tar.gz -C arm-node-v0.10.29 . |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
之后拷贝安装到arm设备的/usr/local之后,需要修改/usr/local/lib/node_modules/npm/bin/npm-cli.js开头node程序的路径