# Find the local dir of the make file GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))) # makes sure the target dir exists MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi # test if two files are different, replacing the first # with the second if so # args: $1 - temporary file to test # $2 - file to replace define TESTANDREPLACEFILE if [ -f "$2" ]; then \ if cmp "$1" "$2"; then \ rm -f $1; \ else \ mv $1 $2; \ fi \ else \ mv $1 $2; \ fi endef