--- a/Makefile.PL
+++ b/Makefile.PL
@@ -43,6 +43,7 @@
 @libdirs =  (
     $ENV{'HDF5_PATH'}."/lib",
     $ENV{'HDF5_PATH'}."/lib64",
+    "$ENV{HDF5_LIBDIR}",
     '/usr/local/hdf5/lib',
     '/usr/local/lib',
     '/opt/local/lib',
@@ -51,26 +52,24 @@
     '/usr/lib64'
     );
 push(@libdirs,split(":",$ENV{'LD_LIBRARY_PATH'}));
-foreach my $libdir ( @libdirs ) {
-    
-  if (-e "$libdir/libhdf5.so") {
-    $hdf5_lib_path = $libdir;
-    print "Found libhdf5.so at $libdir/libhdf5.so\n";
-    last;
-  }
-
-  if (-e "$libdir/libhdf5.dll.a") {
-    $hdf5_lib_path = $libdir;
-    print "Found libhdf5.so at $libdir/libhdf5.so\n";
-    last;
+@hdf5_lib=(
+    "libhdf5.so",
+    "libhdf5_serial.so",
+    "libhdf5.dll.a",
+    "libhdf5.a",
+);
+
+dirloop: foreach my $libdir ( @libdirs ) {
+  foreach my $hdf5_lib_test (@hdf5_lib) {
+      print STDERR "testing $libdir/$hdf5_lib_test\n";
+      if (-e "$libdir/$hdf5_lib_test") {
+        print "Found $hdf5_lib_test at $libdir/$hdf5_lib_test\n";
+        $hdf5_lib=$hdf5_lib_test;
+        $hdf5_lib=~s/\..*//;
+        $hdf5_lib_path = $libdir;
+        last dirloop;
+      }
   }
-
-  if (-e "$libdir/libhdf5.a") {
-    $hdf5_lib_path = $libdir;
-    print "Found libhdf5.a at $libdir/libhdf5.a\n";
-    last;
-  }
-
 }
 
 # We don't do a die here, because we would get bogus emails from CPAN testers
@@ -82,6 +81,7 @@
 
 @incdirs =  (
     $ENV{'HDF5_PATH'}."/include",
+    "$ENV{HDF5_INCDIR}",
     '/usr/local/hdf5/include',
     '/usr/local/include',
     '/opt/local/include',
@@ -133,7 +133,7 @@
   print "Defining _HDF5USEDLL_ for win32\n";
 }
             
-$LIBS = "-L$hdf5_lib_path -lhdf5 ";
+$LIBS = "-L$hdf5_lib_path -lhdf5_serial ";
 $LIBS .= " -lz" if($zLib);
 $LIBS .= " -ljpeg" if($jpegLib);
 $LIBS .= " -lm";
