summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-02 12:20:34 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-02 12:20:34 +0000
commit6d0c73d11bf42070b9a4732b68411e0696f673f2 (patch)
tree5c2da9fe9f7f317a227399c73ad7e0b78482f2cb
parentb937cbf1aed0f2af2637e00616c0bca8481a3370 (diff)
rules.mk: provide a macro "file_copy" which removes any symlink in the destination dir that would be overwritten
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34437 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--rules.mk18
1 files changed, 18 insertions, 0 deletions
diff --git a/rules.mk b/rules.mk
index 36bd22cac..7139f79ef 100644
--- a/rules.mk
+++ b/rules.mk
@@ -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)))