#!/usr/bin/make -f

%:
	dh $@

override_dh_auto_build:
ifdef CARGO_BUILD_TARGET
	cargo build --release --target $(CARGO_BUILD_TARGET)
else
	cargo build --release
endif

override_dh_auto_install:
ifdef CARGO_BUILD_TARGET
	install -D -m755 target/$(CARGO_BUILD_TARGET)/release/rusty-socks debian/rusty-socks/usr/bin/rusty-socks
else
	install -D -m755 target/release/rusty-socks debian/rusty-socks/usr/bin/rusty-socks
endif
	install -D -m644 config/rusty-socks.service debian/rusty-socks/lib/systemd/system/rusty-socks.service
	install -D -m644 config/rusty-socks.sysusers.conf debian/rusty-socks/usr/lib/sysusers.d/rusty-socks.conf
	install -D -m640 config/config.yml.journald.example debian/rusty-socks/etc/rusty-socks/config.yml
	install -D -m660 config/users.yml.example debian/rusty-socks/etc/rusty-socks/users.yml
	install -d debian/rusty-socks/var/log/rusty-socks
	install -d debian/rusty-socks/var/lib/rusty-socks

override_dh_auto_clean:
	cargo clean

override_dh_auto_test:
	# Skip tests for now - can be enabled later
	cargo test

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --exclude=rusty-socks