当前位置:网站首页>Makefile 分隔文件名与后缀
Makefile 分隔文件名与后缀
2022-07-02 11:21:00 【Ayka】
参考Get filename without extension within makefile - Stack Overflow
https://stackoverflow.com/questions/13995906/get-filename-without-extension-within-makefile与GNU make 8.3 Functions for File Names
https://www.gnu.org/software/make/manual/make.html#File-Name-Functions最小样例如下:
SRCNAME = $(basename bar_1.foo.c)
SRCTYPE = $(suffix bar_1.foo.c)其结果为 SRCNAME 是 bar_1.foo,SRCTYPE 是 .c(注意这里的后缀名是包含句点的)。
实用样例如下:
SRCNAME = $(basename $(SRC))
SRCTYPE = $(suffix $(SRC))
all:
ifeq ($(SRCTYPE),.s)
all: assembly
else ifeq ($(SRCTYPE),.c)
all: program
else
$(error Source file suffix must be *.c or *.s)
endif
assembly:
@echo ASM
program:
@echo C
注意这里的第二个和第三个 all target 不可添加缩进, 参考conditional - How do you conditionally call a target based on a target variable (Makefile)? - Stack Overflow
注意 ifeq 条件的逗号前后不可添加空格,结尾只添加一个 endif。
例如若在命令行中执行
make SRC=rv32_fib.s则会输出
ASM
边栏推荐
- Quarkus学习四 - 项目开发到部署
- <口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
- 测试框架TestNG的使用(二):testNG xml的使用
- Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
- 腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
- Pycharm连接远程服务器
- [development environment] StarUML tool (download software | StarUML installation | StarUML creation project)
- 博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
- TeamTalk源码分析之win-client
- OpenHarmony笔记-----------(四)
猜你喜欢

Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people

Uniapp automated test learning

uniapp自动化测试学习

C crystal report printing
![[deep learning] simple implementation of neural network forward propagation](/img/a6/9b4896c62e9b77f9d528c3c9efc58f.jpg)
[deep learning] simple implementation of neural network forward propagation

Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)

测试框架TestNG的使用(二):testNG xml的使用

复用和分用

Pycharm连接远程服务器

Method of creating linked server for cross server data access
随机推荐
MySQL 45 lecture - learning the actual battle of MySQL in Geek time 45 Lecture Notes - 05 | easy to understand index (Part 2)
Fabric.js 元素被选中时保持原有层级
PHP linked list creation and traversal
C语言高级用法--函数指针:回调函数;转换表
Fabric.js 缩放画布
[to be continued] [UE4 notes] l5ue4 model import
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
STM32-DAC实验&高频DAC输出测试
由粒子加速器产生的反中子形成的白洞
【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
The most complete analysis of Flink frame window function
buuctf-pwn write-ups (7)
删除元素(带过渡动画)
Use of freemaker
Daily learning 3
PyQt5_ Qscrollarea content is saved as a picture
Quarkus learning IV - project development to deployment
< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621
Generally speaking, if the error of inconsistent tab and space occurs frequently
Check password