当前位置:网站首页>Makefile 分隔文件名与后缀
Makefile 分隔文件名与后缀
2022-07-02 11:21:00 【Ayka】
参考Get filename without extension within makefile - Stack Overflowhttps://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
边栏推荐
猜你喜欢
Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
QT new project
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
< 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
Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
Essential elements of science fiction 3D scenes - City
Method of creating linked server for cross server data access
关于Flink框架窗口(window)函数最全解析
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
随机推荐
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
Golang 快速生成数据库表的 model 和 queryset
The conference on the growth of all things was held in Hangzhou, and dangbei was selected into the top 100 list of future unicorns in China in 2022
Default slot, named slot, scope slot
OpenCV调用USB摄像头的点滴
How kaggle uses utility script
复用和分用
Pycharm连接远程服务器
由粒子加速器产生的反中子形成的白洞
Fabric. JS free drawing ellipse
Yyds dry goods inventory software encryption lock function
3. Function pointers and pointer functions
Data consistency between redis and database
P1042 [noip2003 popularization group] Table Tennis
抓包工具fiddler学习
Analysis of CPU surge in production environment service
Fabric. JS free draw circle
Advanced usage of C language -- function pointer: callback function; Conversion table
《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
Launcher startup process