Android mk 模板
时间:2010-11-29 来源:wuyongjun
1 在Android.mk 中编译一个可执行程序的模板如下:
# Test Exe
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS)
LOCAL_SRC_FILES:=\
main.c
LOCAL_MODULE:=test_ext
#LOCAL_C_INCLUDES :=
#LOCAL_STATIC_LIBRARIES:=
#LOCAL_SHARED_LIBRARIES:=
include $(BUILD_EXECUTABLE) |
# Test Static lib LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS)
LOCAL_SRC_FILES:=\ helloworld.c LOCAL_MODULES:=libtest_static
#LOCAL_C_INCLUDES := #LOCAL_STATIC_LBRARIES := #LOCAL_SHARED_LIBRARIES :=
include $(BUILD_STATIC_LIBRARY) |
3 在Andorid.mk 中编译一个动态库的模板
#Test shared lib
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
LOCAL_SRC_FILES := \ helloworld.c
LOCAL_MODULE:=libtest_shared
TARGET_PRELINK_MODULE := false
#LOCAL_C_INCLUDES := #LOCAL_STATIC_LIBRARIES := #LOCAL_SHARED_LIBRARIES :=
include $(BUILD_SHARED_LIBRARY) |
可执行程序,静态库和动态库生成的母夜叉结果分别在以下的目录中:
out/target/product/generic/obj/EXECUTABLE
out/target/product/generic/obj/STAIC_LIBRARY
out/target/product/generic/obj/SHARED_LIBRARY
每一个模块的目标文件夹分别为:
可执行程序: {XXX}_intermediates
静态库: {XXX}_static_intermediates
动态库: {XXX}_shared_intermediates
编译主机的内容,可执行程序,静态库,动态库使用宏分别为:
include $(BUILD_HOST_EXECUTABLE)
include $(BUILD_HOST_STATIC_LIBRARY)
include $(BUILD_HOST_SHARED_LIBRARY)
指定最后的目标安装路径和没有经过符号剥离的目标路径:
LOCAL_MODULES_PATH := $(TARGET_ROOT_OUT)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
不同的文件系统路径使用以下的宏进行选择
TARGET_ROOT_OUT: 表示根文件系统,路径为out/target/product/generic/root
TARGET_OUT:表示system文件系统,路径为out/target/product/generic/system
TARGET_OUT_DATA:表示data文件系统,路径为out/target/product/generic/data