#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

i=$(shell pwd)/debian/tmp
b=$(shell pwd)/debian/build

package=cdparanoia

build: build-debstamp
build-debstamp:
	$(checkdir)
	./configure --prefix=/usr --mandir=/share/man
	make CFLAGS="-O2 -g -Wall"
	touch build-debstamp

clean:
	[ ! -f Makefile ] || make distclean
	$(checkdir)
	-rm -f *-debstamp
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/build debian/files* install core debian/substvars

install: build install-debstamp
install-debstamp:
	@echo "--- Installing"
	dh_testdir
	dh_testroot
	dh_clean
	rm -rf $(b)
	mkdir -p $(i)/usr/lib
	mkdir -p $(i)/usr/bin
	mkdir -p $(i)/usr/include
	mkdir -p $(i)/usr/share/man/man1
	make install prefix=$(i)/usr
	touch install-debstamp

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

binary-arch: checkroot install libcdparanoia0 libcdparanoia0-dev cdparanoia

libcdparanoia0: install
	install -m 644 debian/libcdparanoia0.shlibs debian/tmp/DEBIAN
	dh_installdocs       -p$@ -P$(b)/$@ README
	dh_installchangelogs -p$@ -P$(b)/$@ 
	dh_movefiles         -p$@ -P$(b)/$@
	cd $(b)/$@/usr/lib/; ln -s libcdda_paranoia.so.0.10.2 libcdda_paranoia.so.0
	cd $(b)/$@/usr/lib/; ln -s libcdda_interface.so.0.10.2 libcdda_interface.so.0
	dh_strip             -p$@ -P$(b)/$@ 
	dh_compress          -p$@ -P$(b)/$@ 
	dh_fixperms          -p$@ -P$(b)/$@ 
	dh_installdeb        -p$@ -P$(b)/$@
	dh_shlibdeps         -p$@ -P$(b)/$@
	dh_gencontrol        -p$@ -P$(b)/$@
	dh_md5sums           -p$@ -P$(b)/$@
	dh_builddeb          -p$@ -P$(b)/$@

libcdparanoia0-dev: install
	dh_installdocs       -p$@ -P$(b)/$@
	dh_installchangelogs -p$@ -P$(b)/$@ 
	dh_movefiles         -p$@ -P$(b)/$@
	cd $(b)/$@/usr/lib/; ln -s libcdda_paranoia.so.0.10.2 libcdda_paranoia.so
	cd $(b)/$@/usr/lib/; ln -s libcdda_interface.so.0.10.2 libcdda_interface.so
	dh_strip             -p$@ -P$(b)/$@ 
	dh_compress          -p$@ -P$(b)/$@ 
	dh_fixperms          -p$@ -P$(b)/$@ 
	dh_installdeb        -p$@ -P$(b)/$@
	dh_shlibdeps         -p$@ -P$(b)/$@
	dh_gencontrol        -p$@ -P$(b)/$@
	dh_md5sums           -p$@ -P$(b)/$@
	dh_builddeb          -p$@ -P$(b)/$@

cdparanoia: install
	dh_installdocs       -p$@ -P$(b)/$@
	dh_installchangelogs -p$@ -P$(b)/$@ 
	dh_movefiles         -p$@ -P$(b)/$@
	dh_strip             -p$@ -P$(b)/$@ 
	dh_compress          -p$@ -P$(b)/$@ 
	dh_fixperms          -p$@ -P$(b)/$@ 
	dh_installdeb        -p$@ -P$(b)/$@
	dh_shlibdeps         -p$@ -P$(b)/$@
	dh_gencontrol        -p$@ -P$(b)/$@
	dh_md5sums           -p$@ -P$(b)/$@
	dh_builddeb          -p$@ -P$(b)/$@

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot
