#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

pwmnd                      := wmnd
pwmnd_snmp                 := wmnd-snmp

define dh_auto_command
        $(subst override_,,$1) --verbose --buildsystem=autoconf --parallel \
                               --package="$2"                              \
                               --builddirectory="BUILD-$2"                 \
                               --tmpdir="debian/$2"                        \
                               -O --destdir="debian/$2"  $3
endef

export CFLAGS             := $(shell dpkg-buildflags --get CFLAGS) -Wall
export LDFLAGS            := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed

CONFFLAGS                 :=  --enable-trend
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
CONFFLAGS                 += --enable-debug
endif


%:
	 dh "$@" --with autotools_dev

override_dh_auto_configure:
	$(call dh_auto_command,$@,$(pwmnd),                                        \
	                 -- $(CONFFLAGS)                                           \
	                 --docdir="\$${prefix}/share/doc/$(pwmnd)"                 \
	                 --enable-drivers="linux_proc solaris_fpppd"               )
	
	$(call dh_auto_command,$@,$(pwmnd_snmp),                                   \
	                 -- $(CONFFLAGS)                                           \
	                 --docdir="\$${prefix}/share/doc/$(pwmnd_snmp)"            \
	                 --enable-drivers="linux_proc solaris_fpppd generic_snmp"  \
	                 LIBS="$(LIBS) -lsnmp"                                     )


override_dh_auto_build override_dh_auto_clean override_dh_auto_install:
	$(call dh_auto_command,$@,$(pwmnd))

	$(call dh_auto_command,$@,$(pwmnd_snmp))

.PHONY: override_dh_auto_configure override_dh_auto_build  \
        override_dh_auto_clean override_dh_auto_install
