#!/usr/bin/make -f

export CARGO_HOME := $(CURDIR)/debian/cargo-home

%:
	dh $@

override_dh_auto_build:
	RUSTFLAGS="-C link-arg=-Wl,-soname,libtlottie.so.0" \
	cargo rustc \
		--release \
		--features c-api \
		--lib \
		--crate-type cdylib \
		--crate-type staticlib

override_dh_auto_install:
	# Runtime package
	install -d \
		debian/libtlottie0/usr/lib/$(DEB_HOST_MULTIARCH)

	install -m 755 \
		target/release/libtlottie.so \
		debian/libtlottie0/usr/lib/$(DEB_HOST_MULTIARCH)/libtlottie.so.0

	# Development package directories
	install -d \
		debian/libtlottie-dev/usr/lib/$(DEB_HOST_MULTIARCH)

	install -d \
		debian/libtlottie-dev/usr/include/tlottie

	# Development linker symlink
	ln -s libtlottie.so.0 \
		debian/libtlottie-dev/usr/lib/$(DEB_HOST_MULTIARCH)/libtlottie.so

	# Static library
	install -m 644 \
		target/release/libtlottie.a \
		debian/libtlottie-dev/usr/lib/$(DEB_HOST_MULTIARCH)/

	# C API headers
	install -m 644 \
		include/tlottie.h \
		debian/libtlottie-dev/usr/include/tlottie/
