将'$(VAR)'回显到文件 [英] Echo '$(VAR)' to a file

查看:75
本文介绍了将'$(VAR)'回显到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Makefile中的一行出现以下问题:

I have the following problem with a line from a Makefile:

echo 'include $(BASE)/Makefile.base' > file

如果我直接将其写入控制台,它会在文件中直接显示"include $(BASE)/Makefile.base",但是在Makefile中使用它时,$(BASE)总是被替换为空白,我想要它将其从字面上写到文件中.我试图写几种方法,但似乎找不到正确的方法...

If I write this directly into the console it literally prints 'include $(BASE)/Makefile.base' into the file, but when using it within a Makefile $(BASE) always gets replaced with a blank and i want it to literally write that to the file. I tried to write several ways but can't seem the find the right way...

推荐答案

echo 'include $$(BASE)/Makefile.base' > file

名为$的宏(使用$$调用)扩展为$.您经常需要在将成为外壳程序脚本的makefile的段中使用$$,因为make会自动扩展$L$(NAME)${NAME}(其中L是一个字母)(如果宏未设置为其他任何值,则返回空字符串.

The macro named $ (invoked using $$) expands to $. You frequently need to use $$ in segments of a makefile that will become shell script, because make expands $L, $(NAME) and ${NAME} (where L is a single-letter) automatically (to an empty string if the macro isn't set to anything else).

这篇关于将'$(VAR)'回显到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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