File: rules

package info (click to toggle)
resvg 0.8.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,924 kB
  • sloc: cpp: 2,398; python: 107; makefile: 81; ansic: 76; sh: 15
file content (84 lines) | stat: -rwxr-xr-x 2,800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS=1

include /usr/share/dpkg/default.mk
include /usr/share/rustc/architecture.mk

root-crate=$(DEB_SOURCE)
version=$(DEB_VERSION_UPSTREAM)

CARGO := /usr/share/cargo/bin/cargo
export CARGO_HOME := $(CURDIR)/debian/cargo_home

export DEB_HOST_RUST_TYPE
export DEB_HOST_GNU_TYPE

SONAME=libresvg.so.0

dev-packages = $(filter librust-%-dev,$(shell dh_listpackages))
feature-packages = $(foreach package,$(dev-packages),$(if $(findstring +,$(package)),$(package),))
lib-packages = $(foreach package,$(dev-packages),$(if $(findstring +,$(package)),,$(package)))
crates = $(patsubst librust-%-dev,%,$(lib-packages))
pods = $(wildcard debian/*.pod)
manpages = $(pods:.pod=.1)

install-%: source=$(CURDIR)/$(filter-out $(root-crate),$(crate))
install-%: sources=$(foreach file,$(patsubst $(source)/%,%,$(wildcard $(source)/*)),$(if $(filter $(file),debian target $(filter-out $(root-crate),$(crates))),,$(file)))
install-%: pkgdir=$(CURDIR)/debian/librust-$*-dev
install-%: target=$(pkgdir)/usr/share/cargo/registry/$(crate)-$(version)
install-%: crate=$*

install-%:
	mkdir -p $(target)
	cd $(source); \
	: installing $(crate); \
	cp --parents -at $(target) $(sources); \
	cp $(CURDIR)/debian/rust-$(crate)-$(version).metadata/cargo-checksum.json $(target)/.cargo-checksum.json; \
	touch -d@$(SOURCE_DATE_EPOCH) $(target)/Cargo.toml;
	for pkg in $(filter librust-$*+%,$(feature-packages)); \
	do \
		mkdir -p $(CURDIR)/debian/$$pkg/usr/share/doc; \
		ln -s librust-$*-dev $(CURDIR)/debian/$$pkg/usr/share/doc/$$pkg; \
	done

override_dh_auto_install: $(crates:%=install-%)
	install -D       -t debian/tmp/usr/bin \
		target/*/release/rendersvg target/*/release/usvg
	install -D -m644 -t debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) \
		target/*/release/libresvg.so.*
	install -D -m644 -t debian/tmp/usr/include \
		capi/include/*.h
	ln -sf $(SONAME) debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libresvg.so

%:
	dh $@

override_dh_auto_clean:
	-$(CARGO) clean
	-rm -rf debian/cargo_registry $(CARGO_HOME) debian/*.1

override_dh_auto_configure:
	-[ ! -d debian/cargo_registry ] && \
	mkdir -p $(CARGO_HOME) debian/cargo_registry && \
	for d in /usr/share/cargo/registry/*; \
	do \
		ln -s $$d debian/cargo_registry/; \
	done
	rm -f Cargo.lock
	DEB_CARGO_CRATE=resvg $(CARGO) prepare-debian debian/cargo_registry

%.1: %.pod
	touch -d@$(SOURCE_DATE_EPOCH) $<
	pod2man -r "resvg $(version)" -c "Resvg Documentation" $< > $@

override_dh_auto_build: $(manpages)
	$(CARGO) build --release --all-features --all
	mv target/$(DEB_HOST_RUST_TYPE)/release/libresvg.so target/$(DEB_HOST_RUST_TYPE)/release/$(SONAME)

override_dh_strip:
	dh_strip
	patchelf --set-soname $(SONAME) debian/libresvg*/usr/lib/*/$(SONAME)

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG.md