Building SANE for OS/2


Here some information how I managed to build SANE 1.0.14 for OS/2. Perhaps there are other configurations that work. Setting up a build environement for unix-ports is not so easy, but things are improving. If you need help, there's also a unix-os2-mailing list where you might get support.

First of all you need the sources of SANE which you can get either (if you have installed CVS) for example with the following getsane.cmd

REM cvs -d:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/sane login
REM Just hit enter
cvs -z3 -d:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/sane co sane-backends
cvs -z3 -d:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/sane co sane-frontends

When executing this command script for the first time you have to remove the first REM.
If you don't want to install CVS, since May 2003, the Sane 1.0.14 sources are also available as sane-backends-1.0.14.tar.gz and sane-frontends-1.0.11.tar.gz from ftp.mostang.com.
If you want to compile CVS-version instead of the tar-balls you have to replace
sane-backends-1.0.14/
with
sane-backends/
and
sane-frontends-1.0.11/
with
sane-frontends/
in description for the necessary small patches described later.

You need all those fine tools for porting 'unix-like' applications. Here is a list, that should work, maybe there are newer versions of some tools available on unixos2, that also work.
toolsavailable for example at
emx gcc compilerwww.os2site.com / Hobbes
gnudiff, gnufutilsHobbes
preferable this version of sh.exehttp://math.berkeley.edu/~ilya/software/os2/pdksh-5.2.14-bin-2.zip
sedthe hompage of SAWATAISHI JUN
gettext 0.10.35 or laterhttp://www.os2site.com/sw/dev/gettext/index.html
latex (for parts of the documentation)ftp://ftp.dante.de/pub/tex/systems/os2/emtex
libsavailable for example at
sockethttp://www.os2site.com/leo/gnu/emx+gcc/bsddev.zip
sysloghttp://www.os2site.com/leo/tcpip/systools/syslog3.zip
jpeghttp://www.os2site.com/leo/devtools/libraries/jpeg6b.zip
pthreadsftp://ftp.netlabs.org/pub/pthreads/pthread-bjs-bin.zip
If you want to compile xcam and xscanimage you need additionally
Xprog.ziphttp://www.os2site.com/leo/x11/xfree86/Xprog.zip
some gnome/gimp libsChristoph's Pages
tell me what's missing

The version of sed that works for me (and others) is sed version 3.02.80  which can be found as RPM-package on the hompage of SAWATAISHI JUN, the author of os2unix. You need RPM for OS/2 to install it, which is available on the same site. This version of sed  needs intl_d.dll  which is part of tutil2_0.zip available from the www.os2site.com
It also has been reported, that printf  (the version I use reports: printf - GNU sh-utils 1.12 ) which is called from libtool and generates the *.def files does not work with all versions of sh.exe . The sh.exe  which works for me is part of pdksh-5.2.14.

(It's also possible to compile with gcc 3.2.1. The result works for me (Epson, Mustek), but doesn't work with Scanmaker 630)

Prerequisites

  1. Make shure that /emx/bin/install.exe is executed if you type install on a command-line
    (Rename OS2/INSTALL/install.exe or modify the PATH - Variable)
  2. Copy emx/bin/cp.exe to emx/bin/ln.exe
  3. Remove the line containing:
    #warning <sys/socket.h> requires <sys/types.h>
    from .../emx/include/sys/socket.h
  4. You need CONFIG_SITE defined. Example:
    SET CONFIG_SITE=g:/usr/share/config.site
    either in config.sys or in the build script you use. And it should have reasonable entries at least for CFLAGS and LDFLAGS
    The values I used:
    • CFLAGS='-D__EMX__ -DOS2 -Zmtd -D__ST_MT_ERRNO__ -O2'
    • LDFLAGS='-Zexe -Zmtd -D__ST_MT_ERRNO__ -Zsysv-signals'
    You will find a reasonable template for config.site in the os2unix-tool or in a recent autoconf-package from HOBBES
  5. (Optional) If you want to use the generated localisation-files (usr\share\locale\foo\LC_MESSAGES\sane-backends.mo) with X-frontends you have to convert them from UTF-8 to iso-8859-1 for example, because the available gtk (gimp-tool-kit) version 1.2 for OS/2 does not support UTF-8

libsane.dll, scanimage.exe, sane-find-scanner.exe, gamma4scanimage.exe and umax_pp.exe

  1. Optionally you can remove support for scanners you don't need to make compiling faster and libsane.dll smaller.
    For this purpose you have to modify sane-backends-1.0.14/backend/Makefile.in and remove the scanners you don't need from the list which starts with:
    PRELOADABLE_BACKENDS =
    If you want to use saned or use a scanner over a network, don't remove net
  2. In ...\sane-backends directory:
    sh configure --prefix=/usr --enable-translations --disable-parport-directio
    ( '--enable-parport-directio' is only needed to support umax-parallelport-scanners)
  3. in
    sane-backends-1.0.14\include\sane/config.h
    change
    /* #undef HAVE_DLOPEN */
    to
    #define HAVE_DLOPEN 1
  4. Replace sane-backends-1.0.14/libtool  with this modified version of libtool .
  5. make
  6. make install
  7. Copy sane-backends\frontend\.libs\*.exe to \usr\bin
  8. Copy sane-backends\tools\*.exe to \usr\bin

I have scripts which do all steps from 2 to 8. You can get them by request.

The version build this way works perfect here with my EPSON GT-9500 and my Mustek 600S/600 II CD Scanner on OS/2 (eCS 1.0.1) with beta9 of aspirout.sys from Paul Ratcliffe.

Scanners that might work:
abaton agfafocus apple artec as6e avision bh canon coolscan coolscan2 dc25 dmc epson fujitsu gt68xx hp leo matsushita microtek microtek2 mustek mustek_pp nec pie plustek plustek_pp ricoh s9036 sceptre sharp sp15c st400 tamarack test teco1 teco2 teco3 umax ma1509 ibm hp5400 snapscan dc210 dc240 qcam

You can also enter your scanner model into the SANE-Search-Engine and see whether your scanner is supported by the current version of SANE.

In general USB Scanners won't work on OS/2 because until now nobody has ported libusb to OS/2. I can't do this because I don't have time/USB-Scanner/USB-knowledge to do this job. Volonteers? Have a look at netlabs for a start.
But there is an exeption for Epson-USB-Scanners.
Some are supported by a SANE-binary compiled by Maeda Haruyuki! The binaries are part of the latest TAME Package (0.98 or later).

Parallel-Port-Scanners: I have one positive feedback for a Medion (Mustek)-Parallelport-Scanner, so in theory some might work, but support for umax-pp scanners is not compiled in into this binary-package because it causes a nasty delay of some seconds for searching such a scanner for all other users and previous binaries with included umax-pp support never worked anyway.

Additional Information and some SANE-betas (especially useful for snapscan-scanners) can be found on the Homepage of Paul Floyd

For questions and suggestions there is the OS/2 SANE Mailing-List


xscanimage.exe, xcam.exe and scanadf.exe

It is also possible to build xscanimage.exe, xcam.exe  and scanadf.exe  if you have installed the necessary libs.
Prerequisites:
  1. Include
    SET GTK_CONFIG=G:/XFree86/bin/gtk12-config
    in
    config.sys
  2. Add -lpthreads to the 'echo line' near the end of /XFree86/bin/gtk12-config
  3. I had to delete the struct timespec definition from pthread.h  because this definition is allready in sys/time.h
Then I used the following steps:
  1. sh configure --prefix=/usr --with-sane-prefix=/usr --disable-sanetest --with-gtk-prefix=g:/XFree86 --disable-gtktest --disable-gimp
  2. In sane-frontends-1.0.11/src/Makefile 
    add to
    LIBS = -lsyslog -lsocket -lm
    the following code (one line):
    ../../sane-backends-1.0.14/backend/.libs/libsane.a
    Change
    $(INSTALL_PROGRAM) $${program} \
    $(bindir)/$${program}; \
    to
    $(INSTALL_PROGRAM) $${program}.exe \
    $(bindir)/$${program}.exe; \
  3. make
  4. make install

I have scripts which do all steps from 1 to 4. You can get them by request.

xscanimage.exe and xcam.exe are working on my system, I don't have a document-feeder so I can't tell ifscanadf.exe works, but it should.
If you configure with ... --enable-gimp
(and rename -lgimp to -lgimp121 in the Makefile) you get a xscanimage.exe that works for me as gimp(1.2.2)-plugin.


libtool

Here is the description how I did get the modified libtool  which was necessary to build libsane.dll .
I installed the source of SANE Version 1.01 and applied the patches from Yuri Dario included in his 1.01 binary distribution. All steps including autoconf and configure.os2. See his docs.
These steps created a reusable libtool.
I copied this so created libtool  to the 1.0.14 sane-backends-1.0.14/ directory and modified one line:
I added ../sanei/libsanei.a -ljpeg -lsyslog -lpthreads -ldl
to the line starting with
archive_cmds='$echo "LIBRARY

XSane

One powerful frontend for sane is xsane. You can find the informations how to build this program for OS/2 and a compiled version here.

Binary Packages

You also need a jpeg.dll if not already installed on your system.

Hardware that has been reported to work with previous binaries available from my site:
Hardware that has been reported to work with this version:

Thanks to Henning Meier-Geinitz, Oliver Rauch, Stéphane Voltz and Gerhard Jaeger who were very responsive in the sane-devel mailinglist and included some changes to the sources to make SANE 1.0.14 compile on OS/2
Thanks also to Paul Smedley and Zsolt Kadar who reported their experiences with this receipe for building SANE and helped to improve this page.
Thanks also to Paul Ratcliffe for aspirout.sys and Klaus Staedtler for TAME and testing and Thanks to all who reported if the binaries worked for them or not.
I hope I did not miss something important. Feel free to send me your comments.

Last modified 31 May 2007, Franz

Valid HTML 4.01