#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

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

## Suppress some warnings that mostly just lead to noise.
#CFLAGS += -Wno-sequence-point -Wno-pointer-sign -Wno-unused

ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH),hppa)
    CFLAGS += -ffunction-sections
endif

export CFLAGS LDFLAGS

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --with-threads

override_dh_auto_build:
# We need to be strict about requiring prototypes because many functions
# return pointers, and their results may otherwise be misinterpreted on
# 64-bit systems.  However, this flag inconveniently manages to make a
# couple of configure's tests report false negatives, so we should pass it
# only when actually building.
	dh_auto_build -- CFLAGS="$(CFLAGS) -Werror-implicit-function-declaration"

override_dh_auto_install:
# No support for DESTDIR yet :-/
	dh_auto_install -- prefix=$(CURDIR)/debian/goo/usr
	mv debian/goo/usr/bin/goo debian/goo/usr/bin/g2c
	install -m 0755 -o root -g root debian/goo.sh debian/goo/usr/bin/goo

override_dh_installdocs:
	dh_installdocs -XCVS -Xgooomanual

override_dh_installchangelogs:
	dh_installchangelogs txt/changes.txt

override_dh_installman:
	dh_installman debian/goo.1
