.PHONY: build release test clean install manpage
TARGET_AARCH64 = aarch64-apple-darwin
TARGET_X86_64 = x86_64-apple-darwin
VERSION := $(shell cargo metadata --no-deps --format-version 1 \
| python3 -c "import sys,json; print(json.load(sys.stdin)['packages'][0]['version'])")
build:
cargo build
test:
cargo test
manpage:
cargo build
@test -f target/man/cow.1 || (echo "ERROR: target/man/cow.1 not generated by build.rs" && exit 1)
@echo "Man page at target/man/cow.1"
install: manpage
cargo install --path .
install -d /usr/local/share/man/man1
install -m 644 target/man/cow.1 /usr/local/share/man/man1/cow.1
@echo "Installed man page to /usr/local/share/man/man1/cow.1"
release: manpage
rustup target add $(TARGET_AARCH64)
rustup target add $(TARGET_X86_64)
cargo build --release --target $(TARGET_AARCH64)
cargo build --release --target $(TARGET_X86_64)
lipo -create \
target/$(TARGET_AARCH64)/release/cow \
target/$(TARGET_X86_64)/release/cow \
-output target/cow-universal
mkdir -p dist
cp target/cow-universal dist/cow
cp target/man/cow.1 dist/cow.1
tar -czf dist/cow-$(VERSION).tar.gz -C dist cow cow.1
@echo "SHA256: $$(shasum -a 256 dist/cow-$(VERSION).tar.gz | awk '{print $$1}')"
@echo "Release tarball: dist/cow-$(VERSION).tar.gz"
clean:
cargo clean
rm -rf dist