sane-0.55: PINT/NetBSD fixes

Gordon Matzigkeit (gord@m-tech.ab.ca)
23 Apr 1997 23:39:49 -0600

--Multipart_Wed_Apr_23_23:39:49_1997-1
Content-Type: text/plain; charset=US-ASCII

Hi, all!

Great job on 0.55, David... the graphical interface is looking slicker
already.

I forgot to mention (since I was too busy with PINT) that the dll
backend was a little broken. Due to skew between configure.in and
dll.c, it was possible to build a sane that neither preloaded backends
nor had dynamic loading available. The attached patch fixes this
problem.

It also adds dlopen support for NetBSD. Please review this code... I
think it is quite clean, but I don't know if it will break any other
platforms in practice.

I made a trivial fix to the build environment, so that it fails more
nicely when install directories don't exist. The proper thing to do
is a mkinstalldirs-type program, but I don't have time for that today.

The last bit of this patch is trivial... the PINT backend was not
updated to use the new sane include subdir when it was changed.

With all these minor tweaks (and the latest libtool to fix a silly bug
I made on NetBSD), SANE now works *beautifully* with PINT on my
system.

Kudos to all, especially for designing a system that was so trivial to
adapt to my environment.

-- 
  Gord Matzigkeit   | Proudly running pieces of the GNU operating system.
 gord@m-tech.ab.ca  |  Jacques Cousteau loved programming in assembler.

--Multipart_Wed_Apr_23_23:39:49_1997-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="sane-0.55.diff" Content-Transfer-Encoding: 7bit

--- ChangeLog.orig Wed Apr 23 23:03:45 1997 +++ ChangeLog Wed Apr 23 23:24:40 1997 @@ -1,3 +1,26 @@ +Wed Apr 23 23:03:47 1997 Gordon Matzigkeit <gord@gnu.ai.mit.edu> + + * backend/Makefile.in, frontend/Makefile.in: Specify full + filenames, rather than just the directory name for INSTALL + destinations. This Automakeism helps debugging when the target + directory doesn't exist. + + * include/sane/config.h.in (HAVE_SYS_SCANIO_H): Define, for PINT's + sake. + + * backend/pint.c: Prefix sane includes with <sane/...>. + + * backend/dll.c (RTLD_NOW): Paramaterize, so that RTLD_LAZY is + used if RTLD_NOW is not defined. + (load): Try looking up the symbol with a leading underscore, if we + can't find it the first time. + + Make dynamic loading conditional on HAVE_DLOPEN rather than the + library and header file. + + * configure.in (enable_dynamic): Disable dynamic loading if the + system doesn't have dlopen. + Tue Apr 22 00:17:41 1997 David Mosberger-Tang <davidm@azstarnet.com> * frontend/xscanimage.c (browse_filename_callback): Initialize @@ -230,8 +253,8 @@ installed. Sat Apr 19 18:15:03 1997 Michael K. Johnson <johnsonm@redhat.com> - - * */*.[ch]: Prefix sane-includese with <sane/...>. + + * */*.[ch]: Prefix sane-includes with <sane/...>. include/sane*: Move to include/sane subdirectory. Sat Apr 19 08:25:36 1997 David Mosberger-Tang <davidm@azstarnet.com> --- backend/Makefile.in.orig Tue Apr 22 23:13:09 1997 +++ backend/Makefile.in Tue Apr 22 23:56:21 1997 @@ -73,8 +73,9 @@ install: @list="$(LIBS)"; for be in $$list; do \ echo installing $${be} in $(libdir)...; \ - $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${be} $(libdir); \ + $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${be} $(libdir)/$${be}; \ done + $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) libsane.la $(libdir)/libsane.la ln -f -s libsane-dll.so $(libdir)/libsane.so.$(V_MAJOR) ln -f -s libsane-dll.a $(libdir)/libsane.a -mkdir $(configdir) @@ -84,7 +85,7 @@ echo NOT overwriting $${cfg} in $(configdir)...; \ else \ echo installing $${cfg} in $(configdir)...; \ - $(INSTALL_DATA) $${cfg} $(configdir); \ + $(INSTALL_DATA) $${cfg} $(configdir)/$${cfg}; \ fi; \ done @@ -128,6 +129,7 @@ libsane-hp.la: ../sanei/sanei_scsi.lo libsane-mustek.la: ../sanei/sanei_constrain_value.lo libsane-mustek.la: ../sanei/sanei_scsi.lo +libsane-pint.la: ../sanei/sanei_constrain_value.lo libsane-net.la: ../sanei/sanei_codec_bin.lo libsane-net.la: ../sanei/sanei_net.lo libsane-net.la: ../sanei/sanei_wire.lo --- backend/dll.c.orig Tue Apr 22 22:47:14 1997 +++ backend/dll.c Wed Apr 23 23:17:48 1997 @@ -24,7 +24,7 @@ #include <lalloca.h> /* MUST come first for AIX! */ -#if defined(HAVE_DLFCN_H) && defined(HAVE_LIBDL) +#ifdef HAVE_DLOPEN # define DYNAMIC #else # undef DYNAMIC @@ -36,8 +36,11 @@ #include <stdlib.h> #include <string.h> -#ifdef DYNAMIC +#if defined(DYNAMIC) && defined(HAVE_DLFCN_H) # include <dlfcn.h> +# ifndef RTLD_NOW +# define RTLD_NOW RTLD_LAZY +# endif #endif #include <sys/types.h> @@ -220,11 +223,19 @@ { void *(*op) (); - sprintf (funcname, "sane_%s_%s", be->name, op_name[i]); + sprintf (funcname, "_sane_%s_%s", be->name, op_name[i]); - op = (void *(*)()) dlsym (be->handle, funcname); + /* First try looking up the symbol without a leading underscore. */ + op = (void *(*)()) dlsym (be->handle, funcname + 1); if (op) be->op[i] = op; + else + { + /* Try again, with an underscore prepended. */ + op = (void *(*)()) dlsym (be->handle, funcname); + if (op) + be->op[i] = op; + } } return SANE_STATUS_GOOD; --- backend/pint.c.orig Tue Apr 22 22:47:37 1997 +++ backend/pint.c Tue Apr 22 23:09:01 1997 @@ -20,22 +20,22 @@ This file implements a SANE backend for the PINT (PINT Is Not TWAIN) scanner device driver, commonly found in NetBSD. */ -#include <config.h> +#include <sane/config.h> #include <limits.h> #include <stdlib.h> #include <string.h> extern int errno; -#include <sane.h> -#include <saneopts.h> +#include <sane/sane.h> +#include <sane/saneopts.h> #include "pint.h" #include <unistd.h> #include <fcntl.h> -#include <sanei_backend.h> +#include <sane/sanei_backend.h> #define PATH_PINT_CONFIG STRINGIFY(PATH_SANE_CONFIG_DIR) "/pint.conf" --- configure.in.orig Wed Apr 23 00:02:43 1997 +++ configure.in Wed Apr 23 00:09:08 1997 @@ -110,8 +110,10 @@ -DPATH_SANE_DATA_DIR=\$(datadir) \ -DV_MAJOR=${V_MAJOR} -DV_MINOR=${V_MINOR}" if test "${enable_dynamic}" != "no"; then - AC_CHECK_HEADERS(dlfcn.h,HAVE_DLFCN_H="yes") - AC_CHECK_LIB(dl,dlopen) + AC_CHECK_HEADERS(dlfcn.h, + [AC_CHECK_LIB(dl,dlopen) + AC_CHECK_FUNCS(dlopen, , enable_dynamic=no)], + [enable_dynamic=no]) fi if test "${enable_ld_fix}" = "no"; then echo "disabling Mustek line-distance bug workaround" @@ -138,7 +140,7 @@ if test "${enable_shared}" = "no"; then enable_preload=yes fi -if test "${HAVE_DLFCN_H}" != "yes" -o "${enable_preload}" = "yes"; then +if test "${enable_dynamic}" = no || test "${enable_preload}" = "yes"; then echo "preloading backends into DLL" DLL_PRELOAD="\$(PRELOADABLE_BACKENDS)" else --- frontend/Makefile.in.orig Tue Apr 22 23:58:38 1997 +++ frontend/Makefile.in Tue Apr 22 23:59:01 1997 @@ -64,12 +64,12 @@ mkdir $(sbindir); \ fi @for program in $(BINPROGS); do \ - $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${program} $(bindir); \ + $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${program} $(bindir)/$${program}; \ done @for program in $(SBINPROGS); do \ - $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${program} $(sbindir); \ + $(LIBTOOL) $(MINST) $(INSTALL_PROGRAM) $${program} $(sbindir)/$${program}; \ done - $(INSTALL_DATA) sane-style.rc $(datadir) + $(INSTALL_DATA) sane-style.rc $(datadir)/sane-style.rc test: test.o $(LIBSANE) $(LIBLIB) @$(LIBTOOL) $(MLINK) $(LINK) test.o $(LIBSANE) $(LIBLIB) $(LIBS) --- include/sane/config.h.in.orig Tue Apr 22 23:10:30 1997 +++ include/sane/config.h.in Wed Apr 23 00:10:50 1997 @@ -187,6 +187,9 @@ /* Define if you have the <sys/scsiio.h> header file. */ #undef HAVE_SYS_SCSIIO_H +/* Define if you have the <sys/scanio.h> header file. */ +#undef HAVE_SYS_SCANIO_H + /* Define if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H @@ -205,8 +208,8 @@ /* Define if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H -/* Define if you have the dl library (-lm); defines dlopen() etc. */ -#undef HAVE_LIBDL +/* Define if you have the dlopen function. */ +#undef HAVE_DLOPEN /* Define if you have the GIMP header files and library. */ #undef HAVE_LIBGIMP_GIMP_H

--Multipart_Wed_Apr_23_23:39:49_1997-1--

--
Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/
To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com