Android.mk範例:將已編譯的執行碼和library放置到輸出
# for binary
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
LOCAL_SRC_FILES := minebin
LOCAL_MODULE := minebin
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
# for binary service with init.rc
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
LOCAL_SRC_FILES := mineservice
LOCAL_MODULE := mineservice
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
LOCAL_INIT_RC := mineservice.rc
include $(BUILD_PREBUILT)
mineservice.rc的內容可能如下:
service mineservice /system/bin/mineservice
class late_start
disabled
oneshot
某些android工作環境, init.rc是需要另外指定拷貝到root/initrc中, 例如:
PRODUCT_COPY_FILES += mineservice/mineservice.rc:root/initrc/mineservice.rc
# for library
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)
LOCAL_SRC_FILES := libmine.so
LOCAL_MODULE := libmine
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
# for libraries in one-line
include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optional
LOCAL_PREBUILT_LIBS := lib/libmine_a.so \
lib/libmine_b.so \
lib/libmine_c.so \
lib/libmine.a
include $(BUILD_MULTI_PREBUILT)
記得用\換行之後不能有空白, 然後行前面的空白不可以是TAB,會使編譯問題
# for library with headers under 'include' directory
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)
LOCAL_SRC_FILES := libmine.so
LOCAL_MODULE := libmine
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_PREBUILT)
還有
LOCAL_EXPORT_CPPFLAGS
LOCAL_EXPORT_CFLAGS
LOCAL_EXPORT_LDLIBS
# for all Android.mk under current directory
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH))
留言