#!/usr/bin/make -f
# debian/rules for ocaml-tools

#export DH_VERBOSE=1

# top level dir for documentation
export DOCDIR=debian/ocamlmakefile/usr/share/doc/ocamlmakefile

# shared dir where files are to be installed
export SHDIR=debian/ocamlmakefile/usr/share/ocamlmakefile

build: buildstamp 
buildstamp:
	dh_testdir

clean:
	dh_testdir
	dh_testroot
	dh_clean
	-rm buildstamp

install:
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	for f in calc camlp4 idl gtk threads; do\
	  cp -r $$f $(DOCDIR)/examples;\
	  sed "s|../OCamlMakefile|/usr/share/ocamlmakefile/OCamlMakefile|"\
		< $$f/Makefile\
		> $(DOCDIR)/examples/$$f/Makefile;\
	done
	cp debian/README.examples.idl $(DOCDIR)/examples/calc/README
	cp debian/README.examples.idl $(DOCDIR)/examples/idl/README
	sed "s|/usr/local/lib|/usr/lib|" < OCamlMakefile \
		> $(SHDIR)/OCamlMakefile

binary-arch: build install

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs README.txt
	dh_installchangelogs Changelog
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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