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

标签 makefile

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

我的Makefile是:

SHELL := /bin/bash

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

.PHONY: profile

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

  1. cp -r profile/* $(HOME) => cp: 无法统计配置文件/*: 没有这样的文件或目录
  2. cp -r profile/$(wildcard *) $(HOME) => 尝试复制当前目录中的所有文件
  3. cp -r $(通配符配置文件/*) $(HOME)/ => cp:/home/foobar 之后缺少目标文件操作数
  4. 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/

相关文章:

makefile - debhelper:将 `prefix=/usr' 添加到所有隐式 make 调用

makefile - 将目标名称传递给 makefile 中的依赖项列表

c++ - 我如何理解这个 makefile 规则的实质内容?

linux - 如何使用 makefile 创建测试结果

opencv - 无法在 mac osx 上使用brew或make安装opencv

makefile - 使用 patsubst : need two substitutions 的 GNU Make

python - 在cygwin中安装python和make

c++ - gcc 编译器错误消息路径取消父级

qt - qmake 设置安装目录

linux - "clock skew detected” 安装时出现警告