diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-12-02 12:20:34 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-12-02 12:20:34 +0000 |
commit | 828597693e9dd776ca65dab2506a650fba5087d3 (patch) | |
tree | c3d719240dea4198c057a0e2c614ee35ff7c274b | |
parent | 9f3dc9afa7cc440821024b1af3129035dcebbf14 (diff) | |
download | upstream-828597693e9dd776ca65dab2506a650fba5087d3.tar.gz upstream-828597693e9dd776ca65dab2506a650fba5087d3.tar.bz2 upstream-828597693e9dd776ca65dab2506a650fba5087d3.zip |
rules.mk: provide a macro "file_copy" which removes any symlink in the destination dir that would be overwritten
SVN-Revision: 34437
-rw-r--r-- | rules.mk | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -287,6 +287,24 @@ define locked -c '$(subst ','\'',$(1))' endef +# Recursively copy paths into another directory, purge dangling +# symlinks before. +# $(1) => File glob expression +# $(2) => Destination directory +define file_copy + for src_dir in $(sort $(foreach d,$(wildcard $(1)),$(dir $(d)))); do \ + ( cd $$src_dir; find -type f -or -type d ) | \ + ( cd $(2); while :; do \ + read FILE; \ + [ -z "$$FILE" ] && break; \ + [ -L "$$FILE" ] || continue; \ + echo "Removing symlink $(2)/$$FILE"; \ + rm -f "$$FILE"; \ + done; ); \ + done; \ + $(CP) $(1) $(realpath $(2)/)/ +endef + # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) |