Here are some tips for running and compiling SANE under OS/2
Well, I've hardly touched SANE and OS/2 for about 18 months now.
The main beacon holder seems to be Paul Smedley these days - here's his web site.
First of all, if you just want to run a pre-compiled binary.
Running SANE
The SANE_CONFIG_DIR environment variable should point to the directory that contains your [backend].conf file. For instance, SET SANE_CONFIG_DIR=c:\mptn\etc which contains snapscan.conf. In addition, if you are using a parallel port scanner with one of the later betas (1.0.3 and 1.0.4 in which I've disabled the -d option), you should also have a "dll.conf" file that contains the name of your backend (e.g., mustek_pp).
You should set TMP to something valid. If you have problems, then you might like to try the following: SANE_DEBUG_[BACKEND], SANE_DEBUG_DLL and SANE_DEBUG_SANEI_SCSI. All three take numeric values, as far as I can tell, from 0 to 255.
For instance set SANE_DEBUG_SNAPSCAN=2. See below for more information.
You can set SANE_DEFAULT_DEVICE (e.g., to snapscan:b1t2l0).
There are several GUIs available (fesane, jsane, josi, pmsane, SANE/2 and Scan It/2). They can also be found on hobbes, except for Scan It/2, which should be on leo. SANE/2 and Scan It/2 require the DLL version of SANE, so they won't work with anything that I've compiled (at the time of writing - since then I've managed to build DLLs, but haven't tried them).
Compiling SANE
I recommend that you download the following packages and patches.
- sane-1.0.x.tar.gz from the sane homepage.
- os2unix
- You need the directory \var\tmp to exist on the drive where you are running scanimage.exe.
There are a ton of packages that you will need (possibly non-exhaustive):
ksh, autoconf, m4, gcc, gnu bin utils, gnu text utils, gnu patch, sed, bison, gnu diff, gnu find, gnu gawk, gnu shell utils,
gnu make. As a rule, the latest versions should work. sed might pose a problem
You'll probably also want the following packages as well:
- syslog3.zip from leo. Make sure that you recompile the libraries, as you may not be able to link otherwise. You'll also have to put the compiled library (syslog.a) in your emx library directory (x:\emx\lib), and the syslog headers in your emx include directory (x:\emx\include[\sys]). (Other directories will probably work, and/or modifying the options that you use with configure, but this is the quickest and easiest way).
- More recent backend code. For instance, for the Agfa SnapScan
or for Mustek.
- Alternatively, set yourself up to check out the latest SANE source code from anonymous CVS.
In order to configure your build environment, there are a few things that you'll need to do.
- Set a few environment variables.
I use two command files to configure my build environment, one which uses the older EMX, one which uses the newer PGCC. I haven't tried Innotek's GCC 3.
setpathpgcc.cmd
set path=g:\emx\bin.new;g:\emx\bin;g:\bin;C:\OS2;C:\OS2\SYSTEM;C:\OS2\INSTALL;C:\;f:\editors\epm603;C:\OS2\APPS;F:\JAVA11\BIN;F:\UTILS;f:\TOOLKIT\BIN;z:\work\sane-1.0.7\frontend;
set dpath=%dpath%g:\emx\book;
set help=%help%g:\emx\help;
set bookshelf=%bookshelf%g:\EMX\BOOK;
set TMP=g:\tmp
set EMX_PATH=g:/emx/bin.new
SET C_INCLUDE_PATH=g:/emx/include.new;g:/emx/include
SET LIBRARY_PATH=g:/emx/lib.new;g:/emx/lib
SET CPLUS_INCLUDE_PATH=g:/emx/include/cpp;g:/emx/include;
SET PROTODIR=g:/emx/include/cpp/gen
REM set OBJC_INCLUDE_PATH=g:/emx/include
SET GCCLOAD=5
SET GCCOPT=-pipe
REM set TERM=mono
REM set TERMCAP=g:/emx/etc/termcap.dat
REM set INFOPATH=g:/emx/info
SET EMXBOOK=emxdev.inf+emxlib.inf+emxgnu.inf+emxbsd.inf
SET HELPNDX=emxbook.ndx
set beginlibpath=g:\emx\dll.new;g:\emx\dll
SET HOSTTYPE=i386
SET MACHTYPE=i386-pc-os2
set EXEEXT=.exe
REM set ac_cv_exeext=.exe
REM set SANE_DEBUG_SANEI_SCSI=2
REM set SANE_DEBUG_DLL=2
REM set SANE_DEBUG_SNAPSCAN=2
set SANE_CONFIG_DIR=c:\mptn\etc
|
setpathemx.cmd is identical, except that all the references to the PGCC directories that contain ".new" are removed. A few extra details. I have my sane build directory and emx on g:. On f: I have unix utils. c: is my boot drive. I use TVFS to create a z: drive, where I mount the parts of f: and g: that I need. For speed purposes, it's always best to access drives directly whenever possible, so I use z: as little as possible.
- If your installation of all things gnu and emx isn't on the same drive, then I recommend that you use TVFS (on hobbes) to join them all together. Here is my example startup.cmd:
startup.cmd
tvctl -Dw
tvrestor f:\tvfs\tvfs.cmd
exit
|
The tvfs.cmd file that it references
tvfs.cmd
/*REXX*/
/* Load the Tvfs REXX interface. */
rc = RxFuncAdd('TvLoadFuncs', 'TVRX', 'TvLoadFuncs');
if (rc <> 0) then call shutdown;
rc = TvLoadFuncs();
if (rc <> 0) then call shutdown;
/* Restore the Tvfs drives. */
rc = TvUmount("*");
rc = TvMount("-c0 Z:");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\bin F:\bin");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\bin F:\utils");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\emx G:\emx");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\tmp G:\tmp");
if (rc <> 0) then call shutdown;
rc = TvMkdir("Z:\usr");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\var G:\var");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\work G:\junk\sane");
if (rc <> 0) then call shutdown;
rc = TvMkdir("Z:\usr\local");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\bin G:\usr\local\bin");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\etc G:\usr\local\etc");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\include G:\emx\include.new");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\include G:\emx\include");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\lib G:\usr\local\lib");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\sbin G:\usr\local\sbin");
if (rc <> 0) then call shutdown;
rc = TvLink("-drwcnt Z:\usr\local\share G:\usr\local\share");
if (rc <> 0) then call shutdown;
/* Unload the Tvfs REXX interface. */
rc = TvDropFuncs();
exit(0);
shutdown:
SAY "Error restoring TVFS drive."
call TvUmount("*");
call TvDropFuncs;
exit(16)
|
- At this point, you should have a build directory, and all of the build tools set up. There are still a few things that you need to do.
- Run os2unix -all. If you need to rerun this tool, it will add extra spurious lines to your Makefiles. This should be harmless.
- Run ./configure in the sane-1.0.x directory. If you are re-running configure, you might need to delete config.cache, otherwise it might not correctly test everything, just take the test values from the previous execution of configure.
- Run make.
- Test tools/sane-find-scanner.exe and frontend/scanimage.exe
- If you have problems, try making a debug build. It ought to be possible to run configure to generate Makefiles that compile debug info, but I've never managed to get it to work. The manual way is to edit lib/Makefile, sanei/Makefile, frontend/Makefile, Backend/Makefile and tools/Makefile. In the line for CFLAGS, make sure that you DO have -g and that you DO NOT have -s. Ditto for LDFLAGS. I also remove the -O2, but it's probably not absolutely necessary. Then do a "make clean" followed by a "make". You should now be able to debug scanimage.exe with either gdb or pmgdb.
- (Optional) Get Franz Bakan's patch for the sanei code, and for more hints on building a working SANE/2.
A few explanations. On my system I have most of the gnu binaries in f:\bin. I also have some things (mainly not gnu) in f:\utils. EMX is in g:\emx. /tmp is in h:\tmp and the /usr tree is on h:\usr (this is mainly needed by autoconf). You may have noticed that a lot of the PATH components refer to the real hard disk directories, whilst I'm using a Z: TVFS directory. I think there is a performance gain to be had by accessing files directly whenever possible. It's vitally important if you do this that the paths pointed to directly are the same ones that are mounted in your TVFS drive. For instance, if you have TMP=c:\tmp, but d:\tmp is mounted as z:\tmp in TVFS, then you might find that one tool writes a file to $TMP (c:\tmp) but then some bozo has written a script that wants to read it using the direct path /tmp (which is z:\tmp, which is d:\tmp). Since the file was written to c:\tmp, it's not going to find it later when it looks in d:\tmp.
There are a few more things that I recommend doing.
- Subscribe to the sane-os2 list on sane-os2-subscribe@egroups.com
- Subscribe to the main sane developers list (mail to majordomo@mostang.com with "subscribe sane-devel" in the text).
The list is biased toward unix type systems, especially linux. If you have a question that is specific to OS/2, then you're unlikely to find an answer there. They have been quite a lot more helpful recently with SANE 1.0.5.
SANE and output streams
Briefly, when SANE runs, it outputs stuff to two places, stdout and stderr. By default both of these go to the screen.
However, if you redirect stdout to a file (scanimage > scan.pnm) then only stderr continues to be shown on the screen. You should be able
to redirect stderr to a file as well, for instance if you have the SANE_DEBUG* environment variables set, and you run the
command "scanimage -v 2>debug.log > scan.tnm", then hopefully you won't lose the reams of debug output. (If you use the --help option,
it seems as though the help output goes to stdout instead of stderr).
TODO List
Not in any particular order
- Update libtool (or even better, the input files to libtool) in order to be able to compile the DLL version
- Get it to run better with scanners other than my SnapScan 1236s!
Copyright © Paul John Floyd 2003 - 2005