如何在 GNU Make 中处理带等号的文件名?
How to handle filenames with equals signs in GNU Make?
我正在尝试使用 GNU Make 自动处理有时包含 "equal sign" 的文件。例如,假设文件名为 hello=world.txt
,Makefile
如下:
default: hello=world.txt.gz
hello=world.txt.gz : hello=world.txt
gzip hello=world.txt
echo done
您收到以下错误:
test.make:5: *** commands commence before first target. Stop.
如何逃避等号?我试过反斜杠、双引号和单引号。有什么想法吗?
使用%=
在 makefile 中,特殊字符必须通过 %
进行转义
这是一个解决方案:
equal := =
default: hello$(equal)world.txt.gz
hello$(equal)world.txt.gz : hello$(equal)world.txt
gzip hello$(equal)world.txt
echo done
我正在尝试使用 GNU Make 自动处理有时包含 "equal sign" 的文件。例如,假设文件名为 hello=world.txt
,Makefile
如下:
default: hello=world.txt.gz
hello=world.txt.gz : hello=world.txt
gzip hello=world.txt
echo done
您收到以下错误:
test.make:5: *** commands commence before first target. Stop.
如何逃避等号?我试过反斜杠、双引号和单引号。有什么想法吗?
使用%= 在 makefile 中,特殊字符必须通过 %
进行转义这是一个解决方案:
equal := =
default: hello$(equal)world.txt.gz
hello$(equal)world.txt.gz : hello$(equal)world.txt
gzip hello$(equal)world.txt
echo done