makefile中使用变量
直接看代码:
[xxx@localhost makefile]$ ls
makefile test1.cpp test2.cpp
[xxx@localhost makefile]$ cat makefile
all:test1 test2
XX=g++
CFLAGS=-Wall -O -gtest1:test1.o $(XX) test1.o -o test1
test2:test2.o$(XX) test2.o -o test2
test1.o:test1.cpp$(XX) $(CFLAGS) -c test1.cpp -o test1.o
test2.o:test2.cpp$(XX) $(CFLAGS) -c test2.cpp -o test2.oclean:rm -fr *.o
[xxx@localhost makefile]$ cat test1.cpp
#include<stdio.h>int main()
{printf("this is test1\n");return 0;
}
[xxx@localhost makefile]$ cat test2.cpp
#include<stdio.h>int main()
{printf("this is test2\n");return 0;
}
[xxx@localhost makefile]$
执行make:
[xxx@localhost makefile]$ make
g++ -Wall -O -g -c test1.cpp -o test1.o
g++ test1.o -o test1
g++ -Wall -O -g -c test2.cpp -o test2.o
g++ test2.o -o test2
[xxx@localhost makefile]$ ls
makefile test1 test1.cpp test1.o test2 test2.cpp test2.o
[xxx@localhost makefile]$ ./test1
this is test1
[xxx@localhost makefile]$ ./test2
this is test2
[xxx@localhost makefile]$ make clean
rm -fr *.o
[xxx@localhost makefile]$
-Wall表示输出所以警告信息,-O表示编译时进行优化,-g表示编译debug版本
makefile中使用变量相关推荐
- Makefile中的变量和shell变量
我们在写makefile时 多多少少会用到shell脚本, 对于变量的在shell中的使用有一些要注意的细节.让我们从一个简单的makefile来看看. 注意makefile中一定要有一个目标,且一定 ...
- Makefile中的变量
Makefile中的变量 2007-11-03 12:03 Makefile中变量有以下几个特征: 1. Makefile中变量和函数的展开(除规则命令行中的变量和函数以外),是在make读取make ...
- Linux学习笔记-Makefile中的变量及函数
Makefile中的变量 此处的变量不是C/C++,Java等中的变量(认为他是一个字符串就阔以了) 一般变量名用大写字母来写,如下所属: SUBDIR = src xml SUBDIR += osa ...
- Makefile中打印变量
一.使用info/warning/error增加调试信息 方法1: $(info, "here add the debug info") 但是此不能打印出.mk的行号 方法2: $ ...
- 对makefile中,变量定义中 通配符的理解
见如下例子: LIB=*.oall: $(LIB)@echo $^$(LIB):@echo $@ 执行结果: *.o *.o 所以 转载于:https://www.cnblogs.com/gaojia ...
- 【Makefile由浅入深完全学习记录6】Makefile中变量的高级主题上
抓住基础,学习更多技术,迎接挑战,加qq:1126137994 微信:liu1126137994 一起学习更多技术~ 上一篇文章学习了makefile中的预定义变量的使用,今天来继续学习makefil ...
- Makefile中wildcard函数的应用理解
文章目录 前言 1 "*"通配符使用场景 2 "*"通配符实例 总结 前言 如果我们想定义一系列比较类似的文件,我们很自然地就想起使用通配符.make 支持三种 ...
- Makefile中的符号说明
1 GNU make 在大型的开发项目中,通常有几十到上百个的源文件,如果每次均手工键入 gcc命令进行编译的话,则会 非常不方便.因此,人们通常利用 make工具来自动完成编译工作.这些工 ...
- Makefile中export的用法
在实际的项目中,总不会是只有一个 Makefile 文件,我们会在 Makefile 中调用另外的 Makefile 文件,呈现出 Makefile 的层级结构. 上层 make 过程要将所执行的 M ...
最新文章
- 数据交互极速体验-KETTLE的上手指南
- 解析字符串,每8位将2进制转为16进制
- 关于RF中类似于异常(TRY语句)情况的处理
- 检索数据_9_返回的字段在某个范围内的数据
- 一张图一个表——CSS选择器总结
- 前端学习(1302):实现es6的转化
- Open cup #2
- 【我的物联网成长记1】如何进行端到端开发?
- 不同分辨率图片匹配_超实用的图像超分辨率重建方法及应用介绍
- 多态应用-打印商品价格案例
- 如何直接打开android系统的wifi设置页面,防止intent劫持
- 作为程序猿----别说你不知道的人物!
- 读《VBScript程序员参考手册》,做的笔记
- [CTF]QWE加密
- Iproxy USB连接手机
- 实训日记(一)——剧本
- 论文阅读笔记:Masked Autoencoders Are Scalable Vision Learners
- SQL函数StDev与StDevP区别
- 一项调查:从浅到深的机器学习方法的血压估计使用生物传感器【翻译】
- 关于C语言编译的可执行文件 exe 发给好友解决办法 Visual Studio 2013 版本