<<<<<<<
#!/usr/bin/make -f

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

export DH_COMPAT=4
#export DEBIAN=1
PACKAGE=binkd1
MAJOR=$(shell sed -n "/\#define MAJOR/s/.*\([0-9]\+\).*$$/\1/p" Config.h)
MINOR=$(shell sed -n "/\#define MINOR/s/.*\([0-9]\+\).*$$/\1/p" Config.h)
BUILD=$(shell sed -n "/\#define BUILD/s/.*\([0-9]\+\).*$$/\1/p" Config.h)
SUFFIX=$(shell sed -n -e "s/-/+/" -e "/^ *\#define SUFFIX/s/.*\"\([+a-z]\+\)\".*$$/\1/p" Config.h)
PATCHLEVEL=$(shell sed -n "/\#define PATCHLEVEL/s/.*\([0-9]\+\).*$$/\1/p" Config.h)
ifeq ($(SUFFIX),-pre)
  VERSION=$(MAJOR).$(MINOR).$(BUILD)$(SUFFIX)$(PATCHLEVEL)
else
  VERSION=$(MAJOR).$(MINOR).$(BUILD)
endif
PREFIX=$(CURDIR)/debian/binkd1
CONFIGURE_OPTIONS += --with-zlib --with-https --with-ntlm --with-bwlim --with-perl --sysconfdir=$(PREFIX)/etc/ftn --prefix=$(PREFIX) --mandir=$(PREFIX)/usr/share/man

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CONFIGURE_OPTIONS += --with-debug
endif
ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

default:
	@echo "What's do?"

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	-cp mkfls/unix/{configure*,install-sh,Makefile.*,mkinstalldirs} ./
	chmod +x mkinstalldirs
	./configure $(CONFIGURE_OPTIONS)
	touch $@

build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)
	cd doc ; $(MAKE) text ; cd ..

	touch $@

clean:
	dh_testdir
	dh_testroot
	-rm -f  build-stamp configure-stamp install-sh configure Makefile.in \
		Makefile Makefile.dep configure.in config.log binkd build

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) install
	install -d $(PREFIX)/usr/share/doc/$(PACKAGE)
	install \!README*  HISTORY *.[Tt][Xx][Tt]* doc/*.{txt,html,htm} $(PREFIX)/usr/share/doc/$(PACKAGE)/

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
	dh_installman
#	dh_installinfo
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol -- -v$(VERSION)
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
=======
#!/usr/bin/make -f
SHELL+= -e

DPKG_EXPORT_BUILDFLAGS = 1
DEB_BUILD_MAINT_OPTIONS=hardening=+pie,+bindnow
-include /usr/share/dpkg/buildflags.mk

D := $(CURDIR)/debian/binkd

build:
	dh_testdir
	cp mkfls/unix/install-sh mkfls/unix/configure mkfls/unix/Makefile.* .
	chmod u+x configure
	dh_auto_configure -- --with-debug --with-https --with-ntlm --with-bwlim
	$(MAKE)
	touch $@

clean:
	dh_testdir
	[ ! -e Makefile ] || $(MAKE) clean
	-rm -f install-sh configure Makefile.in \
		Makefile Makefile.dep configure.in config.log binkd build
	dh_clean

binary-arch: build
	dh_testdir
	dh_testroot
	dh_prep

	dh_installdirs
	dh_installdocs todo.lst
	dh_installexamples
	dh_installchangelogs \!README.FIX
	dh_installman *.8

	cp binkd.cfg binkd.inc $D/etc/binkd/
	dh_systemd_enable
	dh_installinit --restart-after-upgrade
	dh_systemd_start --restart-after-upgrade

	dh_installlogrotate
	install binkd $D/usr/sbin/
	install --mode 755 debian/binkdlogstat $D/usr/sbin/

	dh_strip
	dh_compress
	dh_fixperms
	chown -R 64000:adm $D/var/log/binkd/
	chmod 750 $D/var/log/binkd/
	chown -R 64000:64000 $D/var/spool/ftn/ $D/etc/binkd/binkd.inc
	chmod 600 $D/etc/binkd/binkd.inc
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-indep:

binary:	binary-arch

build-arch: build
build-indep: build

get-orig-source:
	cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \
	uscan --rename --force-download --watchfile debian/watch --destdir $(CURDIR)

.PHONY: binary binary-arch binary-indep build-arch build-indep clean get-orig-source
>>>>>>>
