How to copy a directory in a Makefile?

前提是你 提交于 2019-12-03 09:45:28
liori

Well, I'd just use rsync. Any make script you will create with these constraints will just replicate its functionality, and most probably will be slower and may contain bugs. An example rule might look:

build/images:
    rsync -rupE images build/

.PHONY: build/images

(.PHONY to trigger the rule every time).

Maybe symlinks or hardlinks can be used instead?

build/images:
    ln -s ../images build/images

If you really want to avoid rsync and links, this piece re-implements them somehow (not tested, needs find, mkdir, and plain cp):

image_files:=$(shell find images -type f)
build/images/%: images/%
    mkdir -p $(@D)
    cp $< $@

build: $(patsubst %,build/%,$(image_files))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!