#!/usr/bin/make -f

# The following targets are required and must be implemented by
# "debian/rules": "clean", "binary", "binary-arch", "binary-indep",
# "build", "build-arch" and "build-indep". These are the targets called
# by "dpkg-buildpackage".

binary-indep: build

binary-arch: build
	make DESTDIR=debian/tmp/ install
	install -d debian/tmp/DEBIAN
	dpkg-shlibdeps debian/tmp/usr/games/2048
	strip --remove-section=.comment debian/tmp/usr/games/2048
	install -d debian/tmp/usr/share/doc/2048
	cp -f debian/changelog debian/tmp/usr/share/doc/2048/changelog.Debian
	cp -f LICENSE debian/tmp/usr/share/doc/2048/copyright
	gzip debian/tmp/usr/share/doc/2048/changelog.Debian -9
	install -d debian/tmp/usr/share/man/man6/
	cp -f debian/2048.6 debian/tmp/usr/share/man/man6/
	gzip debian/tmp/usr/share/man/man6/2048.6 -9
	#create md5sums control-file
	find debian/tmp/usr/ -not -type d -exec md5sum {} \;>debian/md5sums.t
	sed s*debian/tmp/**g debian/md5sums.t>debian/md5sums
	rm -f debian/md5sums.t
	cp -f debian/md5sums debian/tmp/DEBIAN
	dpkg-gencontrol
	dpkg-deb --build debian/tmp
	mv debian/tmp.deb ../2048_0.0-1_amd64.deb

binary: binary-indep binary-arch


# The "build" target should perform all the configuration and
# compilation of the package.
build-arch:
	make

build-indep:

build: build-indep build-arch

clean:
	make clean
	rm -rf debian/tmp
	rm -f debian/files
	rm -f debian/substvars
	rm -f md5sums
