Makefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo +nightly
  6. # Compile target
  7. RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
  8. # Uncomment when doing musl static builds
  9. #RUSTFLAGS = -C target-feature=+crt-static -C link-self-contained=yes
  10. # zkas compiler binary
  11. ZKAS = ../../zkas
  12. # zkas circuits
  13. PROOFS_SRC = $(shell find proof -type f -name '*.zk')
  14. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  15. SRC = \
  16. Cargo.toml \
  17. ../../Cargo.toml \
  18. $(shell find src -type f -name '*.rs') \
  19. $(shell find ../../src -type f -name '*.rs') \
  20. BIN = $(shell grep '^name = ' Cargo.toml | cut -d' ' -f3 | tr -d '"')
  21. all: $(BIN)
  22. $(PROOFS_BIN): $(ZKAS) $(PROOFS_SRC)
  23. $(ZKAS) $(basename $@) -o $@
  24. $(BIN): $(PROOFS_BIN) $(SRC)
  25. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(RUST_TARGET) --release --package $@
  26. cp -f ../../target/$(RUST_TARGET)/release/$@ $@
  27. cp -f ../../target/$(RUST_TARGET)/release/$@ ../../$@
  28. # To build for android, install the Android NDK (Android Studio)
  29. # and then install cargo-ndk: `cargo install cargo-ndk`.
  30. # After that, add new android rust toolchains:
  31. # - rustup target add aarch64-linux-android
  32. # - rustup target add armv7-linux-androideabi
  33. # - rustup target add x86_64-linux-android
  34. # - rustup target add i686-linux-android
  35. $(BIN).android64:
  36. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) ndk -t arm64-v8a -o ./jniLibs build --release --package $(BIN)
  37. cp -f ../../target/aarch64-linux-android/release/$(BIN) $(BIN).$@
  38. $(BIN).android32:
  39. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) ndk -t armeabi-v7a -o ./jniLibs build --release --package $(BIN)
  40. cp -f ../../target/armv7-linux-androideabi/release/$(BIN) $(BIN).$@
  41. clean:
  42. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
  43. rm -f $(BIN) ../../$(BIN) $(BIN).android64 $(BIN).android32
  44. install: all
  45. mkdir -p $(DESTDIR)$(PREFIX)/bin
  46. cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
  47. chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN)
  48. uninstall:
  49. rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN)
  50. .PHONY: all clean install uninstall