1--- ltmain.sh	2006-06-20 04:29:20.000000000 +0900
2+++ ltmain.sh	2007-07-13 20:02:36.000000000 +0900
3@@ -3926,6 +3926,23 @@
4 	  dlname=$soname
5 	fi
6
7+## SANE modification (start)
8+## Moved here from just before the enclosing 'fi' statement so we can
9+## safely rewrite the soname before anything gets run.
10+	# If -module or -export-dynamic was specified, set the dlname.
11+	if test "$module" = yes || test "$export_dynamic" = yes; then
12+	  # On all known operating systems, these are identical.
13+	  dlname="$soname"
14+	fi
15+## The SANE API recommends/requires(?) that backends are made available
16+## with the soname "libsane" instead of "libsane-$backend".  The dlname
17+## should contain the -$backend part for libsane-dll to work.
18+	case $host in
19+	  *)
20+	    soname=`echo $soname | sed -e "s/libsane-[A-Za-z_0-9]*/libsane/g"`
21+	esac
22+## SANE modification (end)
23+
24 	lib="$output_objdir/$realname"
25 	linknames=
26 	for link
27@@ -4189,11 +4206,14 @@
28 	  fi
29 	done
30
31-	# If -module or -export-dynamic was specified, set the dlname.
32-	if test "$module" = yes || test "$export_dynamic" = yes; then
33-	  # On all known operating systems, these are identical.
34-	  dlname="$soname"
35-	fi
36+## SANE modification (start)
37+## Moved before the soname modification needed by SANE.
38+##	# If -module or -export-dynamic was specified, set the dlname.
39+##	if test "$module" = yes || test "$export_dynamic" = yes; then
40+##	  # On all known operating systems, these are identical.
41+##	  dlname="$soname"
42+##	fi
43+## SANE modification (end)
44       fi
45       ;;
46
47