#!/usr/bin/make -f

DEB_BUILDDIR = builddir

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/autoreconf.mk

DEB_BUILD_PARALLEL := 1

DDD_USERINFO := $(shell grep '^ -- ' debian/changelog | head -n 1 | \
	sed -e 's/^ -- //' -e 's/  .*$$//')

DEB_CONFIGURE_SCRIPT_ENV += RSH=rsh LPR=lpr XTERM=xterm XFONTSEL=xfontsel \
                            GCORE=gcore ice_cv_find_xp=no \
                            ac_cv_lib_Xp_XpSelectInput=no
DEB_CONFIGURE_EXTRA_FLAGS := --with-readline-libraries \
	--disable-builtin-app-defaults --disable-builtin-manual \
	--disable-builtin-news --disable-builtin-license \
	--with-userinfo="$(DDD_USERINFO)"
CFLAGS += -W -DNDEBUG
CXXFLAGS += -W -DNDEBUG
LDFLAGS += -Wl,--as-needed

# Disable the make check command, which wants to run ddd interactively
DEB_MAKE_CHECK_TARGET :=

DEB_INSTALL_DOCS_ALL :=

ifeq ($(DEB_BUILD_ARCH),powerpc)
DEB_MAKE_ENVVARS := LIBELF="-lelf"
else
DEB_MAKE_ENVVARS := LIBELF=""
endif

common-install-arch::
	rm -f $(DEB_DESTDIR)/usr/share/ddd/COPYING

clean::
	rm -f ddd/ddd.info.txt ddd/ddd.info.txt.gz
	rm -f ddd/ddd.info.txt.gz.C

# The manpage installed contains a reference to a logo .eps file in the
# build directory which isn't even created; remove this reference to
# eliminate man warnings.
binary-post-install/ddd::
	sed -i -e '/^\.PSPIC/d' debian/ddd/usr/share/man/man1/ddd.1
