在Makefile安装中将目录移动到位的最佳方法是什么? [英] What's the best way to move a directory into place in a Makefile install?

查看:68
本文介绍了在Makefile安装中将目录移动到位的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Makefile中使用通常的技术来安装单个文件:

I'm currently using the usual technique in my Makefile to install individual files:

install:
    install -D executable ${BIN_DIR}

但是我遇到了一种情况,我需要将整个目录及其下的所有文件移动到适当的位置.

But I just ran across a situation where I need to move a whole directory and all files underneath it into place.

cp -r是最好的方法,还是有更多的linux-y/unix-y方法呢?

Is cp -r the best way or is there a more linux-y/unix-y way to do this?

推荐答案

是的,虽然-r是cp的相对较晚的添加,但很难想到cp -r是更统一的方式.我可以告诉您我们使用的方式,并且这种方式在文件系统之类的系统中都可以很好地工作:

Yeah, it's hard to think of a more unix-ish way that cp -r, although the -r is a relatively late addition to cp. I can tell you the way we used to do it, and that works neatly across filesystems and such:

src是您要移动的源目录,而/path/to/target是目标的绝对路径.然后您可以使用:

Let src be the source directory you want to move, and /path/to/target be an absolute path to the target. Then you can use:

$ tar cf - src | (cd /path/to/target; tar xf -)

这篇关于在Makefile安装中将目录移动到位的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆