-#!/bin/sh -e
+#!/usr/bin/perl -w
#
-# Build the .deb package, assuming all the files are set up in debian/tmp.
+# Build the .deb package, assuming all the files are set up.
-PATH=debian:$PATH:/usr/lib/debhelper
-source dh_lib
-doit "dpkg --build debian/tmp .."
+use Debian::Debhelper::Dh_Lib;
+init();
+
+# Set the default destination directory.
+if (! defined $dh{DESTDIR}) {
+ $dh{DESTDIR}='..';
+}
+
+if (! defined $dh{FILENAME}) {
+ $dh{FILENAME}='';
+}
+
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+ $TMP=tmpdir($PACKAGE);
+ doit("dpkg","--build",$TMP,"$dh{DESTDIR}/$dh{FILENAME}",@{$dh{U_PARAMS}});
+}