Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. toml = $@/Cargo.toml
  2. bin = $@/target/debug/$@
  3. doc-crate-toml=./.imag-documentation/Cargo.toml
  4. ECHO=$(shell which echo) -e
  5. MAKE=$(shell which make)
  6. BASH=$(shell which bash)
  7. CARGO=$(shell which cargo)
  8. BINS=$(shell find -maxdepth 1 -name "imag-*" -type d | sort)
  9. LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d | sort)
  10. BIN_TARGETS=$(patsubst imag-%,,$(BINS))
  11. BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test)
  12. LIB_TARGETS=$(LIBS)
  13. LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),$(x)-test)
  14. TARGETS=$(BIN_TARGETS) $(LIB_TARGETS)
  15. RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release)
  16. INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install)
  17. CHECK_TARGETS=$(foreach x,$(TARGETS),$(x)-check)
  18. all: $(TARGETS) imag-bin
  19. @$(ECHO) "\t[ALL ]"
  20. imag-bin:
  21. @$(ECHO) "\t[IMAG ][BUILD ]"
  22. @$(CARGO) build --manifest-path ./bin/Cargo.toml
  23. imag-bin-release:
  24. @$(ECHO) "\t[IMAG ][RELEASE]"
  25. @$(CARGO) build --release --manifest-path ./bin/Cargo.toml
  26. imag-bin-install:
  27. @$(ECHO) "\t[IMAG ][INSTALL]"
  28. @$(CARGO) install --force --path ./bin
  29. imag-bin-check:
  30. @$(ECHO) "\t[IMAG ][CHECK ]"
  31. @$(CARGO) check --manifest-path ./bin/Cargo.toml
  32. release: $(RELEASE_TARGETS) imag-bin-release
  33. @$(ECHO) "\t[RELEASE]"
  34. bin: $(BIN_TARGETS) imag-bin
  35. @$(ECHO) "\t[ALLBIN ]"
  36. bin-test: $(BIN_TARGET_TESTS) imag-bin
  37. lib: $(LIB_TARGETS)
  38. @$(ECHO) "\t[ALLLIB ]"
  39. lib-test: $(LIB_TARGETS_TEST)
  40. test: bin-test lib-test
  41. install: $(INSTALL_TARGETS) imag-bin-install
  42. @$(ECHO) "\t[INSTALL]"
  43. update:
  44. @$(ECHO) "\t[UPDATE ]"
  45. @$(CARGO) update
  46. clean:
  47. @$(ECHO) "\t[CLEAN ]"
  48. @$(CARGO) clean
  49. check: $(CHECK_TARGETS) imag-bin-check
  50. check-outdated:
  51. @$(ECHO) "\t[OUTDATED]"
  52. @$(CARGO) outdated
  53. $(TARGETS): %: .FORCE
  54. @$(ECHO) "\t[CARGO ]:\t$@"
  55. @$(CARGO) build --manifest-path ./$@/Cargo.toml
  56. $(BIN_TARGET_TESTS): %-test: % .FORCE
  57. @$(ECHO) "\t[CARGO ][TEST]: \t$@"
  58. @$(CARGO) test --manifest-path ./$(subst -test,,$@)/Cargo.toml
  59. @$(ECHO) "\t[BINTEST]:\t$@"
  60. if [ -f $(subst -test,,$@)/tests/Makefile ]; then \
  61. $(MAKE) -C $(subst -test,,$@)/tests || exit 1;\
  62. fi;
  63. $(RELEASE_TARGETS): %: .FORCE
  64. @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)"
  65. @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml
  66. $(LIB_TARGETS_TEST): %: .FORCE
  67. @$(ECHO) "\t[TEST ]:\t$@"
  68. @$(CARGO) test --manifest-path ./$(subst -test,,$@)/Cargo.toml
  69. $(INSTALL_TARGETS): %: .FORCE imag-bin-install
  70. @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)"
  71. @$(CARGO) install --force --path ./$(subst -install,,$@)
  72. $(CHECK_TARGETS): %: .FORCE
  73. @$(ECHO) "\t[CHECK ]:\t$(subst -check,,$@)"
  74. @$(CARGO) check --manifest-path ./$(subst -check,,$@)/Cargo.toml
  75. .FORCE: