Patchwork [xserver,2/2] xfree86: add support for Cygwin

login
register
mail settings
Submitter Yaakov Selkowitz
Date March 28, 2012, 5:16 a.m.
Message ID <1332911790-6464-3-git-send-email-yselkowitz@users.sourceforge.net>
Download mbox | patch
Permalink /patch/9655/
State New
Headers show

Comments

Yaakov Selkowitz - March 28, 2012, 5:16 a.m.
From: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>

As a PE platform, all symbols in both EXEs and DLLs must be resolved
at link time.  As Xorg modules depend on symbols in the Xorg
executable, we must build Xorg before its modules, creating an implib
from the former which is used to link the latter.  This implib must
then be installed in order to build the drivers.

Currently only two drivers are supported on Cygwin: xf86-video-dummy
(to replace Xvfb/Xfake) and xf86-video-nested (to replace Xnest/Xephyr).

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
---
 configure.ac                          |   24 ++++++++++++++++++++++++
 hw/xfree86/Makefile.am                |   18 +++++++++++++++---
 hw/xfree86/common/xf86Config.c        |    5 +++++
 hw/xfree86/common/xf86Init.c          |    7 +++++++
 hw/xfree86/dixmods/Makefile.am        |   16 ++++++++++------
 hw/xfree86/dixmods/extmod/Makefile.am |    2 +-
 hw/xfree86/exa/Makefile.am            |    4 ++--
 hw/xfree86/fbdevhw/Makefile.am        |    2 +-
 hw/xfree86/i2c/Makefile.am            |   17 ++++++++++-------
 hw/xfree86/loader/loadmod.c           |   18 ++++++++++++++++++
 hw/xfree86/man/xorg.conf.man          |    3 ++-
 hw/xfree86/os-support/xf86_OSlib.h    |    2 +-
 hw/xfree86/shadowfb/Makefile.am       |    3 ++-
 xorg-server.pc.in                     |    2 +-
 14 files changed, 99 insertions(+), 24 deletions(-)
Alan Coopersmith - March 29, 2012, 3:19 a.m.
On 03/27/12 10:16 PM, Yaakov (Cygwin/X) wrote:
> From: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
> 
> As a PE platform, all symbols in both EXEs and DLLs must be resolved
> at link time.  As Xorg modules depend on symbols in the Xorg
> executable, we must build Xorg before its modules, creating an implib
> from the former which is used to link the latter.  This implib must
> then be installed in order to build the drivers.

I do something similar when building X11 for Solaris packaging, in order
to catch ABI issues such as missing symbols at build time instead of run
time, and this patch will make it easier for me to do that with all the
modules, while now it mostly just checks drivers due to build ordering.

> +
> +i2c/libi2c.la:
> +	$(MAKE) -C $(@D) $(@F)
> +
> +dixmods/libdixmods.la:
> +	$(MAKE) -C $(@D) $(@F)
> +
> +dixmods/libxorgxkb.la:
> +	$(MAKE) -C $(@D) $(@F)

Should those be $(MAKE) $(AM_MAKEFLAGS) ... ?  That's what most automake calls
seem to use.

Also -C is a gnu make specific flag, but I think we still require GNU make
to build the server due to other issues anyway.

> -libfb_la_LDFLAGS = -module -avoid-version
> +libfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
>  libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
>  libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
>  libfb_la_CFLAGS = $(AM_CFLAGS)

BTW, in my patch in the Solaris tree, I have:
+libfb_la_LIBADD += -lpixman-1

> +if CYGWIN
> +libshadow_la_LIBADD += libfb.la
> +endif

I currently patch that in on Solaris too, so would appreciate finding a more
common name than if CYGWIN for this.

The current work in progress from our branch to get 1.12 ready to merge in:
http://src.opensolaris.org/source/xref/fox/Xorg-1.12-merge/open-src/xserver/xorg/dixmods-deps.patch


> diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
> index 72e5713..5d59e8d 100644
> --- a/hw/xfree86/man/xorg.conf.man
> +++ b/hw/xfree86/man/xorg.conf.man
> @@ -701,7 +701,8 @@ This instructs the server to load the module called
>  The module name given should be the module's standard name, not the
>  module file name.
>  The standard name is case\-sensitive, and does not include the \(lqlib\(rq
> -prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
> +or \(lqcyg\(rq prefixes, or the \(lq.a\(rq, \(lq.o\(rq, \(lq.dll\(rq,
> +or \(lq.so\(rq suffixes.

We can probably remove .o & .a from that list now that the old elfloader is gone.
Yaakov Selkowitz - March 29, 2012, 4:05 a.m.
On 2012-03-28 22:19, Alan Coopersmith wrote:
> On 03/27/12 10:16 PM, Yaakov (Cygwin/X) wrote:
>> As a PE platform, all symbols in both EXEs and DLLs must be resolved
>> at link time.  As Xorg modules depend on symbols in the Xorg
>> executable, we must build Xorg before its modules, creating an implib
>> from the former which is used to link the latter.  This implib must
>> then be installed in order to build the drivers.
>
> I do something similar when building X11 for Solaris packaging, in order
> to catch ABI issues such as missing symbols at build time instead of run
> time, and this patch will make it easier for me to do that with all the
> modules, while now it mostly just checks drivers due to build ordering.
>
>> +
>> +i2c/libi2c.la:
>> +	$(MAKE) -C $(@D) $(@F)
>> +
>> +dixmods/libdixmods.la:
>> +	$(MAKE) -C $(@D) $(@F)
>> +
>> +dixmods/libxorgxkb.la:
>> +	$(MAKE) -C $(@D) $(@F)
>
> Should those be $(MAKE) $(AM_MAKEFLAGS) ... ?  That's what most automake calls
> seem to use.
> Also -C is a gnu make specific flag, but I think we still require GNU make
> to build the server due to other issues anyway.

$(MAKE) -C is already used in the top-level Makefile, hw/Makefile, and 
hw/kdrive/Makefile.  But now that you mention it, I see that I forgot 
the $(AM_V_at).

> BTW, in my patch in the Solaris tree, I have:
> +libfb_la_LIBADD += -lpixman-1

That's not necessary with recent libtools; the DIX fb/libfb.la is 
already linked with $(PIXMAN_LIBS).

>> +if CYGWIN
>> +libshadow_la_LIBADD += libfb.la
>> +endif
>
> I currently patch that in on Solaris too, so would appreciate finding a more
> common name than if CYGWIN for this.

How about NO_UNDEFINED?

> The current work in progress from our branch to get 1.12 ready to merge in:
> http://src.opensolaris.org/source/xref/fox/Xorg-1.12-merge/open-src/xserver/xorg/dixmods-deps.patch

Thanks, I'll incorporate what I can from there.

>> -prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
>> +or \(lqcyg\(rq prefixes, or the \(lq.a\(rq, \(lq.o\(rq, \(lq.dll\(rq,
>> +or \(lq.so\(rq suffixes.
>
> We can probably remove .o&  .a from that list now that the old elfloader is gone.

OK, I'll get that when I respin these patches.


Yaakov
Mark Kettenis - March 29, 2012, 6:33 a.m.
> Date: Wed, 28 Mar 2012 23:05:51 -0500
> From: "Yaakov (Cygwin/X)" <yselkowitz@users.sourceforge.net>
> 
> On 2012-03-28 22:19, Alan Coopersmith wrote:
> > On 03/27/12 10:16 PM, Yaakov (Cygwin/X) wrote:
> >> +
> >> +i2c/libi2c.la:
> >> +	$(MAKE) -C $(@D) $(@F)
> >> +
> >> +dixmods/libdixmods.la:
> >> +	$(MAKE) -C $(@D) $(@F)
> >> +
> >> +dixmods/libxorgxkb.la:
> >> +	$(MAKE) -C $(@D) $(@F)
> >
> > Should those be $(MAKE) $(AM_MAKEFLAGS) ... ?  That's what most automake calls
> > seem to use.
> > Also -C is a gnu make specific flag, but I think we still require GNU make
> > to build the server due to other issues anyway.

The server builds fine with (Open)BSD make, and we'd like to keep it
that way.  And it doesn't support -C.
> 
> $(MAKE) -C is already used in the top-level Makefile, hw/Makefile, and 
> hw/kdrive/Makefile.  But now that you mention it, I see that I forgot 
> the $(AM_V_at).

It's only used for the "relink" target, which isn't actually used for
a normal build.  And it bears a "gross hack" comment in the toplevel
Makefile.  Can you solve this in a different way?  Or perhaps explain
the problem you're trying to solve?  Including "." in SUBDIRS seems
like a gross hack to me as well.
Yaakov Selkowitz - March 29, 2012, 6:58 a.m.
On 2012-03-29 01:33, Mark Kettenis wrote:
> The server builds fine with (Open)BSD make, and we'd like to keep it
> that way.  And it doesn't support -C.

Sigh.  I guess I'll have to spell it out then.

> Or perhaps explain the problem you're trying to solve?

Those directories include both convenience libs which go into Xorg 
itself, and modules which (on Cygwin) need to be built after Xorg.

> Including "." in SUBDIRS seems like a gross hack to me as well.

Building Xorg in Cygwin is the "gross hack", so that's par for the 
course. :-)


Yaakov
Alan Coopersmith - March 29, 2012, 5:42 p.m.
On 03/28/12 11:33 PM, Mark Kettenis wrote:
>> Date: Wed, 28 Mar 2012 23:05:51 -0500
>> From: "Yaakov (Cygwin/X)" <yselkowitz@users.sourceforge.net>
>>
>> On 2012-03-28 22:19, Alan Coopersmith wrote:
>>> On 03/27/12 10:16 PM, Yaakov (Cygwin/X) wrote:
>>>> +
>>>> +i2c/libi2c.la:
>>>> +	$(MAKE) -C $(@D) $(@F)
>>>> +
>>>> +dixmods/libdixmods.la:
>>>> +	$(MAKE) -C $(@D) $(@F)
>>>> +
>>>> +dixmods/libxorgxkb.la:
>>>> +	$(MAKE) -C $(@D) $(@F)
>>>
>>> Should those be $(MAKE) $(AM_MAKEFLAGS) ... ?  That's what most automake calls
>>> seem to use.
>>> Also -C is a gnu make specific flag, but I think we still require GNU make
>>> to build the server due to other issues anyway.
> 
> The server builds fine with (Open)BSD make, and we'd like to keep it
> that way.  And it doesn't support -C.

I can see the attraction of not having to fork another shell just for evaluating
"cd $(@D) ; $(MAKE) $(@F)", so we should probably work on getting it added
to our non-GNU make utilities for the future, but that doesn't help short term.

> Including "." in SUBDIRS seems like a gross hack to me as well.

It's the documented solution in the automake manual though, so hardly more
gross than automake itself:

https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html#Subdirectories

Patch

diff --git a/configure.ac b/configure.ac
index 65d29f2..33376f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -699,11 +699,21 @@  dnl DDX Detection... Yes, it's ugly to have it here... but we need to
 dnl handle this early on so that we don't require unsupported extensions
 case $host_os in
 	cygwin*)
+		CONFIG_DBUS_API=no
+		CONFIG_HAL=no
+		CONFIG_UDEV=no
 		DGA=no
 		DRI2=no
+		INT10MODULE=no
+		PCI=no
+		VGAHW=no
+		VBE=no
+		XAA=no
+		XF86UTILS=no
 		XF86VIDMODE=no
 		XSELINUX=no
 		XV=no
+		SYMBOL_VISIBILITY=no
 		;;
 	darwin*)
 		PCI=no
@@ -1060,6 +1070,7 @@  if test "x$GLX_USE_TLS" = xyes ; then
 	GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
 fi
 AC_SUBST([GLX_DEFINES])
+AC_SUBST([GLX_SYS_LIBS])
 
 AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
 if test "x$DRI" = xyes; then
@@ -1461,7 +1472,20 @@  AC_SUBST([UTILS_SYS_LIBS])
 # Some platforms require extra flags to do this.   libtool should set the
 # necessary flags for each platform when -export-dynamic is passed to it.
 LD_EXPORT_SYMBOLS_FLAG="-export-dynamic"
+LD_NO_UNDEFINED_FLAG=
+XORG_MODULE_LIBS=
+case "$host_os" in
+    cygwin*)
+	LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-all,--out-implib,lib\$@.a"
+	LD_NO_UNDEFINED_FLAG="-no-undefined -Wl,\$(top_builddir)/hw/xfree86/libXorg.exe.a"
+	XORG_MODULE_LIBS="-lXorg.exe -L\${moduledir} -lshadow -lfb -no-undefined"
+	CYGWIN=yes
+	;;
+esac
 AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
+AC_SUBST([LD_NO_UNDEFINED_FLAG])
+AC_SUBST([XORG_MODULE_LIBS])
+AM_CONDITIONAL([CYGWIN], [test x"$CYGWIN" = xyes])
 
 dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
 dnl we need to replicate that here until those can all be fixed
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 72be889..c4b7da3 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -25,9 +25,9 @@  if INT10MODULE
 INT10_SUBDIR = int10
 endif
 
-SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw os-support parser \
-	  ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
-	  loader dixmods exa modes \
+SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
+	  ramdac $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
+	  loader modes . i2c dixmods fbdevhw shadowfb exa \
 	  $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man
 
 DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
@@ -92,6 +92,9 @@  if INSTALL_SETUID
 	chown root $(DESTDIR)$(bindir)/Xorg
 	chmod u+s $(DESTDIR)$(bindir)/Xorg
 endif
+if CYGWIN
+	$(INSTALL_DATA) libXorg.exe.a $(DESTDIR)$(libdir)/libXorg.exe.a
+endif
 
 # Use variables from XORG_MANPAGE_SECTIONS and X Server configuration
 # Do not include manpages.am as values are not appropriate for rc files
@@ -113,3 +116,12 @@  sdksyms.dep sdksyms.c: sdksyms.sh
 
 SDKSYMS_DEP = sdksyms.dep
 include $(SDKSYMS_DEP)
+
+i2c/libi2c.la:
+	$(MAKE) -C $(@D) $(@F)
+
+dixmods/libdixmods.la:
+	$(MAKE) -C $(@D) $(@F)
+
+dixmods/libxorgxkb.la:
+	$(MAKE) -C $(@D) $(@F)
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index ec679df..b22b617 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -125,6 +125,11 @@  static ModuleDefault ModuleDefaults[] = {
 #ifdef DRI2
     {.name = "dri2",.toLoad = TRUE,.load_opt = NULL},
 #endif
+#ifdef __CYGWIN__
+    /* load DIX modules used by drivers first */
+    {.name = "fb",.toLoad = TRUE,.load_opt = NULL},
+    {.name = "shadow",.toLoad = TRUE,.load_opt = NULL},
+#endif
     {.name = NULL,.toLoad = FALSE,.load_opt = NULL}
 };
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 2a7d0a3..f42dd10 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1580,3 +1580,10 @@  xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
     else
         return 0;
 }
+
+#ifdef DDXBEFORERESET
+void
+ddxBeforeReset(void)
+{
+}
+#endif
diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index a5be3ae..4af9629 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -30,35 +30,39 @@  INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/miext/shadow \
            -I$(top_srcdir)/glx
 
-libdbe_la_LDFLAGS = -module -avoid-version
+libdbe_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
 libdbe_la_SOURCES = dbemodule.c
 
-libfb_la_LDFLAGS = -module -avoid-version
+libfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
 libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libfb_la_CFLAGS = $(AM_CFLAGS)
 
-libwfb_la_LDFLAGS = -module -avoid-version
+libwfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
 libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
-libglx_la_LDFLAGS = -module -avoid-version
+libglx_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 if AIGLX_DRI_LOADER
 GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
 endif
 libglx_la_LIBADD = \
 	$(top_builddir)/glx/libglx.la \
+	$(GLX_SYS_LIBS) \
 	$(GLXDRI_LIBRARY)
 libglx_la_SOURCES = glxmodule.c
 
-librecord_la_LDFLAGS = -module -avoid-version
+librecord_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 librecord_la_LIBADD = $(top_builddir)/record/librecord.la
 librecord_la_SOURCES = recordmod.c
 
-libshadow_la_LDFLAGS = -module -avoid-version
+libshadow_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
+if CYGWIN
+libshadow_la_LIBADD += libfb.la
+endif
 libshadow_la_SOURCES = shmodule.c
 
 libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c
diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am
index 87c28a4..d08e9ad 100644
--- a/hw/xfree86/dixmods/extmod/Makefile.am
+++ b/hw/xfree86/dixmods/extmod/Makefile.am
@@ -21,7 +21,7 @@  INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/hw/xfree86/loader \
            -I$(top_srcdir)/miext/shadow
 
-libextmod_la_LDFLAGS = -module -avoid-version
+libextmod_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libextmod_la_SOURCES = modinit.c \
                        modinit.h \
                        $(DGA_SRCS) \
diff --git a/hw/xfree86/exa/Makefile.am b/hw/xfree86/exa/Makefile.am
index 3ced531..4339084 100644
--- a/hw/xfree86/exa/Makefile.am
+++ b/hw/xfree86/exa/Makefile.am
@@ -2,7 +2,7 @@  SUBDIRS = man
 
 module_LTLIBRARIES = libexa.la
 
-libexa_la_LDFLAGS = -module -avoid-version
+libexa_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 
 INCLUDES = \
 	$(XORG_INCS) \
@@ -15,4 +15,4 @@  libexa_la_SOURCES = \
 	examodule.c
 
 libexa_la_LIBADD = \
-	../../../exa/libexa.la
+	../../../exa/libexa.la $(PIXMAN_LIBS)
diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am
index 4472acd..1fa9321 100644
--- a/hw/xfree86/fbdevhw/Makefile.am
+++ b/hw/xfree86/fbdevhw/Makefile.am
@@ -2,7 +2,7 @@  SUBDIRS = man
 
 module_LTLIBRARIES = libfbdevhw.la
 
-libfbdevhw_la_LDFLAGS = -module -avoid-version
+libfbdevhw_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 
 if FBDEVHW
 libfbdevhw_la_SOURCES = fbdevhw.c
diff --git a/hw/xfree86/i2c/Makefile.am b/hw/xfree86/i2c/Makefile.am
index 0b80cc8..36a4be5 100644
--- a/hw/xfree86/i2c/Makefile.am
+++ b/hw/xfree86/i2c/Makefile.am
@@ -21,23 +21,26 @@  sdk_HEADERS = xf86i2c.h bt829.h fi1236.h msp3430.h tda8425.h tda9850.h tda9885.h
 #
 # i2c drivers
 #
-bt829_drv_la_LDFLAGS = -module -avoid-version
+bt829_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 bt829_drv_la_SOURCES = bt829.c bt829.h bt829_module.c
 
-fi1236_drv_la_LDFLAGS = -module -avoid-version
+fi1236_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 fi1236_drv_la_SOURCES = fi1236.c fi1236.h fi1236_module.c
+if CYGWIN
+fi1236_drv_la_LIBADD = tda9885_drv.la
+endif
 
-msp3430_drv_la_LDFLAGS = -module -avoid-version
+msp3430_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 msp3430_drv_la_SOURCES = msp3430.c msp3430.h msp3430_module.c
 
-tda8425_drv_la_LDFLAGS = -module -avoid-version
+tda8425_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 tda8425_drv_la_SOURCES = tda8425.c tda8425.h tda8425_module.c
 
-tda9850_drv_la_LDFLAGS = -module -avoid-version
+tda9850_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 tda9850_drv_la_SOURCES = tda9850.c tda9850.h tda9850_module.c
 
-tda9885_drv_la_LDFLAGS = -module -avoid-version
+tda9885_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 tda9885_drv_la_SOURCES = tda9885.c tda9885.h tda9885_module.c
 
-uda1380_drv_la_LDFLAGS = -module -avoid-version
+uda1380_drv_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 uda1380_drv_la_SOURCES = uda1380.c uda1380.h uda1380_module.c
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index c6b5590..706b9b3 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -212,9 +212,15 @@  static const char *stdSubdirs[] = {
  * to port this DDX to, say, Darwin, we'll need to fix this.
  */
 static PatternRec stdPatterns[] = {
+#ifdef __CYGWIN__
+    {"^cyg(.*)\\.dll$",},
+    {"(.*)_drv\\.dll$",},
+    {"(.*)\\.dll$",},
+#else
     {"^lib(.*)\\.so$",},
     {"(.*)_drv\\.so$",},
     {"(.*)\\.so$",},
+#endif
     {NULL,}
 };
 
@@ -408,21 +414,33 @@  FindModuleInSubdir(const char *dirpath, const char *module)
             continue;
         }
 
+#ifdef __CYGWIN__
+        snprintf(tmpBuf, PATH_MAX, "cyg%s.dll", module);
+#else
         snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
+#endif
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
             if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
                 ret = NULL;
             break;
         }
 
+#ifdef __CYGWIN__
+        snprintf(tmpBuf, PATH_MAX, "%s_drv.dll", module);
+#else
         snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
+#endif
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
             if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
                 ret = NULL;
             break;
         }
 
+#ifdef __CYGWIN__
+        snprintf(tmpBuf, PATH_MAX, "%s.dll", module);
+#else
         snprintf(tmpBuf, PATH_MAX, "%s.so", module);
+#endif
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
             if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
                 ret = NULL;
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 72e5713..5d59e8d 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -701,7 +701,8 @@  This instructs the server to load the module called
 The module name given should be the module's standard name, not the
 module file name.
 The standard name is case\-sensitive, and does not include the \(lqlib\(rq
-prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
+or \(lqcyg\(rq prefixes, or the \(lq.a\(rq, \(lq.o\(rq, \(lq.dll\(rq,
+or \(lq.so\(rq suffixes.
 .PP
 .RS 7
 Example: the DRI extension module can be loaded with the following entry:
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 9161e18..e931b09 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -171,7 +171,7 @@ 
 /**************************************************************************/
 /* Linux or Glibc-based system                                            */
 /**************************************************************************/
-#if defined(__linux__) || defined(__GLIBC__)
+#if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__)
 #include <sys/ioctl.h>
 #include <signal.h>
 #include <stdlib.h>
diff --git a/hw/xfree86/shadowfb/Makefile.am b/hw/xfree86/shadowfb/Makefile.am
index 39c6610..5756fca 100644
--- a/hw/xfree86/shadowfb/Makefile.am
+++ b/hw/xfree86/shadowfb/Makefile.am
@@ -1,6 +1,7 @@ 
 module_LTLIBRARIES = libshadowfb.la
-libshadowfb_la_LDFLAGS = -module -avoid-version
+libshadowfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG)
 libshadowfb_la_SOURCES = sfbmodule.c shadow.c
+libshadowfb_la_LIBADD = $(PIXMAN_LIBS)
 
 sdk_HEADERS = shadowfb.h
 
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index a98eca8..a3a9085 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -17,4 +17,4 @@  Description: Modular X.Org X Server
 Version: @PACKAGE_VERSION@
 Requires.private: @SDK_REQUIRED_MODULES@
 Cflags: -I${sdkdir} @symbol_visibility@
-Libs: -L${libdir}
+Libs: -L${libdir} @XORG_MODULE_LIBS@