#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_EXCLUDES := e2e internal/dnsdocs
export DH_GOLANG_INSTALL_EXTRA := \
    $(wildcard challenge/dns01/fixtures/*) \
    $(shell find providers/dns/ -name fixtures -type d) \
    README.md \
    docs/content/dns/ \
    docs/data/zz_cli_help.toml \
    internal/dns/docs/templates/ \
    internal/dns/providers/dns_providers.go.tmpl \
    internal/releaser/templates/ \
    providers/dns/rfc2136/rfc2136.toml

# Workaround Debian's packaging setting GO111MODULE=on
export GODEBUG := httpmuxgo121=0

nodns= \
    acmedns \
    alidns \
    aliesa \
    allinkl \
    auroradns \
    azion \
    azure \
    azuredns \
    baiducloud \
    bunny \
    bindman \
    civo \
    cloudflare \
    designate \
    dnsimple \
    dnspod \
    edgedns \
    edgeone \
    exoscale \
    freemyip \
    huaweicloud \
    ibmcloud \
    iij \
    iijdpf \
    infoblox \
    linode \
    liquidweb \
    jdcloud \
    mailinabox \
    metaname \
    namedotcom \
    namesilo \
    nodion \
    ns1 \
    oraclecloud \
    porkbun \
    regfish \
    sakuracloud \
    scaleway \
    selectelv2 \
    tencentcloud \
    transip \
    ucloud \
    ultradns \
    vegadns \
    vinyldns \
    vkcloud \
    volcengine \
    vultr \
    yandexcloud \

%:
	dh $@ --buildsystem=golang --builddirectory=_build

override_dh_auto_configure:
	dh_auto_configure
	set -e -x ;\
        cd _build/src/github.com/go-acme/lego && \
        for P in $(nodns); do \
            perl -ni -E "print unless m{\b$$P\b}" providers/dns/zz_gen_dns_providers.go ;\
            rm -rf providers/dns/$$P ;\
        done

override_dh_auto_build:
	dh_auto_build -- -ldflags "-X main.version=$(DEB_VERSION_UPSTREAM)"
