#!/usr/bin/make -f

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)))
MANPAGES = debian/build/safe-vdash.1
endif

%:
	dh $@

execute_after_dh_auto_install: $(MANPAGES)

# build manpages
debian/build/safe-vdash.1: debian/build/%.1: debian/safe-vdash/usr/bin/%
	mkdir --parents $(dir $@)
	help2man --section 1 --no-info \
		--name "CLI tool to monitor nodes on the Safe Network" \
		--output $@ $< \
		|| { $1 --help; false; }
