Subject: Re: XShm lacking in the Xext library
From: [email-masked] (Gary V. Vaughan)

15 Jan 1999 14:21:29 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------E3B3FC68041AED4093F89987"
To: Sebastien Carpe <[email-masked]>,
        Michael Jennings <[email-masked]>
Cc: [email-masked]

This is a multi-part message in MIME format.
--------------E3B3FC68041AED4093F89987
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Sebastien!

That is great news.

I have CCed this to Michael Jennings as he might be interested in
distributing your binaries from his web site, as the ones I sent him are
quite old now.

I have attached my makedll script which will convert an existing static
lib into a dll/import lib pair (b20 only, unless you use Mumit Khan's
dllhelpers package).  There is a bit of a knack to using this, because
you need to break out of the build after each static lib has been built,
run the script to convert it by hand and then resume the build (until
another static lib needs converting).

I tend to use `make somelib.a && makedll <-Lextra/path> <-ldeplib>
somelib[.a/.la]' for all the libraries in the package, and then run a
full make with the dll's in place.

A few things to watch for:  You can't leave any undefined symbols in a
dll (which you can sometimes get round by using macros for the offending
symbols). The import libs (.a) need to go in the library search path
(/usr/lib maybe?), and the dlls need to go in the executable search path
(/usr/bin maybe?), so after make install, you will need to manually copy
the dlls into place.  Also the script (actually its the dlls themselves)
don't cope well with exported data items (like glib version numbers for
instance) without *alot* of messing about with _declspec in the headers
(look at glib and you will see what I mean).

Hope that helps some.

Cheers,
	Gary.

P.S last one to compile balsa on win32 is a rotten egg (you too
Michael!) =)O|

Sebastien Carpe wrote:
> 
> I downloaded the X11R6.4 release, applyed the ptch from Sergey and fiddle in
> the Xext directory so that it includes XShm.c and recompiled. Unfortunately, i
> didn't succeed to ake dll, but since i don't really understand how it really
> works, that was to be exspected... So i did a static libXext2 with XShm support
> and managed to compile E successfully (still had to patch to make button work
> ... for some reason, getpwd didn't extract the shell path from /etc/passwd...)
> NB: i did make use of libcygipc somewhere but don't remind where...
> At the moment, i managed to have gtk/glib 1.1.12 working, imlib, Eterm and
> enlightenement. I'll be moving forward to meet gnome in the next few weeks)
> 
> "Gary V. Vaughan" wrote:
> >
> > Sebastien Carpe wrote:
> > >
> > > Well, i'm trying to compile Enlightenment. Yet, it seems XShm
> > > functions are not present within the libXext (from Sergey or Andy,
> > > they seem to be the same anyway). Does anybody know why i can't find
> > > them anywhere in the /usr/X11R6.4/lib libraries ? or if there is
> > > something that prevent to have XShm implemented on Cygwin ... I'd be
> > > glad to know if i stand a chance to have it run or not ...
> >
> > I sent Michael Jennings a bunch of code to allow conditional compile
> > time removal of the shared memory code from Imlib and enlightenment
> > (waaaay) before Christmas.  I had hoped to rebuild the whole lot with
> > b20 as soon as it was released, but have had scant time to do so.  I am
> > still fiddling with getting GTK-1.1.12 to compile properly, but will get
> > there (a b20.1 compile of enlightenment) eventually.
> >
> > I think Michael checked all that stuff in, though it may have bitrotted
> > since then.  Michael also has all the binaries on his website so you
> > could use those for now.
> >
> > The reason XShm is not implemented is because there is no unix shm API
> > wrapper for win32, and XShm requires that.  There is a poor mans shm
> > daemon for win32 which will manage shared memory for processes that
> > speak to it, and a shm/IPC API library for you to link with:
> >
> > http://www.multione.capgemini.fr/tools/pack_ipc/
> >
> > Hope that helps some.
> >
> > Cheers,
> >         Gary V. Vaughan
> > -
> > For help on using this list (especially unsubscribing), send a message to
> > "[email-masked]" with one line of text: "help".
--------------E3B3FC68041AED4093F89987
Content-Type: text/plain; charset=us-ascii;
 name="makedll"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="makedll"

#!/bin/sh

# USAGE: makedll [-v] [<linker options>] <library>
#        eg. makedll libz.a

VERBOSE=false
DLL_LDFLAGS=""
TMP_FILES=""

# If we have any extra arguments, make sure they are switches (start with a -)
# and add them to the link flags.
#
while test $# -gt 0; do
  case $1 in
   -v | --v | --ve | --ver | --verb | --verbo | --verbos | --verbose)
       VERBOSE=:
       VERBOSE_FLAG=$1
       shift
       ;;
   -*) DLL_LDFLAGS="$DLL_LDFLAGS $1"
       shift
       ;;
   *)  break ;;
  esac
done

# Only one argument should remain (the library name)
#
if test $# != 1; then
  echo "USAGE:  makedll [<linker options>] <library>" >&2
  exit 2
fi

# This script needs to be run in the same directory as the library
#
CWD=`pwd`
library="`echo $1|sed 's,\\\\,/,g;;s,^\([A-Za-z]\):,//\1,'`"
case $library in
  */*) srcdir=`echo $library|sed 's,/[^/]*$,,'` ;;
  *) srcdir=. ;;
esac
cd $srcdir

basename=`echo $1 | sed 's,\..*$,,'`
case $basename in
  /*) basename="`echo $basename|sed 's,^.*/,,g'`"
      ;;
esac

# Handle libtool libs in a .libs subdir gracefully!
case $1 in
  *.la)
	. $1
	basename=`echo $old_library | sed 's,\..*$,,'`
	case $basename in
	  /*) basename="`echo $basename|sed 's,^.*/,,g'`"
	      ;;
	esac
	JUMP_FILE="$srcdir/.libs/$basename.a"
	EXP_FILE="$srcdir/.libs/$basename.coff"
	if test -f $JUMP_FILE; then
	  :
	else
	  if test -f $EXP_FILE; then
	    mv $EXP_FILE $JUMP_FILE
	  else
	    echo "Error: no $JUMP_FILE to match $basename" >&2
	    exit 1
	  fi
	fi
	;;
  *.a)
	EXP_FILE="$srcdir/$basename.coff"
	JUMP_FILE="$srcdir/$basename.a"
	;;
  *)    echo "Error: unknown library type $1" >&2
	exit 1
	;;
esac

$VERBOSE && echo "JUMP_TABLE will be archived to $JUMP_FILE"

# Make sure we preserve the original coff library
#
if test -f $EXP_FILE; then
  :
else
  mv $JUMP_FILE $EXP_FILE
fi

$VERBOSE && echo "COFF library will be preserved at $EXP_FILE"

# Get a list of the object files in the coff library, and make sure
# they are all present!
#
COFF_OBJS="`ar t $EXP_FILE`"
for file in $COFF_OBJS
do
  if test -f $file; then
    :
  else
    ar x $EXP_FILE $file
    TMP_FILES="$TMP_FILES $file"
  fi
done

$VERBOSE && echo "Exporting from objects: $COFF_OBJS"

# Extrapolate the other files we need
#
DEF_FILE=$basename.def
DLL_NAME=$basename.dll
DLL_OBJS="dllinit.o $COFF_OBJS"

# Make a dll entry point object for the dll
#
if test -f dllinit.c; then
  :
else
  $VERBOSE && echo "Creating dll entry point"
  cat $0 | grep '^X' | sed s,^X,, > dllinit.c
  gcc -c dllinit.c
  TMP_FILES="$TMP_FILES dllinit.c dllinit.o"
fi

# create an export list
#
$VERBOSE && echo "Creating export list to $DEF_FILE"
rm -f $DEF_FILE
dlltool --export-all --output-def $DEF_FILE $DLL_OBJS

# Use Mumit Khan's dllwrap to build a dll from the export list and
# the extracted objects
$VERBOSE && echo "Combining objects, entry point and deflist into a dll"
eval dllwrap $VERBOSE_FLAG --def $DEF_FILE -o $DLL_NAME $DLL_OBJS$DLL_LDFLAGS

# Make a jump table export library for gcc to link against
#
$VERBOSE && echo "Creating a jump table at $JUMP_FILE"
dlltool --dllname $DLL_NAME --def $DEF_FILE --output-lib $JUMP_FILE

# Touch the libtool library so that make knows it has to relink
#
test -f $1 && touch $1

# cleanup temporary files
#
rm $DEF_FILE $TMP_FILES

# quick reminder!
#
cat >&2 <<EOF
Don\'t forget to install the dll into a directory in your \$PATH\!
EOF

# don\'t interpret the rest of this file as a script!
#
exit 0
X/* dllinit.c -- Portable DLL initialization. 
X   Copyright (C) 1998 Free Software Foundation, Inc.
X   Contributed by Mumit Khan ([email-masked]).
X
X   I've used DllMain as the DLL "main" since that's the most common 
X   usage. MSVC and Mingw32 both default to DllMain as the standard
X   callback from the linker entry point. Cygwin b20 uses essentially 
X   the same, albeit slightly differently implemented, scheme. Please
X   see DECLARE_CYGWIN_DLL macro in <cygwin/cygwin_dll.h> for more 
X   info on how Cygwin uses the callback function.
X
X   The real entry point is typically always defined by the runtime 
X   library, and usually never overridden by (casual) user. What you can 
X   override however is the callback routine that the entry point calls, 
X   and this file provides such a callback function, DllMain.
X
X   Mingw32: The default entry point for mingw32 is DllMainCRTStartup
X   which is defined in libmingw32.a This in turn calls DllMain which is
X   defined here. If not defined, there is a stub in libmingw32.a which
X   does nothing.
X
X   Cygwin: The default entry point for cygwin b20 is
X   __cygwin_dll_entry which is defined in libcygwin.a. This in turn
X   calls the routine you supply to the DECLARE_CYGWIN_DLL (see below)
X   and, for this example, I've chose DllMain to be consistent with all
X   the other platforms.
X
X   MSVC: MSVC runtime calls DllMain, just like Mingw32.
X
X   Summary: If you need to do anything special in DllMain, just add it
X   here. Otherwise, the default setup should be just fine for 99%+ of
X   the time. I strongly suggest that you *not* change the entry point,
X   but rather change DllMain as appropriate.
X
X */
X
X
X#define WIN32_LEAN_AND_MEAN
X#include <windows.h>
X#undef WIN32_LEAN_AND_MEAN
X#include <stdio.h>
X
XBOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, 
X                       LPVOID reserved /* Not used. */ );
X
X#ifdef __CYGWIN32__
X
X#include <cygwin/cygwin_dll.h>
XDECLARE_CYGWIN_DLL( DllMain );
X/* save hInstance from DllMain */
XHINSTANCE __hDllInstance_base;
X
X#endif /* __CYGWIN32__ */
X
X/*
X *----------------------------------------------------------------------
X *
X * DllMain --
X *
X *	This routine is called by the Mingw32, Cygwin32 or VC++ C run 
X *	time library init code, or the Borland DllEntryPoint routine. It 
X *	is responsible for initializing various dynamically loaded 
X *	libraries.
X *
X * Results:
X *      TRUE on sucess, FALSE on failure.
X *
X * Side effects:
X *
X *----------------------------------------------------------------------
X */
XBOOL APIENTRY
XDllMain (
X	 HINSTANCE hInst /* Library instance handle. */ ,
X	 DWORD reason /* Reason this function is being called. */ ,
X	 LPVOID reserved /* Not used. */ )
X{
X
X#ifdef __CYGWIN32__
X  __hDllInstance_base = hInst;
X#endif /* __CYGWIN32__ */
X
X  switch (reason)
X    {
X    case DLL_PROCESS_ATTACH:
X      break;
X
X    case DLL_PROCESS_DETACH:
X      break;
X
X    case DLL_THREAD_ATTACH:
X      break;
X
X    case DLL_THREAD_DETACH:
X      break;
X    }
X  return TRUE;
X}

--------------E3B3FC68041AED4093F89987--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".