android编译系统makefile(Android.mk)写法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

android编译系统的makefile文件Android.mk写法如下

(1)Android.mk文件首先需要指定LOCAL_PATH变量,用于查找源文件。由于一般情况下

Android.mk和需要编译的源文件在同一目录下,所以定义成如下形式:

LOCAL_PATH:=$(call my-dir)

上面的语句的意思是将LOCAL_PATH变量定义成本文件所在目录路径。

(2)Android.mk中可以定义多个编译模块,每个编译模块都是以include $(CLEAR_VARS)开始

以include $(BUILD_XXX)结束。

include $(CLEAR_VARS)

CLEAR_VARS由编译系统提供,指定让GNU MAKEFILE为你清除除LOCAL_PATH以外的所有LOCAL_XXX变量,如LOCAL_MODULE,LOCAL_SRC_FILES,LOCAL_SHARED_LIBRARIES,LOCAL_STATIC_LIBRARIES等。include $(BUILD_STATIC_LIBRARY)表示编译成静态库

include $(BUILD_SHARED_LIBRARY)表示编译成动态库。

include $(BUILD_EXECUTABLE)表示编译成可执行程序

(3)举例如下(frameworks/base/libs/audioflinger/Android.mk):

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS) 模块一

ifeq ($(AUDIO_POLICY_TEST),true)

ENABLE_AUDIO_DUMP := true

endif

LOCAL_SRC_FILES:= \

AudioHardwareGeneric.cpp \

AudioHardwareStub.cpp \

AudioHardwareInterface.cpp

ifeq ($(ENABLE_AUDIO_DUMP),true)

LOCAL_SRC_FILES += AudioDumpInterface.cpp

LOCAL_CFLAGS += -DENABLE_AUDIO_DUMP

endif

LOCAL_SHARED_LIBRARIES := \

libcutils \

libutils \

libbinder \

libmedia \

libhardware_legacy

ifeq ($(strip $(BOARD_USES_GENERIC_AUDIO)),true)

LOCAL_CFLAGS += -DGENERIC_AUDIO

endif

LOCAL_MODULE:= libaudiointerface

ifeq ($(BOARD_HAVE_BLUETOOTH),true)

LOCAL_SRC_FILES += A2dpAudioInterface.cpp

LOCAL_SHARED_LIBRARIES += liba2dp

LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP

LOCAL_C_INCLUDES += $(call include-path-for, bluez)

endif

include $(BUILD_STATIC_LIBRARY) 模块一编译成静态库

include $(CLEAR_VARS) 模块二

LOCAL_SRC_FILES:= \

AudioPolicyManagerBase.cpp

LOCAL_SHARED_LIBRARIES := \

libcutils \

libutils \

libmedia

ifeq ($(TARGET_SIMULATOR),true)

LOCAL_LDLIBS += -ldl

else

LOCAL_SHARED_LIBRARIES += libdl

endif

LOCAL_MODULE:= libaudiopolicybase

ifeq ($(BOARD_HAVE_BLUETOOTH),true)

LOCAL_CFLAGS += -DWITH_A2DP

endif

ifeq ($(AUDIO_POLICY_TEST),true)

LOCAL_CFLAGS += -DAUDIO_POLICY_TEST

endif

include $(BUILD_STATIC_LIBRARY) 模块二编译成静态库

include $(CLEAR_VARS) 模块三

LOCAL_SRC_FILES:= \

AudioFlinger.cpp \

AudioMixer.cpp.arm \

AudioResampler.cpp.arm \

AudioResamplerSinc.cpp.arm \

AudioResamplerCubic.cpp.arm \

AudioPolicyService.cpp

LOCAL_SHARED_LIBRARIES := \

libcutils \

libutils \

libbinder \

libmedia \

libhardware_legacy

ifeq ($(strip $(BOARD_USES_GENERIC_AUDIO)),true)

LOCAL_STATIC_LIBRARIES += libaudiointerface libaudiopolicybase LOCAL_CFLAGS += -DGENERIC_AUDIO

else

LOCAL_SHARED_LIBRARIES += libaudio libaudiopolicy

endif

ifeq ($(TARGET_SIMULATOR),true)

LOCAL_LDLIBS += -ldl

else

LOCAL_SHARED_LIBRARIES += libdl

endif

LOCAL_MODULE:= libaudioflinger

ifeq ($(BOARD_HAVE_BLUETOOTH),true)

LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP

LOCAL_SHARED_LIBRARIES += liba2dp

endif

相关文档
最新文档