linux - 在 Makefile 中使用变量操作

标签 linux bash makefile compiler-errors compilation

我正在尝试创建目标文件名 = 文件夹名的 Makefile。 我没有硬编码,而是使用了函数

FILE=$(PWD##*/)

我也试过 FILE=$(echo PWD##*/)FILE=$(echo $(PWD##*/))。 但是我收到一个错误:未终止的变量引用。 我知道在 Makefile 中很难进行这样的变量操作。有解决办法吗?

谢谢

最佳答案

像这样设置 FILE 应该可行:

FILE = $(notdir $(PWD))

另一种方法是调用 shell 来做同样的事情:

FILE = $(shell basename $${PWD})

关于linux - 在 Makefile 中使用变量操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46720439/

相关文章:

javascript 设置超时();不适用于 linux (firefox)

bash - 简化 bash 脚本?

linux - Sed 没有写入文件

linux - Shell 中的 Perl glob 等效项用于循环匹配模式的文件

c - 新手 : what is wrong with my makefile?

android - 低级安卓调试

c - `open`和 `close`如何异步串口?

python - 在Python中将声卡输入播放到声卡输出

makefile - 如何使 Make *not* 打印“目标配方失败?

shell - 将环境变量导出到 Makefile shell