makefile - 使文件变量为空
问题描述
在这里,我试图从看起来像这样的 makefile 构建一个目标。
VER := 13.1-9.6
V1 = $(word 1,$(subst -, ,$(VER)))
V2 = $(word 2,$(subst -, ,$(VER)))
hello:
cp ./path/file.txt ./path/file_$(V1).txt;
cp ./path/file.txt ./path/file_$(V2).txt;
在这里,只想将“13.1-9.6”拆分为“13.1”和“9.6”,最后创建两个文件。
但得到以下输出
cp ./path/file.txt ./path/file_.txt;
cp ./path/file.txt ./path/file_.txt;
这里有什么问题,为什么变量是空的?
我在 Freebsd 11.4-RELEASE
的输出gmake -v
GNU Make 4.2.1
Built for amd64-portbld-freebsd11.3
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
解决方案
我无法重现这个,所以我不知道发生了什么。也许 FreeBSD 的人对 GNU make 应用了一些本地补丁来修改它的行为,或者你在你的设置中做了一些不同的事情。
$ make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
~$ cat Makefile
VER := 13.1-9.6
V1 = $(word 1,$(subst -, ,$(VER)))
V2 = $(word 2,$(subst -, ,$(VER)))
hello:
: cp ./path/file.txt ./path/file_$(V1).txt;
: cp ./path/file.txt ./path/file_$(V2).txt;
~$ make
: cp ./path/file.txt ./path/file_13.1.txt;
: cp ./path/file.txt ./path/file_9.6.txt;
推荐阅读
- java - 创建名为“namedParameterJdbcTemplate”的 bean 时出错,无法确定合适的驱动程序类,尝试运行 Web 应用程序
- javascript - 构造函数什么时候返回`this`,什么时候返回它被告知要返回的内容?
- google-apps-script - 根据单元格值自动将行复制到另一个工作表
- node.js - 如何在 Heroku 上正确部署 dist 和服务器端?
- c++ - 编译我的 3 个文件时,我收到错误,提示“operator=”不匹配
- javascript - 在 x 轴标签上方重新绘制值标签
- java - 构造函数注入在 Servlet + WELD + Tomcat 中不起作用
- r - R Shiny 根据 Userinput 动态添加 textinput 并打印 ui 输出
- algorithm - 在 3D 边界框中以最佳方式拟合其他球体之间的球体的算法?
- reactjs - 使用模拟函数测试 React 存储