11all : build
22
3- AKG := target/release/authrorized -keys-github
3+ NATIVE_EXE := target/release/authorized -keys-github
44
55# When building the testing image, make the UID and GID match ours
66UID := $(shell id -u)
@@ -34,16 +34,35 @@ endef
3434# To speed up interactive development with cargo, cache the cargo home in a subdir of `target`
3535target/.docker_cargo_home :
3636 mkdir -p $@
37- $(AKG ) : target/.docker_cargo_home
37+ $(NATIVE_EXE ) : target/.docker_cargo_home
3838else
3939define docker_exec
4040$(2 )
4141endef
4242endif
4343
44- $(AKG ) : Cargo.toml Cargo.lock src/main.rs
44+ $(NATIVE_EXE ) : Cargo.toml Cargo.lock src/main.rs
4545 $(call docker_exec,rust,cargo build --color=always --release)
46- build : $(AKG )
46+ build : $(NATIVE_EXE )
47+
48+ # Use `cross` to build for other architectures
49+ target/% /release/authorized-keys-github :
50+ ifeq ($(shell which cross 2>/dev/null) ,)
51+ cargo install cross --git https://github.com/cross-rs/cross
52+ endif
53+ cross build --target $* --release
54+
55+ # `ring` has some build problems, preventing us from building on:
56+ # - powerpc64le-unknown-linux-gnu
57+ # - arm-unknown-linux-gnueabihf
58+ TARGET_TRIPLETS := aarch64-unknown-linux-gnu \
59+ aarch64-unknown-linux-musl \
60+ armv7-unknown-linux-gnueabihf \
61+ i686-unknown-linux-gnu \
62+ i686-unknown-linux-musl \
63+ x86_64-unknown-linux-gnu \
64+ x86_64-unknown-linux-musl
65+ $(foreach triplet,$(TARGET_TRIPLETS ) ,$(eval multibuild : target/$(triplet ) /release/authorized-keys-github))
4766
4867check :
4968 $(call docker_exec,rust,cargo fmt --color=always --all -- --check)
@@ -52,7 +71,7 @@ format:
5271 $(call docker_exec,rust,cargo fmt --color=always --all)
5372
5473.PHONY : test build
55- test : $(AKG )
74+ test : $(NATIVE_EXE )
5675ifeq ($(USE_DOCKER ) ,true)
5776 docker build --build-arg UID=$(UID) --build-arg GID=$(GID) -t authorized-keys-github-test .
5877endif
0 commit comments