Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo
  6. # Optional compile target
  7. #RUST_TARGET = x86_64-unknown-linux-musl
  8. # Uncomment this if the above is uncommented
  9. #TARGET_PRFX = --target=
  10. # Binaries to be built
  11. BINS = drk darkfid ircd dnetview faucetd vanityaddr
  12. # zkas dependencies
  13. ZKASDEPS = \
  14. Cargo.toml \
  15. bin/zkas/Cargo.toml \
  16. $(shell find src/zkas -type f) \
  17. $(shell find src/serial -type f) \
  18. $(shell find bin/zkas/src -type f)
  19. # ZK proofs to compile with zkas
  20. PROOFS_SRC = $(shell find proof -type f -name '*.zk') example/simple.zk
  21. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  22. # Common dependencies which should force the binaries to be rebuilt
  23. BINDEPS = \
  24. Cargo.toml \
  25. $(shell find bin/*/src -type f) \
  26. $(shell find bin -type f -name '*.toml') \
  27. $(shell find src -type f) \
  28. $(shell find contrib/token -type f)
  29. all: $(BINS)
  30. zkas: $(ZKASDEPS)
  31. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  32. --all-features --release --package $@
  33. cp -f target/$(RUST_TARGET)/release/$@ $@
  34. $(PROOFS_BIN): zkas $(PROOFS_SRC)
  35. ./zkas $(basename $@) -o $@
  36. contracts: zkas
  37. $(MAKE) -C src/contract/money
  38. $(MAKE) -C src/contract/dao
  39. $(MAKE) -C src/contract/consensus
  40. $(MAKE) -C src/contract/deployooor
  41. token_lists:
  42. $(MAKE) -C contrib/token all
  43. $(BINS): token_lists contracts $(PROOFS_BIN) $(BINDEPS)
  44. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  45. --all-features --release --package $@
  46. cp -f target/$(RUST_TARGET)/release/$@ $@
  47. check: token_lists contracts $(PROOFS_BIN)
  48. $(CARGO) hack check --release --feature-powerset --all
  49. fix: token_lists contracts $(PROOFS_BIN)
  50. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  51. clippy: token_lists contracts $(PROOFS_BIN)
  52. $(CARGO) clippy --release --all-features --all
  53. rustdoc: token_lists contracts $(PROOFS_BIN)
  54. $(CARGO) doc --release --all-features --workspace --document-private-items
  55. test: token_lists $(PROOFS_BIN) contracts
  56. $(CARGO) test --release --all-features --all
  57. test-no-run: token_lists $(PROOFS_BIN) contracts
  58. $(CARGO) test --release --all-features --all --no-run
  59. coverage: token_lists contracts $(PROOFS_BIN)
  60. $(CARGO) llvm-cov --release --all-features --workspace --html
  61. cleanbin:
  62. rm -f $(BINS)
  63. clean: cleanbin
  64. $(CARGO) clean
  65. install:
  66. @for i in $(BINS); \
  67. do \
  68. if test ! -f $$i; \
  69. then \
  70. echo "The '$$i' binary was not built."; \
  71. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  72. exit 1; \
  73. fi; \
  74. done;
  75. mkdir -p $(DESTDIR)$(PREFIX)/bin
  76. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  77. uninstall:
  78. for i in $(BINS); \
  79. do \
  80. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  81. done;
  82. .PHONY: \
  83. all contracts token_lists check fix clippy rustdoc test test-no-run \
  84. cleanbin clean install uninstall coverage