#!/usr/bin/make -f

CFLAGS=		$(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS=	$(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS=	$(shell dpkg-buildflags --get LDFLAGS)

CFLAGS+=	-pipe -Wall -W -Wbad-function-cast \
		-Wcast-align -Wcast-qual -Wchar-subscripts -Winline \
		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
		-Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings
ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS)))
	CFLAGS+=	-Werror
endif
export CFLAGS CPPFLAGS LDFLAGS
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
_STRIP=		no
else
_STRIP=		yes
endif
export _STRIP

DEB_BUILD_HARDENING_PIE:=0
include /usr/share/hardening-includes/hardening.make
ifeq (,$(filter nohardening,$(DEB_BUILD_OPTIONS)))
CFLAGS+=	$(HARDENING_CFLAGS)
LDFLAGS+=	$(HARDENING_LDFLAGS)
endif

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

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp prefix=/usr \
		libdir=/usr/lib/$(DEB_HOST_MULTIARCH) install
	sed -e "s@%%DEB_HOST_MULTIARCH%%@$(DEB_HOST_MULTIARCH)@g" debian/libdebug0.install.in > debian/libdebug0.install
	sed -e "s@%%DEB_HOST_MULTIARCH%%@$(DEB_HOST_MULTIARCH)@g" debian/libdebug0-dev.install.in > debian/libdebug0-dev.install

%:
	dh $@
