| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
# resolve DEB_VERSION_UPSTREAM |
| 4 |
include /usr/share/dpkg/pkg-info.mk |
| 5 |
|
| 6 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 7 |
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic |
| 8 |
export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic |
| 9 |
|
| 10 |
# trust upstream optimization level unless explicitly disabled |
| 11 |
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) |
| 12 |
export DEB_CFLAGS_MAINT_STRIP=-O2 |
| 13 |
export DEB_CXXFLAGS_MAINT_STRIP=-O2 |
| 14 |
endif |
| 15 |
|
| 16 |
cmd = nanopub-cli |
| 17 |
|
| 18 |
# generate documentation unless nodoc requested |
| 19 |
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS))) |
| 20 |
MANPAGES = $(cmd).1 |
| 21 |
endif |
| 22 |
|
| 23 |
# generate manual pages from output of clap-based Rust binary |
| 24 |
# arguments: 1:MANFILEPATH 2:COMMANDPATH 3:SUBCOMMAND(S) |
| 25 |
_help2man = \ |
| 26 |
$(eval suffix = $(lastword $(subst ., ,$(1))))\ |
| 27 |
$(eval stem = $(patsubst %.$(suffix),%,$(1)))\ |
| 28 |
help2man --section $(suffix) --no-info \ |
| 29 |
--version-string='$(DEB_VERSION_UPSTREAM)' \ |
| 30 |
--name $(shell $(2) $(3) --help | head --lines=1 | xargs -0 shell-quote --) \ |
| 31 |
--output '$(stem)$(if $(3),-$(subst $() ,-,$(strip $(3)))).$(suffix)' \ |
| 32 |
'$(2)$(if $(3), $(3))' \ |
| 33 |
|| { $(2) $(3) --help; false; } |
| 34 |
|
| 35 |
%: |
| 36 |
dh $@ |
| 37 |
|
| 38 |
execute_after_dh_auto_install-arch: debian/nanopub/usr/bin/$(cmd) $(MANPAGES) |
| 39 |
mkdir --parents debian/build |
| 40 |
$< completions bash > debian/build/bash-completion |
| 41 |
$< completions zsh > debian/build/_$(cmd) |
| 42 |
|
| 43 |
# build manpages |
| 44 |
$(cmd).1: %.1: debian/nanopub/usr/bin/% |
| 45 |
$(call _help2man,$@,$<) |
| 46 |
set -e; $(foreach x,sign publish check,\ |
| 47 |
$(call _help2man,$@,$<,$x);) |