tfkit.mk 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. test: tfkit
  9. @tfkit/runtests
  10. tfkit: bin/tfkit_init
  11. @bin/tfkit_init
  12. tfkit_delete:
  13. @rm -rf tfkit
  14. @rm -f bin/tfkit_init
  15. @rmdir bin 2>/dev/null || true
  16. bin/tfkit_init:
  17. @mkdir -p bin
  18. @echo '#!/bin/sh' >bin/tfkit_init
  19. @echo '' >>bin/tfkit_init
  20. @echo 'die() {' >>bin/tfkit_init
  21. @echo ' echo "$$1" >&2' >>bin/tfkit_init
  22. @echo ' exit 3' >>bin/tfkit_init
  23. @echo '}' >>bin/tfkit_init
  24. @echo '' >>bin/tfkit_init
  25. @echo 'if test -d tfkit/.git;' >>bin/tfkit_init
  26. @echo 'then' >>bin/tfkit_init
  27. @echo ' exit 0' >>bin/tfkit_init
  28. @echo 'else' >>bin/tfkit_init
  29. @echo '' >>bin/tfkit_init
  30. @echo ' origin=""' >>bin/tfkit_init
  31. @echo ' git remote | grep -q origin && origin=origin' >>bin/tfkit_init
  32. @echo ' test $$(git remote | wc -l) -eq 1 && origin=$$(git remote)' >>bin/tfkit_init
  33. @echo ' test -n "$$origin" || die "could not guess remote name"' >>bin/tfkit_init
  34. @echo '' >>bin/tfkit_init
  35. @echo '' >>bin/tfkit_init
  36. @echo ' uri=$$(git remote -v | grep "^$$origin.*(fetch)" | tr $$"\t" " " | cut -d\ -f2)' >>bin/tfkit_init
  37. @echo ' tfkit_uri=$$(dirname $$uri)/tfkit.git' >>bin/tfkit_init
  38. @echo '' >>bin/tfkit_init
  39. @echo ' git clone $$tfkit_uri || die "failed to clone tfkit"' >>bin/tfkit_init
  40. @echo '' >>bin/tfkit_init
  41. @echo 'fi' >>bin/tfkit_init
  42. @chmod +x bin/tfkit_init
  43. tfkit_update: tfkit
  44. @cd tfkit
  45. @git --git-dir tfkit/.git pull
  46. .PHONY: test