tfkit.mk 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Makefile module to deploy tfkit
  2. #
  3. # Will add bin/tfkit_init utility, and use it to guess URI to tfkit.git,
  4. # and clone tfkit to current directory.
  5. #
  6. # Adds targets: test to run tfkit tests, tfkit to deploy tfkit, tfkit_update to
  7. # pull tfkit updates, and tfkit_delete to remove the tfkit code.
  8. #
  9. # NOTE: Do not edit this file in your project directory as it will overwrite
  10. # itself when you call tfkit_update!!!
  11. test: tfkit
  12. @tfkit/runtests
  13. tfkit: bin/tfkit_init
  14. @bin/tfkit_init
  15. tfkit_delete:
  16. @rm -rf tfkit
  17. @rm -f bin/tfkit_init
  18. @rmdir bin 2>/dev/null || true
  19. bin/tfkit_init:
  20. @mkdir -p bin
  21. @echo '#!/bin/sh' >bin/tfkit_init
  22. @echo '' >>bin/tfkit_init
  23. @echo 'die() {' >>bin/tfkit_init
  24. @echo ' echo "$$1" >&2' >>bin/tfkit_init
  25. @echo ' exit 3' >>bin/tfkit_init
  26. @echo '}' >>bin/tfkit_init
  27. @echo '' >>bin/tfkit_init
  28. @echo 'if test -d tfkit/.git;' >>bin/tfkit_init
  29. @echo 'then' >>bin/tfkit_init
  30. @echo ' exit 0' >>bin/tfkit_init
  31. @echo 'else' >>bin/tfkit_init
  32. @echo '' >>bin/tfkit_init
  33. @echo ' origin=""' >>bin/tfkit_init
  34. @echo ' git remote | grep -q origin && origin=origin' >>bin/tfkit_init
  35. @echo ' test $$(git remote | wc -l) -eq 1 && origin=$$(git remote)' >>bin/tfkit_init
  36. @echo ' test -n "$$origin" || die "could not guess remote name"' >>bin/tfkit_init
  37. @echo '' >>bin/tfkit_init
  38. @echo '' >>bin/tfkit_init
  39. @echo ' uri=$$(git remote -v | grep "^$$origin.*(fetch)" | tr $$"\t" " " | cut -d\ -f2)' >>bin/tfkit_init
  40. @echo ' tfkit_uri=$$(dirname $$uri)/tfkit.git' >>bin/tfkit_init
  41. @echo '' >>bin/tfkit_init
  42. @echo ' git clone $$tfkit_uri || die "failed to clone tfkit"' >>bin/tfkit_init
  43. @echo '' >>bin/tfkit_init
  44. @echo 'fi' >>bin/tfkit_init
  45. @chmod +x bin/tfkit_init
  46. tfkit_update: tfkit
  47. @cd tfkit
  48. @git -C tfkit pull
  49. @cp tfkit/tfkit.mk .
  50. .PHONY: test