mac平台下LuaJIT-2.1.0-beta2 编译android i686-linux-android-clang: Command not found


今天更新luajit2.1beta2时,编译android一直报错。
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found
Makefile:264: *** Unsupported target architecture.  Stop.
make: *** [default] Error 2

阅读最src/Makefile发现增加了这么一句
ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
  HOST_SYS= Windows
  HOST_RM= del
else
  HOST_SYS:= $(shell uname -s)
  ifneq (,$(findstring MINGW,$(HOST_SYS)))
    HOST_SYS= Windows
    HOST_MSYS= mingw
  endif
  ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
    HOST_SYS= Windows
    HOST_MSYS= cygwin
  endif
  # Use Clang for OSX host.
  ifeq (Darwin,$(HOST_SYS))
    DEFAULT_CC= clang
  endif
endif


在mac下编译默认用的clang, NDK是没什么i686-linux-android-clang,

修改成默认gcc做了一个判断

  # Use Clang for OSX host.
  ifeq (Darwin,$(HOST_SYS))
    ifneq (Linux, $(TARGET_SYS))
      DEFAULT_CC= clang
    endif
  endif

贴上 luajit 编译代码
#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
host_os=`uname -s | tr "[:upper:]" "[:lower:]"`
SRCDIR=$DIR/src
cd "$SRCDIR"
NDK=$NDK_ROOT
NDKABI=8
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.9
NDKP=$NDKVER/prebuilt/${host_os}-x86_64/bin/arm-linux-androideabi-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
# Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
DESTDIR=$DIR/prebuilt/android/armeabi
rm "$DESTDIR"/*.a
make clean
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF"
if [ -f $SRCDIR/src/libluajit.a ]; then
    mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a
fi;
# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
DESTDIR=$DIR/prebuilt/android/armeabi-v7a
rm "$DESTDIR"/*.a
make clean
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF $NDKARCH"
if [ -f $SRCDIR/src/libluajit.a ]; then
    mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a
fi;
# Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
NDKABI=18
DESTDIR=$DIR/prebuilt/android/x86
NDKVER=$NDK/toolchains/x86-4.9
NDKP=$NDKVER/prebuilt/${host_os}-x86_64/bin/i686-linux-android-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
rm "$DESTDIR"/*.a
make clean
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF"
if [ -f $SRCDIR/src/libluajit.a ]; then
    mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a
fi;
make clean





冠军是一种习惯,比要求的做得更多。成功是每一个环节都成功,冠军对每件事要求都非常严格!成为冠军的第一要决:下定决心!下定决心=切除一切退路!