Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. token_lists:
  41. $(MAKE) -C contrib/token all
  42. $(BINS): token_lists contracts $(PROOFS_BIN) $(BINDEPS)
  43. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  44. --all-features --release --package $@
  45. cp -f target/$(RUST_TARGET)/release/$@ $@
  46. check: token_lists contracts $(PROOFS_BIN)
  47. $(CARGO) hack check --release --feature-powerset --all
  48. fix: token_lists contracts $(PROOFS_BIN)
  49. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  50. clippy: token_lists contracts $(PROOFS_BIN)
  51. $(CARGO) clippy --release --all-features --all
  52. rustdoc: token_lists contracts $(PROOFS_BIN)
  53. $(CARGO) doc --release --all-features --workspace --document-private-items
  54. test: token_lists $(PROOFS_BIN) contracts
  55. $(CARGO) test --release --all-features --all
  56. cleanbin:
  57. rm -f $(BINS)
  58. clean: cleanbin
  59. $(CARGO) clean
  60. install:
  61. @for i in $(BINS); \
  62. do \
  63. if test ! -f $$i; \
  64. then \
  65. echo "The '$$i' binary was not built."; \
  66. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  67. exit 1; \
  68. fi; \
  69. done;
  70. mkdir -p $(DESTDIR)$(PREFIX)/bin
  71. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  72. uninstall:
  73. for i in $(BINS); \
  74. do \
  75. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  76. done;
  77. .PHONY: all contracts token_lists check fix clippy rustdoc test cleanbin clean install uninstall