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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
    CFLAGS += -O0
else
    CFLAGS += -O2
endif

CONFFLAG = "--enable-debug"

CFLAGS = "-Wall -g -Wl,-z,defs"

DEB_CONFIGURE_EXTRA_ARGS :=      \
    CFLAGS=$(CFLAGS) \
    --host=$(DEB_HOST_GNU_TYPE) \
    --build=$(DEB_BUILD_GNU_TYPE) \
    --prefix=/usr \
    --mandir=\$${prefix}/share/man \
    --infodir=\$${prefix}/share/info \
    $(CONFFLAG) \
    $(NULL)

%:
	dh $@ --parallel

override_dh_autoclean:
	[ ! -f Makefile ] || $(MAKE) clean
	rm -f Makefile src/Makefile vmime/Makefile vmime/config.hpp build-stamp libtool config.guess config.log config.sub config.status config.h vmime.pc stamp-h1
	cd src ; rm -f `find . -type l`
	dh_auto_clean

override_dh_auto_configure:
	[ -f ./bootstrap ] && ./bootstrap
	dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_ARGS)

override_dh_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	dh_install

