#! /usr/bin/make -f

#   Copyright 1994-97   joey@infodrom.north.de (Martin Schulze)
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; version 2 dated June, 1991.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program;  if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139, USA.

tmpdir=debian/tmp
docdir=$(tmpdir)/usr/share/doc/dosfstools
mandir=$(tmpdir)/usr/share/man
oldmandir=$(tmpdir)/usr/man
ARCH = $(shell dpkg --print-gnu-build-architecture)

ifeq ($(ARCH),alpha)
OPTFLAGS="-fomit-frame-pointer -fno-strict-aliasing $(shell getconf LFS_CFLAGS)"
else
OPTFLAGS="-O2 -fomit-frame-pointer $(shell getconf LFS_CFLAGS)"
endif

build:
	make DEBUGFLAGS=-g OPTFLAGS=$(OPTFLAGS)
	touch build

clean:
	make distclean
	rm -f `find -name '*~' -o -name '.#*' -o -name '.new*'`
	rm -rf build
	rm -rf debian/tmp
	rm -f debian/files debian/substvars

binary: binary-indep binary-arch

binary-indep:
# Nothing to be done here

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs
	make install PREFIX=`pwd`/$(tmpdir)
	install -d $(mandir)/man8
	mv $(oldmandir)/man8/* $(mandir)/man8
	rm -rf $(oldmandir)
	dh_installdocs README.Atari TODO
	# dh_installdocs can't install two "README" files (same name)
	install -m 644 mkdosfs/README $(docdir)/README.mkdosfs
	install -m 644 dosfsck/README $(docdir)/README.dosfsck
	dh_installchangelogs CHANGES
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_builddeb

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b' or dsc; false

dist: binary dsc

.PHONY: binary binary-arch binary-indep clean

