生成文件:使用“纯生成语法"读取文件(无shell命令) [英] Makefiles: reading a file with 'pure make syntaxis' (no shell commands)

查看:78
本文介绍了生成文件:使用“纯生成语法"读取文件(无shell命令)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取文本文件的内容,并将其分配给我的makefile中的变量.我阅读了制作手册 ch 8.6:文件功能,并在我的makefile中写了这个简单的代码段:

I want to read the content of a text file and assign it to a variable in my makefile. I read the make manual ch 8.6: The file function, and wrote this simple snippet in my makefile:

# Snippet from my makefile

my_var = $(file < C:/full/path/to/my_file.txt)

all:
    @echo $(my_var)

我收到以下错误:

*** Invalid file operation: < C:/full/path/to/my_file.txt.  Stop.

我故意选择$(file ..)而不是$(shell ..)函数来读取文件.那是因为我的makefile应该尽可能与平台无关. $(file ..)函数是纯makefile语法,而$(shell ..)函数包含shell语法.

I deliberately choose for the $(file ..) instead of the $(shell ..) function to read out the file. That's because my makefile should be as platform independent as possible. The $(file ..) function is pure makefile-syntax, whereas the $(shell ..) function contains shell-syntax.

我在做什么错了?

推荐答案

如果要使用$(file <)读取文件,则需要至少升级到4.2版.

You'll need to upgrade to at least make 4.2 if you want to read files with $(file <).

这篇关于生成文件:使用“纯生成语法"读取文件(无shell命令)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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