【问题标题】:Cannot copy files of directory into other directory无法将目录的文件复制到其他目录
【发布时间】:2014-08-17 23:09:30
【问题描述】:

我有一个 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`后缺少目标文件操作数

【问题讨论】:

    标签: makefile


    【解决方案1】:

    尝试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
    

    【讨论】:

      猜你喜欢
      • 2011-11-19
      • 1970-01-01
      • 2015-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      • 1970-01-01
      相关资源
      最近更新 更多