#!/usr/bin/make -f

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

DEB_CFLAGS_MAINT_APPEND := -Wall
DEB_CXXFLAGS_MAINT_APPEND := -Wall
export DEB_BUILD_MAINT_OPTIONS := hardening=+all

DEB_CFLAGS_MAINT_APPEND += -g -gdwarf-2 -fno-omit-frame-pointer
DEB_CXXFLAGS_MAINT_APPEND += -g -gdwarf-2 -fno-omit-frame-pointer
ifeq ($(DEB_HOST_ARCH),solaris-i386)
DEB_CFLAGS_MAINT_APPEND += -msave-args
DEB_CXXFLAGS_MAINT_APPEND += -msave-args
endif
export DEB_CFLAGS_MAINT_APPEND DEB_CXXFLAGS_MAINT_APPEND

override_dh_auto_configure:
	dh_auto_configure --verbose -- \
		--localstatedir=/var/cache/locate \
		--enable-d_type-optimisation \
		--libexecdir='$${libdir}/locate'


override_dh_auto_clean:
	[ ! -f Makefile ] || dh_auto_clean --verbose
	rm -fv doc/find.info*

override_dh_auto_install:
	dh_auto_install --verbose
	install -m755 $(CURDIR)/debian/tmp/usr/bin/updatedb \
		$(CURDIR)/debian/locate/usr/bin/updatedb.findutils
	install -m755 $(CURDIR)/debian/tmp/usr/bin/locate \
		$(CURDIR)/debian/locate/usr/bin/locate.findutils
	install -m644 $(CURDIR)/debian/tmp/usr/share/man/man1/locate.1 \
		$(CURDIR)/debian/locate/usr/share/man/man1/locate.findutils.1
	install -m644 $(CURDIR)/debian/tmp/usr/share/man/man1/updatedb.1 \
		$(CURDIR)/debian/locate/usr/share/man/man1/updatedb.findutils.1

%:
	dh $@ --with autotools_dev
