diff -Naurd magicrescue-1.1.9/Makefile.in magicrescue-1.1.9.new//Makefile.in
--- magicrescue-1.1.9/Makefile.in	2008-06-27 00:24:06.000000000 +0400
+++ magicrescue-1.1.9.new//Makefile.in	2012-05-13 07:57:59.000000000 +0400
@@ -21,7 +21,7 @@
 	$(CC) -o $@ $(LDFLAGS) $(MAGICRESCUE_OBJS)
 
 dupemap: $(DUPEMAP_OBJS)
-	$(CC) -o $@ $(LDFLAGS) $(DBM_LDFLAGS) $(DUPEMAP_OBJS)
+	$(CC) -o $@ $(LDFLAGS) $(DUPEMAP_OBJS) $(DBM_LDFLAGS)
  
 tools/inputseek: $(INPUTSEEK_OBJS)
 	$(CC) -o $@ $(LDFLAGS) $(INPUTSEEK_OBJS)
diff -Naurd magicrescue-1.1.9/config.d/50dbm magicrescue-1.1.9.new//config.d/50dbm
--- magicrescue-1.1.9/config.d/50dbm	2008-06-27 00:24:05.000000000 +0400
+++ magicrescue-1.1.9.new//config.d/50dbm	2012-05-13 07:56:16.000000000 +0400
@@ -14,18 +14,14 @@
 	    flag="`echo $flag|sed 's/./-l&/'`"
 	    echo "trying to link with flags [$flag]" >&5
 	    
-	    bak_LDFLAGS="$LDFLAGS"
-	    LDFLAGS="$LDFLAGS $flag"
+            LIBS="$flag"
 	    if conftest_link; then
 		# we found it!
-		LDFLAGS="$bak_LDFLAGS"
 		DBM_LDFLAGS="$flag"
 		env_vars="$env_vars DBM_LDFLAGS"
 		echo "#define $dbmdef" >> config.h
 		echo "#define HAVE_NDBM" >> config.h
 		return 0
-	    else
-		LDFLAGS="$bak_LDFLAGS"
 	    fi
 	done
 	
diff -Naurd magicrescue-1.1.9/configure magicrescue-1.1.9.new//configure
--- magicrescue-1.1.9/configure	2008-06-27 00:24:06.000000000 +0400
+++ magicrescue-1.1.9.new//configure	2012-05-13 07:56:16.000000000 +0400
@@ -63,9 +63,9 @@
 }
 
 conftest_link() {
-    echo "$CC -o conftest $LDFLAGS conftest.o" >&5
+    echo "$CC -o conftest $LDFLAGS conftest.o $LIBS" >&5
     echo >&5
-    $CC -o conftest $LDFLAGS conftest.o >&5 2>&5 \
+    $CC -o conftest $LDFLAGS conftest.o $LIBS >&5 2>&5 \
 	&& [ -x conftest ] && ./conftest 2>&5
 }
 
