X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=rules.mk;h=1ded3ba85510ba7af650c5d8bc915071d3b5eec1;hb=c86485210ba6136bc90fc2708611ae5a609b6bf1;hp=36bd22cac7b547e3d705d4e6fbe53fd46a700f3a;hpb=2371c6542e034c9a628072a61612a3945e5ac18b;p=openwrt%2Fstaging%2Fdedeckeh.git diff --git a/rules.mk b/rules.mk index 36bd22cac7..1ded3ba855 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) $(2) +endef + # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))