Changeset 34437


Ignore:
Timestamp:
2012-12-02T13:20:34+01:00 (5 years ago)
Author:
jow
Message:

rules.mk: provide a macro "file_copy" which removes any symlink in the destination dir that would be overwritten

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/rules.mk

    r34304 r34437  
    288288endef 
    289289 
     290# Recursively copy paths into another directory, purge dangling 
     291# symlinks before. 
     292# $(1) => File glob expression 
     293# $(2) => Destination directory 
     294define file_copy 
     295        for src_dir in $(sort $(foreach d,$(wildcard $(1)),$(dir $(d)))); do \ 
     296                ( cd $$src_dir; find -type f -or -type d ) | \ 
     297                        ( cd $(2); while :; do \ 
     298                                read FILE; \ 
     299                                [ -z "$$FILE" ] && break; \ 
     300                                [ -L "$$FILE" ] || continue; \ 
     301                                echo "Removing symlink $(2)/$$FILE"; \ 
     302                                rm -f "$$FILE"; \ 
     303                        done; ); \ 
     304        done; \ 
     305        $(CP) $(1) $(realpath $(2)/)/ 
     306endef 
     307 
    290308# file extension 
    291309ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) 
Note: See TracChangeset for help on using the changeset viewer.