#!/usr/bin/make -f
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

# There used to be `source' and `diff' targets in this file, and many
# packages also had `changes' and `dist' targets.  These functions
# have been taken over by dpkg-source, dpkg-genchanges and
# dpkg-buildpackage in a package-independent way, and so these targets
# are obsolete.

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

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

CC ?= gcc
CFLAGS += -Wall -DUTF8

install_binary= install -o root -g root -m 755
install_script= install -o root -g root -m 755
install_files=  install -o root -g root -m 644

# The next section may have to be extensively modified

build-indep: 
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

build-arch: build-stamp
build-stamp:
	dh_testdir
	@echo "Building the binaries ..."
	dh_autotools-dev_updateconfig
	CC="$(CC)" CFLAGS="$(CFLAGS)" ./configure --with-slanglib=/usr/lib/"$(DEB_HOST_MULTIARCH)"
	$(MAKE) SYS_INITFILE=/etc/most.conf
	touch $@

clean:
	dh_testdir
	dh_testroot
	@echo "Cleaning up after a build ..."
	-rm -f build-stamp src/config.h
	-rm -f config.log
	[ ! -f Makefile ] || $(MAKE) distclean
	dh_autotools-dev_restoreconfig
	dh_clean


binary-indep:  
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:	build
	dh_testdir 
	dh_testroot 
	dh_clean
	@echo "Making the binary package: $(p)-$(version)-$(debian).deb ..."
	dh_installdirs 
	dh_installchangelogs changes.txt
	dh_installdocs debian/copyright README lesskeys.rc most-fun.txt most.rc
	dh_installmime
	dh_installman most.1
	$(install_binary) src/objs/most debian/most/usr/bin/most
	chrpath --delete debian/most/usr/bin/most
	dh_strip
	dh_compress
	dh_shlibdeps
	dh_installdeb
	dh_fixperms
	dh_md5sums
	dh_gencontrol
	dh_builddeb 

# Below here is fairly generic really.

binary: binary-indep binary-arch
build: build-indep build-arch 

.PHONY: binary binary-indep binary-arch build-indep build-arch dist update clean checkroot
