#!/usr/bin/make -f

# Upstream's Makefile.in only appends -fPIC when the build machine CPU is
# x86_64 (ifeq (@build_cpu@,x86_64)). On every other architecture the objects
# are built without PIC, so linking the shared libraries fails with
# "relocation R_AARCH64_ADR_PREL_PG_HI21 ... recompile with -fPIC"
# (observed on arm64, loong64 and riscv64). Pass -fPIC through CPPFLAGS, which
# configure picks up and puts into the generated Makefile; amd64 keeps
# upstream's behaviour unchanged, as upstream already adds -fPIC there.
ifneq ($(DEB_HOST_ARCH),amd64)
export CPPFLAGS := $(CPPFLAGS) -fPIC
endif

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	find debian/tmp -type f -name \*~ -delete
	find debian/tmp -type f -name \*.in -delete
