#!/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.

package=abcmidi

build:
	$(checkdir)
	make CC='gcc $$(CFLAGS)' CFLAGS="-O2 -g -Wall"
	touch build

clean:
	$(checkdir)
	-rm -f build
	-make clean
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars

install:
	for i in abc2midi midi2abc abc2abc mftext; \
	do install -m 755 -s $$i $(DESTDIR)/usr/bin; \
	done
	for i in *.1; \
	do install -m 644 $$i $(DESTDIR)/usr/man/man1; \
	done
	mkdir -p $(DESTDIR)/usr/doc/abcmidi
	for i in *.txt; \
	do install -m 644 $$i $(DESTDIR)/usr/doc/abcmidi; \
	done

binary-indep:	checkroot build
	$(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 build install
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp
	cd debian/tmp && install -d `cat ../dirs`
	debian/rules install DESTDIR=`pwd`/debian/tmp
# Must have debmake installed for this to work. Otherwise please copy
# /usr/bin/debstd into the debian directory and change debstd to debian/debstd
	debstd README 
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

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

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