makefile filter &&filter-out

博客介绍了Makefile中的过滤和排除功能。通过示例展示了如何使用filter过滤出.c和.s文件参加编译,以及使用filter-out去除变量中指定的字串,如从objects中去除mains定义的文件名,返回剩余文件名。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


    sources := foo.c bar.c baz.s abc.h
    foo: $(sources)
            gcc $(filter %.c %.s,$(sources)) -o foo

says that foo depends of foo.c、bar.c、baz.s and ugh.h but only foo.c、bar.c and baz.s should be specified in the command to the compiler.
过滤出.c和.s 参加编译。

    objects := main1.o foo.o main2.o bar.o
    mains   := main1.o main2.o

the following generates a list which contains all the object files not in ‘mains’:

$(filter-out $(mains),$(objects))
实现了去除变量“objects”中“mains”定义的字串(文件名)功能。它的返回值为“foo.o bar.o”。

转载于:https://www.cnblogs.com/yuguangyuan/p/10929967.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值