我有一个 Makefile,它应该将所有点文件复制到主目录中。不幸的是,GNUMake
不支持 bash 中使用的通配符,并且常见通配符 $(wildcard *.c)
仅限于特殊文件类型。
我的Makefile是:
SHELL := /bin/bash
profile:
@cp -r profile/ $(HOME)/
.PHONY: profile
到目前为止我尝试过的其他变体:
cp -r profile/* $(HOME)
=>cp: 无法统计配置文件/*: 没有这样的文件或目录
cp -r profile/$(wildcard *) $(HOME)
=> 尝试复制当前目录中的所有文件cp -r $(通配符配置文件/*) $(HOME)/
=>cp:/home/foobar 之后缺少目标文件操作数
cp -r $(通配符配置文件/*) $(HOME)/$(通配符配置文件/*) =>
cp:/home/foobar`后缺少目标文件操作数
最佳答案
尝试The shell Function在 makefile 中使用直接 shell 命令
profile:
$shell(cp -r profile/* $(HOME)/)
.PHONY: profile
否则在开始时设置 HOME 变量,如下所示
SHELL := /bin/bash
HOME := $(shell echo $HOME)
profile:
@cp -r profile/* $(HOME)/
.PHONY: profile
关于makefile - 无法将目录中的文件复制到其他目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25350318/