无法将目录文件复制到其他目录中

时间:2014-08-17 14:53:58

标签: makefile

我有一个Makefile,它应该将我的所有点文件复制到主目录中。遗憾的是,GNUMake不支持bash中使用的通配符,并且常见通配符$(wildcard *.c)仅限于特殊文件类型。

我的 Makefile 是:

SHELL := /bin/bash

profile:
    @cp -r profile/ $(HOME)/

.PHONY: profile

到目前为止我尝试的其他变体:

  1. cp -r profile/* $(HOME) => cp: cannot stat profile/*: No such file or directory
  2. cp -r profile/$(wildcard *) $(HOME) =>尝试复制当前目录中的所有文件
  3. cp -r $(wildcard profile/*) $(HOME)/ => cp: missing destination file operand after /home/foobar
  4. cp -r $(wildcard profile/*) $(HOME)/$(wildcard profile/*) => cp:在/ home / foobar`
  5. 之后缺少目标文件操作数

1 个答案:

答案 0 :(得分:3)

在makefile

中使用直接shell命令尝试The shell Function
profile:
    $shell(cp -r profile/* $(HOME)/)

.PHONY: profile

否则在初始化时设置HOME变量

SHELL := /bin/bash
HOME  := $(shell echo $HOME)
profile:
    @cp -r profile/* $(HOME)/

.PHONY: profile
相关问题