librtmp2 0.5.0

librtmp2 — RTMP/RTMPS protocol library
Documentation
#!/usr/bin/make -f

# Launchpad PPA builders have no network access. The PPA workflow vendors all
# crates, stores them in vendor.tar.xz inside the Debian source package, and
# generates .cargo/config.toml pointing cargo at the extracted vendor/ tree.
export CARGO_HOME := $(CURDIR)/debian/cargo_home
export CARGO_NET_OFFLINE := true
export DEB_BUILD_MAINT_OPTIONS := hardening=+all

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
UPSTREAM_VERSION := $(shell dpkg-parsechangelog -SVersion | sed 's/-.*//')
VENDOR_ARCHIVE := vendor.tar.xz

# Per docs/abi-policy.md the soname only bumps on a major (ABI-breaking)
# release, not expected before 1.0.0 - so the soname major tracks "0" for
# the whole 0.x series.
SONAME_MAJOR := 0
SONAME := liblibrtmp2.so.$(SONAME_MAJOR)

export RUSTFLAGS := -C link-arg=-Wl,-soname,$(SONAME)

%:
	dh $@

.PHONY: unpack-vendor
unpack-vendor:
	@if [ ! -d vendor ]; then \
		test -f "$(VENDOR_ARCHIVE)" || { \
			echo >&2 "error: $(VENDOR_ARCHIVE) is required for the offline Debian build"; \
			exit 1; \
		}; \
		mkdir -p vendor; \
		tar -xJf "$(VENDOR_ARCHIVE)" -C vendor; \
	fi

override_dh_auto_build: unpack-vendor
	cargo build --release --offline --all-features --verbose

override_dh_auto_test: unpack-vendor
	cargo test --release --offline --all-features --verbose

override_dh_auto_install:
	install -D -m0644 target/release/liblibrtmp2.so \
		debian/librtmp2/usr/lib/$(DEB_HOST_MULTIARCH)/liblibrtmp2.so.$(UPSTREAM_VERSION)
	ln -s liblibrtmp2.so.$(UPSTREAM_VERSION) \
		debian/librtmp2/usr/lib/$(DEB_HOST_MULTIARCH)/$(SONAME)
	install -D -m0644 target/release/liblibrtmp2.a \
		debian/librtmp2-dev/usr/lib/$(DEB_HOST_MULTIARCH)/liblibrtmp2.a
	ln -s $(SONAME) \
		debian/librtmp2-dev/usr/lib/$(DEB_HOST_MULTIARCH)/liblibrtmp2.so
	sed -e 's/@VERSION@/$(UPSTREAM_VERSION)/' \
		-e 's/@MULTIARCH@/$(DEB_HOST_MULTIARCH)/' \
		debian/librtmp2.pc.in > debian/librtmp2.pc
	install -D -m0644 debian/librtmp2.pc \
		debian/librtmp2-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/librtmp2.pc

override_dh_shlibdeps:
	dh_shlibdeps -l$(CURDIR)/debian/librtmp2/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_dwz:
	# liblibrtmp2.so is a Rust cdylib; dwz on Rust debug info is unreliable.

override_dh_clean:
	dh_clean
	# vendor/ is reconstructed from the archive by unpack-vendor. Removing it
	# here makes repeated source and binary package builds deterministic and
	# prevents generated Cargo state from leaking into the source package.
	rm -rf target debian/cargo_home vendor