macros.mk 528 B

12345678910111213141516171819202122
  1. # Find the local dir of the make file
  2. GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))
  3. # makes sure the target dir exists
  4. MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
  5. # test if two files are different, replacing the first
  6. # with the second if so
  7. # args: $1 - temporary file to test
  8. # $2 - file to replace
  9. define TESTANDREPLACEFILE
  10. if [ -f "$2" ]; then \
  11. if cmp "$1" "$2"; then \
  12. rm -f $1; \
  13. else \
  14. mv $1 $2; \
  15. fi \
  16. else \
  17. mv $1 $2; \
  18. fi
  19. endef