Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. all: $(BINS)
  29. zkas: $(ZKASDEPS)
  30. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  31. --all-features --release --package $@
  32. cp -f target/$(RUST_TARGET)/release/$@ $@
  33. $(PROOFS_BIN): zkas $(PROOFS_SRC)
  34. ./zkas $(basename $@) -o $@
  35. contracts: zkas
  36. $(MAKE) -C src/contract/money
  37. $(MAKE) -C src/contract/dao
  38. $(MAKE) -C src/contract/consensus
  39. $(MAKE) -C src/contract/deployooor
  40. $(BINS): contracts $(PROOFS_BIN) $(BINDEPS)
  41. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  42. --all-features --release --package $@
  43. cp -f target/$(RUST_TARGET)/release/$@ $@
  44. check: contracts $(PROOFS_BIN)
  45. $(CARGO) hack check --release --feature-powerset --all
  46. fix: contracts $(PROOFS_BIN)
  47. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  48. clippy: contracts $(PROOFS_BIN)
  49. $(CARGO) clippy --release --all-features --all
  50. rustdoc: contracts $(PROOFS_BIN)
  51. $(CARGO) doc --release --all-features --workspace --document-private-items
  52. test: $(PROOFS_BIN) contracts
  53. $(CARGO) test --release --all-features --all
  54. test-no-run: $(PROOFS_BIN) contracts
  55. $(CARGO) test --release --all-features --all --no-run
  56. coverage: contracts $(PROOFS_BIN)
  57. $(CARGO) llvm-cov --release --all-features --workspace --html
  58. cleanbin:
  59. rm -f $(BINS)
  60. clean: cleanbin
  61. $(CARGO) clean
  62. install:
  63. @for i in $(BINS); \
  64. do \
  65. if test ! -f $$i; \
  66. then \
  67. echo "The '$$i' binary was not built."; \
  68. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  69. exit 1; \
  70. fi; \
  71. done;
  72. mkdir -p $(DESTDIR)$(PREFIX)/bin
  73. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  74. uninstall:
  75. for i in $(BINS); \
  76. do \
  77. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  78. done;
  79. .PHONY: all check fix clippy test test-no-run cleanbin clean \
  80. install uninstall contracts coverage