Patches for sane on FreeBSD

=?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= (mikko@dynas.se)
Sun, 1 Mar 1998 09:27:55 +0100 (CET)

Hi!

Is this the right place to send patches?

After some minor tweaking I got sane 0.71 up and running on both
FreeBSD 2.2.5 and FreeBSD 3.0 (-CURRENT).

I'm using an Agfa Snapscan 310. No idea how other backends may fare,
but I see no reason why they should not work too.

Now for the bad news:

So far xscanimage does not work well (for me) as a gimp-plugin (does
not work with colour images, not even with the pnm backend). Is
anyone successfully using gimp-0.99.18 + gtk-0.99.3 + sane-0.71?

If I get the time, I'll build everything on a Sparc/Solaris and see if
the same thing happens there, to rule out platform weirdness. Then
maybe I'll see what "Purify" has to say... (the number of gimp
warnings printed out is slightly unsettling...)

NOTE: the configure script will leave out gimp support entirely if
"<libgimp/gimp.h>" is not in the regular compiler search path.
Using CPPFLAGS in environment when running configure is one workaround
(e.g. configuring with "CPPFLAGS=-I/usr/X11R6/include ./configure")

Summary:

Platform: FreeBSD 2.2.5, FreeBSD 3.0
SANE version tested: 0.71 (Gtk 0.99.3, Gimp 0.99.18)
Compiler: Gcc
User-level SCSI support: yes
Shared library support: yes
Dynamic loading support: yes
X11 clients: yes (have not tested xcam)
GIMP support: yes, thouhg it seems to need some debugging

Regards,
/Mikko

--------8<------------------------------------------------------------

FreeBSD Patches (diffs for sane-0.71):

If you are the trusting type, simply go to the sane-0.71 distribution
directory and feed the rest of this message to "patch". If not, read
on (it isn't all that much).

Gcc gave up unless I did this (on Solaris too). Hope it was the right
thing to do:

--- sanei/sanei_ab306.c.org Tue Feb 24 22:13:38 1998
+++ sanei/sanei_ab306.c Tue Feb 24 22:41:22 1998
@@ -56,7 +56,7 @@
static __inline__ void
outb (u_char value, u_long port)
{
- __asm__ __volatile__ ("outb %0,%1" : : "a" value, "d" ((u_short) port));
+ __asm__ __volatile__ ("outb %0,%1" : : "a" (value), "d" ((u_short) port));
}

static __inline__ u_char

The "find-scanner" tool needed to be linked against the -lscsi lib,
just like everything else (added $(LIBS) to link target):

--- tools/Makefile.in.org Sat Feb 28 16:23:52 1998
+++ tools/Makefile.in Sat Feb 28 16:25:07 1998
@@ -32,6 +32,7 @@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
DEFS = @DEFS@

LIBTOOL = ../libtool
@@ -63,7 +64,8 @@

find-scanner: find-scanner.o \
../sanei/sanei_scsi.lo ../sanei/sanei_init_debug.lo
- @$(LIBTOOL) $(MLINK) $(LINK) find-scanner.o $(LIBSANEI) $(LIBLIB)
+ @$(LIBTOOL) $(MLINK) $(LINK) find-scanner.o $(LIBSANEI) $(LIBLIB) \
+ $(LIB)

depend:
makedepend $(INCLUDES) *.c

A bit of a moot point -- anyone who has gotten around configuring the
"unknown" scsi devices is likely to already have figured out where the
scanner is. But I guess it doesn't hurt looking, so:

--- tools/find-scanner.c.orig Tue Feb 24 06:23:17 1998
+++ tools/find-scanner.c Sat Feb 28 10:05:15 1998
@@ -347,7 +347,10 @@
"/dev/scg2a", "/dev/scg2b", "/dev/scg2c", "/dev/scg2d",
"/dev/scg2e", "/dev/scg2f", "/dev/scg2g",
"/dev/sg/0", "/dev/sg/1", "/dev/sg/2", "/dev/sg/3",
- "/dev/sg/4", "/dev/sg/5", "/dev/sg/6"
+ "/dev/sg/4", "/dev/sg/5", "/dev/sg/6",
+#elif defined(__FreeBSD__)
+ "/dev/uk0", "/dev/uk1", "/dev/uk2", "/dev/uk3", "/dev/uk4",
+ "/dev/uk5", "/dev/uk6",
#endif
0
};

The first changed line avoids a syntax error when building on Suns.

Libtool kept printing out insults against the system linker, even
though I know for a fact that it is possble to compile, link and
install programs... After these changes it behaved more reasonably
(it insisted on including the full path to the build directory for
"libsane.so" in the binaries otherwise):

--- ltconfig.org Tue Feb 24 22:23:48 1998
+++ ltconfig Tue Feb 24 23:07:18 1998
@@ -705,6 +705,15 @@
hardcode_minus_L=yes
;;

+ freebsd2.2.[56]*) # The .6 is just a guess...
+ runpath_var=LD_RUN_PATH
+ archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=no
+ ;;
+
# FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
# support. Future versions do this automatically, but an explicit c++rt0.o
# doesn't break anything, and helps significantly (at the cost of a little

I suppose this should be sent to the "libtool" maintainer. I'm just
including it for the benefit of any other FreeBSD users.

On FreeBSD 3.0 it works directly out of the box, though.

As I got a free SCSI card with the AGFA scanner, to my surprise I also
found that it worked:

--- doc/sane-scsi.man.org Tue Feb 24 22:33:09 1998
+++ doc/sane-scsi.man Tue Feb 24 22:49:13 1998
@@ -61,6 +61,16 @@
.B aic
driver.
.TP
+Adaptec 1505
+Works on FreeBSD 2.2.5R and 3.0 using the
+.B aic
+driver, provided that Plug-and-Play support is disabled on the card.
+If there are no
+.I uk
+devices, just do a "sh MAKEDEV uk0" in the "/dev" directory. The
+scanner should then be accessible as "/dev/uk0" if it was probed
+during boot.
+.TP
Tekram DC390
Reported to work fine under FreeBSD 2.2.2R with the
.B amd

Now I'll have to find some other use for my old 1542B... Or, maybe
not - the aic driver doesn't do dma, and the 1505 generates tons of
interrupts, which slows down the system noticeably during scans.

And last, xscanimage got floating exceptions on seemingly normal
calculations when using the pnm backend. Recalling that there were
similar problems with TCL, I dug up these lines from tcl-7.5:

--- frontend/xscanimage.c.org Sat Feb 28 16:08:58 1998
+++ frontend/xscanimage.c Sat Feb 28 10:46:01 1998
@@ -59,6 +59,10 @@

#include <libgimp/gimp.h>

+#ifdef __FreeBSD__
+# include <floatingpoint.h>
+#endif
+
static void query (void);
static void run (char *name, int nparams, GParam * param,
int *nreturn_vals, GParam ** return_vals);
@@ -1703,6 +1707,11 @@
++prog_name;
else
prog_name = argv[0];
+
+#ifdef __FreeBSD__
+ fpsetround(FP_RN);
+ fpsetmask(0L);
+#endif

#ifdef HAVE_LIBGIMP_GIMP_H
{

Disclaimer: I have not bothered to look into all implications of this,
but does seem to work.

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com