+#if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
+ /*
+ * In order to avoid the lossage with flat Athena widgets dynamically
+ * linking to one of the ThreeD variants, using the dynamic symbol helpers
+ * to look for symbols that shouldn't be there and refusing to run if they
+ * are seems a less toxic idea than having XEmacs crash when we try and
+ * use a subclass of a widget that has changed size.
+ *
+ * It's ugly, I know, and not going to work everywhere. It seems better to
+ * do our damnedest to try and tell the user what to expect rather than
+ * simply blow up though.
+ *
+ * All the ThreeD variants I have access to define the following function
+ * symbols in the shared library. The flat Xaw library does not define them:
+ *
+ * Xaw3dComputeBottomShadowRGB
+ * Xaw3dComputeTopShadowRGB
+ *
+ * So far only Linux has shown this problem. This seems to be portable to
+ * all the distributions (certainly all the ones I checked - Debian and
+ * Redhat)
+ *
+ * This will only work, sadly, with dlopen() -- the other dynamic linkers
+ * are simply not capable of doing what is needed. :/
+ */
+
+ {
+ /* Get a dll handle to the main process. */
+ dll_handle xaw_dll_handle = dll_open (NULL);
+
+ /* Did that fail? If so, continue without error.
+ * We could die here but, well, that's unfriendly and all -- plus I feel
+ * better about some crashing somewhere rather than preventing a perfectly
+ * good configuration working just because dll_open failed.
+ */
+ if (xaw_dll_handle != NULL)
+ {
+ /* Look for the Xaw3d function */
+ dll_func xaw_function_handle =
+ dll_function (xaw_dll_handle, "Xaw3dComputeTopShadowRGB");
+
+ /* If we found it, warn the user in big, nasty, unfriendly letters */
+ if (xaw_function_handle != NULL)
+ {
+ warn_when_safe (Qdevice, Qerror, "\n"
+"It seems that XEmacs is built dynamically linked to the flat Athena widget\n"
+"library but it finds a 3D Athena variant with the same name at runtime.\n"
+"\n"
+"This WILL cause your XEmacs process to dump core at some point.\n"
+"You should not continue to use this binary without resolving this issue.\n"
+"\n"
+"This can be solved with the xaw-wrappers package under Debian\n"
+"(register XEmacs as incompatible with all 3d widget sets, see\n"
+"update-xaw-wrappers(8) and .../doc/xaw-wrappers/README.packagers). It\n"
+"can be verified by checking the runtime path in /etc/ld.so.conf and by\n"
+"using `ldd /path/to/xemacs' under other Linux distributions. One\n"
+"solution is to use LD_PRELOAD or LD_LIBRARY_PATH to force ld.so to\n"
+"load the flat Athena widget library instead of the aliased 3D widget\n"
+"library (see ld.so(8) for use of these environment variables).\n\n"
+ );
+
+ }
+
+ /* Otherwise release the handle to the library
+ * No error catch here; I can't think of a way to recover anyhow.
+ */
+ dll_close (xaw_dll_handle);
+ }
+ }
+#endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */
+
+