Makefile出身:
Uinx、GNU、GNU make、理查德·斯托曼(Richard Matthew Stallman)博士
不说了,大家可看看“GNU/Linux与开源文化的那些人和事”这文章写的很好,专科生一定要看。
什么是GNU make:
GNU make is the implementation of make written for the Free Software Foundation’s GNU Operating System. The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them.
Makefile到底是啥还是没有懂:
make是一个专解释Makefile中指令的命令工具,
Makefile实质就是描述了整个工程的编译、连接等规则的定义文件,最终目地就是实现“自动化编译”
这也是“GNU Operating System”灵魂人物“Richard Matthew Stallman”带领团队搞出来的。
Android这小弟就是在他的基础上改改搞搞。
Makefile基本语法:
target... : prerequisites ...
command
...
...
target 目标文件
prerequisites 目标文件
command 命令
写个GNU APP hello world:
vim android.c
#include <stdio.h>
int main(void) {
printf("hello world\n");
return 0;
}
gcc -c android.c //编译
gcc android.o -o android //生成执行文件
./android //执行文件
结果:“hello world”
Makefile上场:
vim Makefile: //定义规则
android: android.c
gcc -c android.c
gcc android.o -o android
clean:
rm -rf android.o
rm -rf android
make android //make解释Makefile的指令生成了android bin
./android //执行文件
结果:“hello world”
make clean
android.o android被删除
android build hello world.
非常感谢您花费时间阅读这份稿件,感觉有用可以分享给更多的学习者,转载请标记出处。
作者: [Alin]
时间: 2021 年 02月 01日
email:380475066@qq.com