Subject: sane-backends workaround for MacOS X
To: None <tech-pkg@netbsd.org>
From: John D. Baker <jdbaker@mylinuxisp.com>
List: tech-pkg
Date: 04/07/2004 17:35:49
I think I've managed to work around the sane-backends problem I mentioned
yesterday.
On Tue, 6 Apr 2004, John D. Baker wrote:
> Trying to build graphics/sane-backends (dependency of graphics/xsane)
> on MacOS X 10.1.5 and 10.2.8 fails linking as follows:
>
> [...]
> mkdir .libs
> gcc -o .libs/scanimage scanimage.o stiff.o -framework CoreFoundation -framework IOKit -L/Volumes/NetBSD/pkgsrc/graphics/sane-backends/work/.buildlink/lib ../lib/liblib.a ../backend/.libs/libsane.dylib -L/usr/pkg/lib /usr/pkg/lib/libusb.dylib -lIOKit -lm /usr/pkg/lib/libjpeg.dylib
> ld: multiple definitions of symbol _getopt
> /usr/lib/libm.dylib(getopt.So) definition of _getopt
> ../lib/liblib.a(getopt.o) definition of _getopt in section (__TEXT,__text)
> ld: multiple definitions of symbol _opterr
> /usr/lib/libm.dylib(getopt.So) definition of _opterr
> ../lib/liblib.a(getopt.o) definition of _opterr in section (__DATA,__data)
> ld: multiple definitions of symbol _optind
> /usr/lib/libm.dylib(getopt.So) definition of _optind
> ../lib/liblib.a(getopt.o) definition of _optind in section (__DATA,__data)
> ld: multiple definitions of symbol _optopt
> /usr/lib/libm.dylib(getopt.So) definition of _optopt
> ../lib/liblib.a(getopt.o) definition of _optopt in section (__DATA,__data)
> gnumake[1]: *** [scanimage] Error 1
> gnumake: *** [all-recursive] Error 1
> *** Error code 2
>
> Stop.
> bmake: stopped in /usr/pkgsrc/graphics/sane-backends
> [...]
Workaround: Edit
graphics/sane-backends/work/sane-backends-1.0.12/lib/getopt.c
and comment out:
global vars: opterr, optind, optopt.
function: getopt
Or the patch, as follows:
--- /usr/pkgsrc/graphics/sane-backends/work/sane-backends-1.0.12/lib/getopt.c.orig Wed Apr 7 17:19:51 2004
+++ /usr/pkgsrc/graphics/sane-backends/work/sane-backends-1.0.12/lib/getopt.c Wed Apr 7 17:20:46 2004
@@ -132,7 +132,7 @@
how much of ARGV has been scanned so far. */
/* 1003.2 says this must be 1 before any call. */
-int optind = 1;
+/* int optind = 1; */
/* Formerly, initialization of getopt depended on optind==0, which
causes problems with re-calling getopt as programs generally don't
@@ -152,13 +152,13 @@
/* Callers store zero here to inhibit the error message
for unrecognized options. */
-int opterr = 1;
+/* int opterr = 1; */
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
-int optopt = '?';
+/* int optopt = '?'; */
/* Describe how to deal with options that follow non-option ARGV-elements.
@@ -1190,6 +1190,7 @@
}
}
+#if 0
int
getopt (argc, argv, optstring)
int argc;
@@ -1201,6 +1202,7 @@
(int *) 0,
0);
}
+#endif /* 0 */
#endif /* Not ELIDE_CODE. */
With the above modifications in place, sane-backends builds and installs.
The 'test' driver works, at least. I am still working on installing on
a machine that has a scanner attached.
(I'm anticipating shared-library problems. During installation, I saw
a number of command lines go by refering to "*.so" files, rather than
"*.dylib" files...)
--
John D. Baker, KN5UKS NetBSD Darwin/MacOS X
jdbaker(at)mylinuxisp(dot)com OpenBSD FreeBSD
BSD -- It just sits there and _works_!