linux驱动程序对应的app程序

在编写此app测试程序时,可以通过以前的方式,编写c文件,编写makefile文件,最终编译出可以执行程序。
不过此时可以通过android下的Android.mk来快速编译可执行程序。
例如:

LOCAL_PAH :=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := freg
LOCAL_SRC_FILES := $(call all-subdir-c-files)
include $(BUILD_EXCUTABLE)

这个里面基本都是固定写法。从网上摘录几个常用的。

LOCAL_PATH := $(call my-dir)

An Android.mk file must begin with the definition of the LOCAL_PATH variable.
It is used to locate source files in the development tree. In this example, the macro function ‘my-dir’, provided by the build system, is used to return
the path of the current directory (i.e. the directory containing the Android.mk file itself).

每个Android.mk都是一个这个为开始。
每个要编译的单元都是以下面一句为开始,以include $(BUILD_SHARED_LIBRARY) 这种形式为结束。

include $(CLEAR_VARS)

The CLEAR_VARS variable is provided by the build system and points to a special GNU Makefile that will clear many LOCAL_XXX variables for you
(e.g. LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, etc…), with the exception of LOCAL_PATH. This is needed because all build
control files are parsed in a single GNU Make execution context where all variables are global.

LOCAL_MODULE := freg

The LOCAL_MODULE variable must be defined to identify each module you describe in your Android.mk. The name must be unique and not contain
any spaces. Note that the build system will automatically add proper prefix and suffix to the corresponding generated file. In other words,
a shared library module named ‘foo’ will generate ‘libfoo.so’.

IMPORTANT NOTE:
If you name your module ‘libfoo’, the build system will not add another ‘lib’ prefix and will generate libfoo.so as well.
This is to support Android.mk files that originate from the Android platform sources, would you need to use these.

LOCAL_SRC_FILES := $(call all-subdir-c-files)

The LOCAL_SRC_FILES variables must contain a list of C and/or C++ source files that will be built and assembled into a module. Note that you should
not list header and included files here, because the build system will compute dependencies automatically for you; just list the source files
that will be passed directly to a compiler, and you should be good.

Note that the default extension for C++ source files is ‘.cpp’. It is however possible to specify a different one by defining the variable
LOCAL_CPP_EXTENSION. Don’t forget the initial dot (i.e. ‘.cxx’ will work, but not ‘cxx’).

include $(BUILD_SHARED_LIBRARY)

The BUILD_SHARED_LIBRARY is a variable provided by the build system that points to a GNU Makefile script that is in charge of collecting all the information you defined in LOCAL_XXX variables since the latest ‘include $(CLEAR_VARS)’ and determine what to build, and how to do it exactly. There is also BUILD_STATIC_LIBRARY to generate a static library.

There are more complex examples in the samples directories, with commented Android.mk files that you can look at.

更多信息参考
Android.mk解释

编写好之后,在当前目录执行mm命令,即可编译出可执行程序。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值