$NetBSD$

This is rather ugly, but we need to find the local copy of the
smoke library, and the rpath.

--- PerlQt/Makefile.PL.in.orig	2005-07-10 19:59:28.000000000 +0000
+++ PerlQt/Makefile.PL.in
@@ -86,6 +86,8 @@ my $localsmoke = File::Spec->catdir($abs
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 
+my $OTHERLDFLAGS = $rpath." @LDFLAGS@ -L".$localsmoke;
+
 WriteMakefile(
     'NAME'		=> 'Qt',
     'VERSION_FROM'	=> 'Qt.pm', # finds $VERSION
@@ -104,7 +106,7 @@ WriteMakefile(
     'DEFINE'            => $cxxflags,
     'H'                 => ["marshall.h", "perlqt.h", "smokeperl.h"],
     'ABSTRACT'		=> "An OO interface to Trolltech's Qt toolkit",
-    'dynamic_lib'       => {'OTHERLDFLAGS' => $rpath},
+    'dynamic_lib'       => {'OTHERLDFLAGS' => $OTHERLDFLAGS},
     ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
       (
        AUTHOR     => 'Ashley Winters <qaqortog@nwlink.com>') : ()),
@@ -134,6 +136,14 @@ sub MY::dist {
                    $i;
 }
 
+# ../../lang/perl5/module.mk overrides OTHERLDFLAGS
+sub MY::dynamic_lib {
+		  package MY;
+                   my $i = shift->SUPER::dynamic_lib(@_);
+                   $i =~ s#(\$\(OTHERLDFLAGS\))#$1 $OTHERLDFLAGS#s;
+                   $i;
+}
+
 sub MY::install {
 		  package MY;
 		  my $i = shift->SUPER::install(@_);
@@ -152,12 +162,12 @@ sub MY::install {
 		#       last;
 		#    }
 		#  }
-                  $i =~ s/^install\s+::\s+all.*$/$& install_my_perlqt_doc/m;
+                  $i =~ s/^install\s+::\s+.*$/$& install_my_perlqt_doc/m;
 		#  $src = File::Spec->catdir( $src, "en" ) unless $found;
 		  $i .= "\ninstall_my_perlqt_doc:\n".
                         "\t\@echo Installing documentation in ${doc_dir}\n".
                         "\t\@$^X -MExtUtils::Install -MConfig -e \\\n".
-		        "\t\t'install({ \"$src\" => \"${doc_dir}\" },0,0)' \$(DEV_NULL)\n";
+		        "\t\t'install({ \"$src\" => \"\$(DESTDIR)${doc_dir}\" },0,0)' \$(DEV_NULL)\n";
 		  $doc_dir_glob = $doc_dir;
 		  $i;
 }
