#!/usr/bin/make -f

# output every command that modifies files on the build system.
export DH_VERBOSE = 1

export VENDORED ?= 1
CLEAN ?= 1

ifeq ($(VENDORED),1)
export CARGO_HOME = $(CURDIR)/target/cargo
endif

# Link against the system OpenSSL (libssl-dev) instead of building and
# embedding the copy shipped by the openssl crate "vendored" feature.
export OPENSSL_NO_VENDOR = 1

%:
	dh $@

override_dh_auto_build:
ifeq ($(VENDORED),1)
	make vendor
endif
	dh_auto_build

override_dh_auto_clean:
ifeq ($(CLEAN),1)
	make clean
endif

override_dh_auto_install:
	dh_auto_install -- prefix=/usr
# Regenerate the help2man manpage with a meaningful NAME section (the
# default one is useless for whatis/apropos); dh_compress compresses it.
	rm debian/feroxbuster/usr/share/man/man1/feroxbuster.1.gz
	help2man --no-info \
		--name="fast, simple, recursive content discovery tool" \
		--output=debian/feroxbuster/usr/share/man/man1/feroxbuster.1 \
		target/release/feroxbuster
# Completions shipped by packages other than fish belong in
# vendor_completions.d.
	mv debian/feroxbuster/usr/share/fish/completions \
		debian/feroxbuster/usr/share/fish/vendor_completions.d
