当前位置:网站首页>Makefile自动推导的简单例程
Makefile自动推导的简单例程
2022-08-03 05:24:00 【langaopeng】
最近在深入的研究Makefile的编译过程。发现看Makefile代码时,觉得挺简单。其实不然,当你合上课本写的时候,发现有时就是不按照你的思想走。下面我用最简单的例子分享一下Makefile自动根据C代码的include情况推导规则。
1 在同一个目录下建立test.c,test_sub.c,test.h, test1.h, test2.h。test.c包含test.h,test.h包含test1.h,test1.h包含test2.h。
Makefile代码如下:
src :=test.c test_sub.c
obj:=$(src:.c=.o)
def:=$(src:.d=.o)
IFLAGS:= -I.
test:$(obj)
cc -o test $(obj) $(LDFLAGS) $(IFLAGS)
%.d:%.c
cc -MF $(@:%.o=%.d) -o @ -M $^ #生成test.d test_sub.d 内容为:test.o:test.c .....
sed -i 's/\(.*\)\.o:/\1\.o \1\.d:/g' [email protected] #将test.o:test.c变成test.o test.d:test.c .....
-include $(def) #包含.d文件,自动推导成隐晦规则
.PHONY : clean
clean:
-rm $(obj) $(def)
边栏推荐
- Ansible installation and deployment detailed process, basic operation of configuration inventory
- 动漫:海贼王女
- ASP.NET MVC:自定义 Route
- 中国生物反应器行业发展现状及前景规划分析报告报告2022~2028年
- new / malloc / delete / free之间的区别
- 自监督论文阅读笔记 Ship Detection in Sentinel 2 Multi-Spectral Images with Self-Supervised Learning
- 布尔盲注需简化代码
- 自监督论文阅读笔记FIAD net: a Fast SAR ship detection network based on feature integration attention and self
- 自监督论文阅读笔记: MoCoV2使用动量对比学习改进基线
- BeanFactory和FactoryBean的区别
猜你喜欢

MySQL 下载和安装详解

自监督论文阅读笔记 Ship Detection in Sentinel 2 Multi-Spectral Images with Self-Supervised Learning

自监督论文阅读笔记SELF-SUPERVISED SPECTRAL MATCHING NETWORK FOR HYPERSPECTRAL TARGET DETECTION

优雅的拦截TabLayout的点击事件

神经网络基础

联邦学习摘录

Browser multi-threaded off-screen rendering, compression and packaging scheme

自监督论文阅读笔记 SimCLRV2 Big Self-Supervised Models are Strong Semi-Supervised Learners
ASP.NET MVC3的伪静态实现

微信小程序 自定义tabBar
随机推荐
西塞罗 论老年
中国水环境治理行业投融资分析及“十四五”规划建议报告2022~2028年
关于梯度下降法的一些优化方法
自监督论文阅读笔记 DenseCL:Dense Contrastive Learning for Self-Supervised Visual Pre-Training
Dynamic adjustment subject web system?Look at this one is enough
深度学习基本概念
经典论文-ResNet
网络间通信
中国食品产业园区行业前景规划建议及投融资模式分析报告2022~2028年
MMU 介绍-[TBL/page table work]
自监督论文阅读笔记 TASK-RELATED SELF-SUPERVISED LEARNING FOR REMOTE SENSING IMAGE CHANGE DETECTION
自监督论文阅读笔记 Self-Supervised Visual Representation Learning with Semantic Grouping
进程间通讯 (IPC 技术) - 信号
漫谈Map Reduce 参数优化
IPC通信 - 管道
【HQL】(一)json字符串处理json_tuple和get_json_object
Mysql 外键详解(Foreign Key)
该描述怎么写成SQL语句
自监督论文阅读笔记Reading and Writing: Discriminative and Generative Modelingfor Self-Supervised Text Recogn
用iPhone前摄3D人像建模,Meta:我看行