#!/usr/bin/make -f
# -*- makefile -*-
export DH_VERBOSE=1

# 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)

build:
	touch build

clean:
	dh_testdir
	dh_testroot
	rm -rf build
	rm -rf debian/perf
	$(MAKE) clean
	dh_clean

binary-arch: build
	rm -rf debian/tmp
	rm -rf debian/perf
	# Make perf
	$(MAKE)
	$(MAKE) man
	# Install perf
	install -d debian/perf/usr/bin
	install -p -m 777 perf debian/perf/usr/bin
	install -d debian/perf/usr/lib
	install -p -m 777 python/perf.so debian/perf/usr/lib
	install -p -m 777 perf-archive debian/perf/usr/bin
	install -d debian/perf/usr/share/doc/perf
	install -d debian/perf/usr/share/man/man1/
	install -p -m 644 Documentation/*.1 debian/perf/usr/share/man/man1/
	cat debian/copyright | sed -e "s&#OSNAME#&$(OSNAME)&g" \
		> debian/perf/usr/share/doc/perf/copyright
	chmod 644 debian/perf/usr/share/doc/perf/copyright
	install -p -m 644 debian/changelog debian/perf/usr/share/doc/perf/
	gzip -9 debian/perf/usr/share/doc/perf/changelog
	install -d debian/perf/DEBIAN
	cd debian/perf && \
		md5sum `find usr -type f` > DEBIAN/md5sums
	dh_strip -pperf
	dh_compress -pperf
	dh_fixperms -pperf
	dh_shlibdeps -pperf
	dh_gencontrol -pperf
	dh_builddeb -pperf

binary: binary-arch
.PHONY: clean binary-arch binary
