11NAME := $(shell grep 'name =' Cargo.toml | head -n 1 | cut -d'"' -f2)
22VERSION := $(shell grep '^version =' Cargo.toml | cut -d'"' -f2)
3- ARCH := $(shell uname -m)
3+ TARGET_ARCH ?= $(shell rustc -vV | sed -n 's/host: //p')
4+ ARCH := $(shell echo "$(TARGET_ARCH ) " | cut -d'-' -f1)
45ALL_RS := $(shell find src -name '* .rs')
56PREFIX ?= /usr
67CACHE_DIR := .cache
@@ -28,7 +29,7 @@ help: ## Display this help.
2829
2930.PHONY : install
3031install : build # # Install PowerStation to the given prefix (default: PREFIX=/usr)
31- install -D -m 755 target/release/powerstation \
32+ install -D -m 755 target/$( TARGET_ARCH ) / release/powerstation \
3233 $(PREFIX ) /bin/powerstation
3334 install -D -m 644 rootfs/usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf \
3435 $(PREFIX ) /share/dbus-1/system.d/org.shadowblip.PowerStation.conf
@@ -47,21 +48,21 @@ uninstall: ## Uninstall PowerStation
4748# #@ Development
4849
4950.PHONY : debug
50- debug : target/debug/powerstation # # Build debug build
51- target/debug/powerstation : $(ALL_RS ) Cargo.lock
52- cargo build
51+ debug : target/$( TARGET_ARCH ) / debug/powerstation # # Build debug build
52+ target/$( TARGET_ARCH ) / debug/powerstation : $(ALL_RS ) Cargo.lock
53+ cargo build --target $( TARGET_ARCH )
5354
5455.PHONY : build
55- build : target/release/powerstation # # Build release build
56- target/release/powerstation : $(ALL_RS ) Cargo.lock
57- cargo build --release
56+ build : target/$( TARGET_ARCH ) / release/powerstation # # Build release build
57+ target/$( TARGET_ARCH ) / release/powerstation : $(ALL_RS ) Cargo.lock
58+ cargo build --release --target $( TARGET_ARCH )
5859
5960.PHONY : all
6061all : build debug # # Build release and debug builds
6162
6263.PHONY : run
6364run : setup debug # # Build and run
64- sudo ./target/debug/powerstation
65+ sudo ./target/$( TARGET_ARCH ) / debug/powerstation
6566
6667.PHONY : test
6768test : debug # # Build and run all tests
@@ -87,25 +88,25 @@ setup: /usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf ## Install db
8788# #@ Distribution
8889
8990.PHONY : dist
90- dist : dist/$(NAME ) .tar.gz dist/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm # # Create all redistributable versions of the project
91+ dist : dist/$(NAME ) - $( ARCH ) .tar.gz dist/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm # # Create all redistributable versions of the project
9192
9293.PHONY : dist-archive
93- dist-archive : dist/powerstation.tar.gz # # Build a redistributable archive of the project
94- dist/powerstation.tar.gz : build
94+ dist-archive : dist/powerstation- $( ARCH ) .tar.gz # # Build a redistributable archive of the project
95+ dist/powerstation- $( ARCH ) .tar.gz : build
9596 rm -rf $(CACHE_DIR ) /powerstation
9697 mkdir -p $(CACHE_DIR ) /powerstation
9798 $(MAKE ) install PREFIX=$(CACHE_DIR ) /powerstation/usr NO_RELOAD=true
9899 mkdir -p dist
99100 tar cvfz $@ -C $(CACHE_DIR ) powerstation
100- cd dist && sha256sum powerstation.tar.gz > powerstation.tar.gz.sha256.txt
101+ cd dist && sha256sum powerstation- $( ARCH ) .tar.gz > powerstation- $( ARCH ) .tar.gz.sha256.txt
101102
102103.PHONY : dist-rpm
103104dist-rpm : dist/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm # # Build a redistributable RPM package
104- dist/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm : target/release/$(NAME )
105+ dist/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm : target/$( TARGET_ARCH ) / release/$(NAME )
105106 mkdir -p dist
106107 cargo install cargo-generate-rpm
107- cargo generate-rpm
108- cp ./target/generate-rpm/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm dist
108+ cargo generate-rpm --target $( TARGET_ARCH )
109+ cp ./target/$( TARGET_ARCH ) / generate-rpm/$(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm dist
109110 cd dist && sha256sum $(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm > $(NAME ) -$(VERSION ) -1.$(ARCH ) .rpm.sha256.txt
110111
111112INTROSPECT_CARD ?= Card2
@@ -166,6 +167,8 @@ in-docker: docker-builder
166167 -v $(PWD ) :/src \
167168 --workdir /src \
168169 -e HOME=/home/build \
170+ -e TARGET_ARCH=$(TARGET_ARCH ) \
171+ -e PKG_CONFIG_SYSROOT_DIR=" /usr/$( ARCH) -linux-gnu" \
169172 --user $(shell id -u) :$(shell id -g) \
170173 $(IMAGE_NAME ) :$(IMAGE_TAG ) \
171174 make $(TARGET )
0 commit comments