#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
-include /usr/share/dpkg/buildflags.mk

export CFLAGS += -DGMP_DESC -DLTM_DESC -DUSE_LTM

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
else
	NUMJOBS := 1
endif

override_dh_auto_test:
	$(MAKE) coverage EXTRALIBS="-lgmp -ltommath"

override_dh_auto_build:
	$(MAKE) V=1 docs
	$(MAKE) -f makefile.shared EXTRALIBS="-lgmp -ltommath" -j$(NUMJOBS)

override_dh_auto_install:
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp INSTALL_GROUP=root LIBPATH=/usr/lib/$(DEB_HOST_MULTIARCH) PREFIX=/usr install -f makefile.shared

%:
	dh $@
