Android NDK standlone编译脚本

参照网上的一些脚本编写了一个makefile,可以直接用NDK来编译程序。

NDK_ROOT=D:/gnu-toochain/android-ndk-r8c
TOOLCHAIN_ROOT=$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.6/prebuilt/windows
TOOLCHAIN_PREFIX=$(TOOLCHAIN_ROOT)/bin/arm-linux-androideabi
TOOLCHAIN_INCLUDE=$(TOOLCHAIN_ROOT)/lib/gcc/arm-linux-androideabi/4.6/include-fixed
PLATFORM_ROOT=$(NDK_ROOT)/platforms/android-14/arch-arm
PLATFORM_INCLUDE=$(PLATFORM_ROOT)/usr/inlcude
PLATFORM_LIB=$(PLATFORM_ROOT)/usr/lib

MODULE_NAME=helloworld
RM=del

FLAGS=-I$(PLATFORM_INCLUDE) \
      -L$(PLATFORM_LIB) \
      -nostdlib \
      -lgcc \
      -Bdynamic \
      -lc 
      
#      -I$(TOOLCHAIN_INCLUDE) \      

OBJS=$(MODULE_NAME).o \
     $(PLATFORM_LIB)/crtbegin_dynamic.o \
     $(PLATFORM_LIB)/crtend_android.o
     
all:
	$(TOOLCHAIN_PREFIX)-gcc --sysroot=$(PLATFORM_ROOT) $(FLAGS) -c $(MODULE_NAME).c -o $(MODULE_NAME).o 
	$(TOOLCHAIN_PREFIX)-gcc --sysroot=$(PLATFORM_ROOT) $(FLAGS) $(OBJS) -o $(MODULE_NAME)

clean:
	rm *.o
    
install:
	adb push $(MODULE_NAME) /data/local/tmp
	adb shell chmod 755 /data/local/tmp/$(MODULE_NAME)


你可能感兴趣的:(android,NDK,makefile,toolchain)