Add dynamic loading support for MacOS X/Darwin (from Peter O'Gorman

<peter@pogma.com>).
DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-12-01 12:42:01 +00:00
rodzic 5ce657748e
commit 46fcee60aa
4 zmienionych plików z 276 dodań i 5 usunięć

Wyświetl plik

@ -1,3 +1,8 @@
2002-12-01 Henning Meier-Geinitz <henning@meier-geinitz.de>
* configure configure.in backend/dll.c: Add dynamic loading support
for MacOS X/Darwin (from Peter O'Gorman <peter@pogma.com>).
2002-11-30 Henning Meier-Geinitz <henning@meier-geinitz.de>
* po/Makefile.in po/epson.sv.po po/saneopts.sv.po: Added Swedish

Wyświetl plik

@ -44,7 +44,7 @@
/* Please increase version number with every change
(don't forget to update dll.desc) */
#define DLL_VERSION "1.0.6"
#define DLL_VERSION "1.0.7"
#ifdef _AIX
# include "lalloca.h" /* MUST come first for AIX! */
@ -81,6 +81,12 @@
# define HAVE_DLL
#endif
/* Mac OS X/Darwin support */
#if defined (HAVE_NSLINKMODULE) && defined(HAVE_MACH_O_DYLD_H)
# include <mach-o/dyld.h>
# define HAVE_DLL
#endif
#include <sys/types.h>
#include "sane/sane.h"
@ -251,6 +257,22 @@ add_backend (const char *name, struct backend **bep)
return SANE_STATUS_GOOD;
}
#if defined(HAVE_NSLINKMODULE)
static const char *dyld_get_error_str ();
static const char
*dyld_get_error_str ()
{
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString;
NSLinkEditError (&c, &errorNumber, &fileName, &errorString);
return errorString;
}
#endif
static SANE_Status
load (struct backend *be)
{
@ -274,6 +296,11 @@ load (struct backend *be)
# define PREFIX "libsane-"
# define POSTFIX ".sl.%u"
mode = BIND_DEFERRED;
#elif defined(HAVE_NSLINKMODULE)
# define PREFIX "libsane-"
# define POSTFIX ".%u.so"
mode = NSLINKMODULE_OPTION_RETURN_ON_ERROR +
NSLINKMODULE_OPTION_PRIVATE;
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */
@ -344,6 +371,16 @@ load (struct backend *be)
be->handle = dlopen (libname, mode);
#elif defined(HAVE_SHL_LOAD)
be->handle = (shl_t)shl_load (libname, mode, 0L);
#elif defined(HAVE_NSLINKMODULE)
{
NSObjectFileImage objectfile_img = NULL;
if (NSCreateObjectFileImageFromFile (libname, &objectfile_img)
== NSObjectFileImageSuccess)
{
be->handle = NSLinkModule (objectfile_img, libname, mode);
NSDestroyObjectFileImage (objectfile_img);
}
}
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */
@ -351,6 +388,8 @@ load (struct backend *be)
{
#ifdef HAVE_DLOPEN
DBG(1, "load: dlopen() failed (%s)\n", dlerror());
#elif defined(HAVE_NSLINKMODULE)
DBG(1, "load: dyld error (%s)\n", dyld_get_error_str());
#else
DBG(1, "load: dlopen() failed (%s)\n", strerror (errno));
#endif
@ -370,6 +409,18 @@ load (struct backend *be)
op = (void *(*)(void)) dlsym (be->handle, funcname + 1);
#elif defined(HAVE_SHL_LOAD)
shl_findsym ((shl_t*)&(be->handle), funcname + 1, TYPE_UNDEFINED, &op);
#elif defined(HAVE_NSLINKMODULE)
{
NSSymbol *nssym = NSLookupSymbolInModule (be->handle, funcname);
if (!nssym)
{
DBG(15, "dyld error: %s\n", dyld_get_error_str());
}
else
{
op = (void *(*)(void)) NSAddressOfSymbol (nssym);
}
}
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */
@ -382,6 +433,18 @@ load (struct backend *be)
op = (void *(*)(void)) dlsym (be->handle, funcname);
#elif defined(HAVE_SHL_LOAD)
shl_findsym (be->handle, funcname, TYPE_UNDEFINED, &op);
#elif defined(HAVE_NSLINKMODULE)
{
NSSymbol *nssym = NSLookupSymbolInModule (be->handle, funcname);
if (!nssym)
{
DBG(15, "dyld error: %s\n", dyld_get_error_str());
}
else
{
op = (void *(*)(void)) NSAddressOfSymbol (nssym);
}
}
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */
@ -619,6 +682,14 @@ sane_exit (void)
#elif defined(HAVE_SHL_LOAD)
if (be->handle)
shl_unload(be->handle);
#elif defined(HAVE_NSLINKMODULE)
if (be->handle)
NSUnLinkModule(be->handle,
NSUNLINKMODULE_OPTION_NONE
# ifdef __ppc__
| NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES
# endif
);
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */

196
configure vendored
Wyświetl plik

@ -5788,6 +5788,194 @@ done
fi
done
#Mac OS X/Darwin
for ac_header in mach-o/dyld.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
no:yes )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
for ac_func in NSLinkModule
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
char (*f) ();
int
main ()
{
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func;
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
enable_dynamic=yes
fi
done
LDFLAGS="$LDFLAGS -module"
DL_LIB=""
fi
done
fi
@ -8479,7 +8667,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
case $host in
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 8482 "configure"' > conftest.$ac_ext
echo '#line 8670 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@ -8997,7 +9185,7 @@ chmod -w .
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
compiler_c_o=no
if { (eval echo configure:9000: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
if { (eval echo configure:9188: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s out/conftest.err; then
@ -10747,7 +10935,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10750 "configure"
#line 10938 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -10845,7 +11033,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10848 "configure"
#line 11036 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H

Wyświetl plik

@ -223,6 +223,13 @@ if test "${enable_dynamic}" != "no"; then
AC_CHECK_FUNCS(shl_load, enable_dynamic=yes,)
LIBS="${saved_LIBS}"
],)
#Mac OS X/Darwin
AC_CHECK_HEADERS(mach-o/dyld.h,
[AC_CHECK_FUNCS(NSLinkModule, enable_dynamic=yes,)
LDFLAGS="$LDFLAGS -module"
DL_LIB=""
],)
fi
AC_SUBST(DL_LIB)