android.mk是描述项目的到建立系统的。其位于jni的文件夹下内容为
# Copyright (C) 2009 The Alndroid Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_SHARED_LIBRARY)
其中#:代表的是注释,不会被gnu make工具执行。
Local_Path:一个Android.mk工具总是从该变量的定义开始的,用来定位源文件,使用了一个宏(my-dir)来代表当前目录。
Clear_vars:是指定了Clear_vars.mk的位置,其作用是清除除了local_path外的所有local_(name)的变量。这是需要的因为android建立系统是一起执行多个建立文件和模块的,local_(name)变量时全局的,所以需要清除。
local_module:给模块定义一个独特的名字,建立系统会增加相应的前缀和后缀,hello-jni产生一个共享的模块,libhello-jni.so命名。
local_src_files:使用来产生模块的源文件。
BUILD_SHARED_LIBRARY:指定了需要共享的类库build-shared-library.mk文件的位置,其中包含了让源文件编译成共享库的函数。