如何在Makefile中使用自动变量获取第二个依赖文件? [英] How to get the second dependency file using Automatic Variables in a Makefile?

查看:448
本文介绍了如何在Makefile中使用自动变量获取第二个依赖文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从规则中获取第n个依赖文件,类似于bash中的$ n.我需要这样做是因为我想将各个依赖文件作为构建程序的选项.

I need to get the nth dependency file from a rule, something similar to $n in bash. I need this because I'd like to feed in individual dependency files as options to the build program.

这是一个例子:

dep.o: dep.src config1.cfg config2.cfg
    parse -cfg1 $2 -cfg2 $3 -o $@ $<

有可能吗?

推荐答案

dep.o: dep.src config1.cfg config2.cfg
    @echo the second preq is $(word 2,$^), the third is $(word 3,$^)

这篇关于如何在Makefile中使用自动变量获取第二个依赖文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆