GNU make manual 翻译(二十六)

本文探讨了当makefile的目标文件仅由隐式规则创建时,可以采用的一种替代makefile风格。通过将条目按前提条件分组,而非目标,实现更灵活的构建流程。

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

继续翻译

2.6 Another Style of Makefile                        
=============================                        
                        
When the objects of a makefile are created only by implicit rules, an 
alternative style of makefile is possible.  In this style of makefile,
you group entries by their prerequisites instead of by their targets.                        
Here is what one looks like:                        
                        
     objects = main.o kbd.o command.o display.o \                        
               insert.o search.o files.o utils.o                        
                        
     edit : $(objects)                        
             cc -o edit $(objects)                        
                        
     $(objects) : defs.h                        
     kbd.o command.o files.o : command.h                        
     display.o insert.o search.o files.o : buffer.h                        

2.6 另一种类型的 makefile

如果一个makefile的目标文件仅仅是由隐式规则所创建,那么另一种类型的makefile 是可能的。

在这种类型的makefile中,你可以把它们按照前提条件来分组,而不是按他们的目的来分组。

下面是它可能的样子:

objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o

edit : $(objects)
cc -o edit $(objects)

$(objects) : defs.h
kbd.o command.o files.o : command.h
display.o insert.o search.o files.o : buffer.h

后文待续

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值