File: rules

package info (click to toggle)
scaphandre 1.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,640 kB
  • sloc: sh: 53; makefile: 49
file content (72 lines) | stat: -rwxr-xr-x 1,998 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/make -f

# resolve DEB_VERSION_UPSTREAM
include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_CXXFLAGS_MAINT_APPEND  = -Wall -pedantic

# trust upstream optimization level unless explicitly disabled
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
export DEB_CFLAGS_MAINT_STRIP=-O2
export DEB_CXXFLAGS_MAINT_STRIP=-O2
endif

# generate documentation unless nodoc requested
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
DOCS = README.html README.txt
CHANGELOGS = CHANGELOG.html CHANGELOG.txt
MANPAGES = debian/scaphandre.1
endif

# generate manual pages from output of clap-based Rust binary
#  arguments: 1:MANFILEPATH 2:COMMANDPATH 3:SUBCOMMAND(S)
_help2man = \
 $(eval suffix = $(lastword $(subst ., ,$(1))))\
 $(eval stem = $(patsubst %.$(suffix),%,$(1)))\
 help2man --section $(suffix) --no-info \
 --version-string='$(DEB_VERSION_UPSTREAM)' \
 --name $(shell $(2) $(3) --help | head --lines=1 | xargs -0 shell-quote --) \
 --output '$(stem)$(if $(3),-$(subst $() ,-,$(strip $(3)))).$(suffix)' \
 '$(2)$(if $(3), $(3))' \
 || { $(2) $(3) --help; false; }

# Fails on a virtual machine
TEST_VM = \
 exporter_qemu \
 read_core_stats \
 read_socket_stats \
 get_topology_returns_topology_type \
 read_topology_stats

%:
	dh $@ --with-linktree

override_dh_auto_test:
	dh_auto_test --buildsystem rust -- \
	 --no-fail-fast -- $(addprefix --skip ,$(TEST_VM))

%.html: %.md
	cmark-gfm $< > $@

%.txt: %.md
	cmark-gfm --to plaintext $< > $@

execute_after_dh_auto_build: $(DOCS) $(CHANGELOGS)
	mdbook build --dest-dir docs
	rm -rf docs/FontAwesome

execute_after_dh_auto_install: $(MANPAGES)

override_dh_installdocs:
	dh_installdocs --all -- $(DOCS)

override_dh_installchangelogs:
	dh_installchangelogs -- $(CHANGELOGS)

# build manpages
debian/scaphandre.1: debian/%.1: debian/scaphandre/usr/bin/%
	$(call _help2man,$@,$<)
	set -e; $(foreach x,stdout json prometheus,\
	 $(call _help2man,$@,$<,$x);)