通过对象的微小更改构建多个可执行文件
考虑以下 Makefile
COMP = compiler
OBJECTS = file1 \
file2 \
file3 \
file4 \
file5_suffix \
file6 \
file7 \
file8 \
file9_suffix \
file10
all: $(OBJECTS)
$(COMP) $(OBJECTS) -o bin/executable_suffix
是否有一种简单的方法可以为不同的 suffix
值编译多个可执行文件?例如,相当于
COMP = compiler
OBJECTS1 = file1 \
file2 \
file3 \
file4 \
file5_s1 \
file6 \
file7 \
file8 \
file9_s1 \
file10
OBJECTS2 = file1 \
file2 \
file3 \
file4 \
file5_s2 \
file6 \
file7 \
file8 \
file9_s2 \
file10
all: $(OBJECTS1) $(OBJECTS2)
$(COMP) $(OBJECTS1) -o bin/executable_s1
$(COMP) $(OBJECTS2) -o bin/executable_s2
但不重新定义整个对象列表?在我处理的现实情况中,可能需要构建 50 多个对象和十几个二进制文件,每次对象列表之间只有很小的变化,因此最好不必每次都列出所有对象。
Consider the following Makefile
COMP = compiler
OBJECTS = file1 \
file2 \
file3 \
file4 \
file5_suffix \
file6 \
file7 \
file8 \
file9_suffix \
file10
all: $(OBJECTS)
$(COMP) $(OBJECTS) -o bin/executable_suffix
Is there an easy way to compile multiple executables for different values of suffix
? For example, the equivalent of
COMP = compiler
OBJECTS1 = file1 \
file2 \
file3 \
file4 \
file5_s1 \
file6 \
file7 \
file8 \
file9_s1 \
file10
OBJECTS2 = file1 \
file2 \
file3 \
file4 \
file5_s2 \
file6 \
file7 \
file8 \
file9_s2 \
file10
all: $(OBJECTS1) $(OBJECTS2)
$(COMP) $(OBJECTS1) -o bin/executable_s1
$(COMP) $(OBJECTS2) -o bin/executable_s2
but without redefining the whole list of objects? In the real life case I am dealing with, there might be 50+ objects and a dozen binaries to build, with only small changes between the object list each time, so it would be nice not to have to list all the objects each time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样就可以了。如果您可以对变化施加更多限制,它可以变得更加优雅。
This will do it. It can be made more elegant if there are more restrictions you can put on the variations.