#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs
export FORCE_SOURCE_DATE = 1

CONF_OPTS= -Dtest=true \
		-Dlzma=true \
		-Dbzlib=true \
	  -Dopenssl=false \
	  -Dx=false \
	  -Dfinger=true \
	  -Dgnutls=true \
	  -Dnntp=true \
	  -D88-colors=true \
	  -D256-colors=true \
	  -Dgettext=true \
	  -Dnls=true \
	  -Dleds=true \
	  -Dhtml-highlight=true \
	  -Dfsp=true \
	  -Dsmb=false \
	  -Dperl=true \
	  -Dguile=false \
	  -Dpython=true \
	  -Druby=false \
	  -Dluapkg=lua5.3 \
	  -Dgssapi=true \
	  -Dcgi=true \
	  -Dexmode=true \
	  -Dbittorrent=true \
	  -Ddebug=false \
	  -Dterminfo=true \
	  -Dlibev=true \
	  -Dreproducible=true \
	  -Dbrotli=true \
	  -Dgopher=true \
	  -Dgemini=true \
	  -Dlibsixel=true \
	  -Dlibcss=false \
	  -Dsource-date-epoch=$(SOURCE_DATE_EPOCH)

ifeq (,$(findstring ~,$(DEB_VERSION_UPSTREAM)))
	CONF_OPTS += -Dfastmem=true
endif

ifneq (linux,$(DEB_HOST_ARCH_OS))
	CONF_OPTS += -Dgpm=false
endif

%:
	dh $@ --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure -- $(CONF_OPTS)

override_dh_auto_build:
	dh_auto_build -- man html pdf txt

override_dh_installexamples:
	dh_installexamples --exclude=.gitignore

override_dh_install:
	dh_install -Xmanual.proc
