Subject: Proposal: Xserver loadable modules for MIPS
To: None <tech-x11@netbsd.org, port-sgimips@netbsd.org>
From: Christopher SEKIYA <wileyc@rezrov.net>
List: port-sgimips
Date: 07/11/2004 08:33:31
All,

The XFree86 server, as we ship it, does not contain support for loadable modules
on MIPS platforms.  Unfortunately, our build scheme does not like builds that
don't use loadable modules with that server, which results in an inability to
create a working X server for (at least) sgimips in a cross-build environment.

The XFree86 module loader was originally written to provide dlopen()-like
functionality on platforms that didn't have dlopen().  It will happily
load the driver "foo" from libfoo.so via dlopen() so long as libfoo.a is
absent.

To that end, appended is a patch that does the right thing for sgimips.  I'd
like to commit it (or something very much like it) in time for the 2.0 release.
The X setlists for affected platforms will have to be adjusted, of course.

Comments?

-- Chris
	GPG key FEB9DE7F (91AF 4534 4529 4BCC 31A5  938E 023E EEFB FEB9 DE7F)

Index: share/mk/bsd.x11.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.x11.mk,v
retrieving revision 1.38.2.2
diff -u -r1.38.2.2 bsd.x11.mk
--- share/mk/bsd.x11.mk	11 May 2004 13:22:09 -0000	1.38.2.2
+++ share/mk/bsd.x11.mk	10 Jul 2004 23:20:15 -0000
@@ -70,7 +70,8 @@
 .if ${MACHINE} == "amd64"	|| \
     ${MACHINE} == "cats"	|| \
     ${MACHINE} == "i386"	|| \
-    ${MACHINE} == "macppc"
+    ${MACHINE} == "macppc"	|| \
+    ${MACHINE} == "sgimips"
 #	LOADABLE
 X11FLAGS.LOADABLE=	-DXFree86LOADER -DIN_MODULE -DXFree86Module
 .endif
Index: x11/Xserver/Makefile.serverlib
===================================================================
RCS file: /cvsroot/src/x11/Xserver/Makefile.serverlib,v
retrieving revision 1.5
diff -u -r1.5 Makefile.serverlib
--- x11/Xserver/Makefile.serverlib	7 Feb 2004 06:52:04 -0000	1.5
+++ x11/Xserver/Makefile.serverlib	10 Jul 2004 23:20:34 -0000
@@ -1,9 +1,14 @@
 #	$NetBSD: Makefile.serverlib,v 1.5 2004/02/07 06:52:04 lukem Exp $
 
 NOLINT=         1
-NOPIC=          1
 NOPROFILE=      1
 
+.if ${MACHINE_ARCH} != "mipseb" && ${MACHINE_ARCH} != "mipsel"
+.if !defined(XMODULEDIR)
+NOPIC=		1
+.endif
+.endif
+
 .include <bsd.own.mk>		# for NETBSDSRCDIR
 .include <bsd.endian.mk>
 
@@ -26,6 +31,16 @@
 .MAKEOVERRIDES+=XSERVERINCDIR
 .endif
 
+# Architectures that can't use the XFree86 loader (such as MIPS) can use
+# dlopen() to load modules.
+
 .if defined(XMODULEDIR)
 CPPFLAGS+=	${X11FLAGS.LOADABLE}
+.if ${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel"
+SHLIB_MAJOR=	0
+SHLIB_MINOR=	0
+MKPICLIB=	yes
+MKSTATICLIB=	no
+.endif
+.else
 .endif
Index: x11/Xserver/hw/xfree86/Makefile.drivermod
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/Makefile.drivermod,v
retrieving revision 1.3
diff -u -r1.3 Makefile.drivermod
--- x11/Xserver/hw/xfree86/Makefile.drivermod	6 Mar 2004 03:31:06 -0000	1.3
+++ x11/Xserver/hw/xfree86/Makefile.drivermod	10 Jul 2004 23:20:59 -0000
@@ -1,8 +1,12 @@
 # $NetBSD: Makefile.drivermod,v 1.3 2004/03/06 03:31:06 rtr Exp $
 
-# XXX this is a really bad hack to install an archive as a .o
 LIB=${MODULE}
 
+# XXX this is a really bad hack to install an archive as a .o
+# This hack is not required for targets that use the dlopen() module scheme.
+
+.if ${MACHINE_ARCH} != "mipseb" && ${MACHINE_ARCH} != "mipsel"
+
 __archivebuild: .USE
 	${_MKTARGET_BUILD}
 	rm -rf ${.TARGET}
@@ -13,4 +17,6 @@
 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
 	    ${SYSPKGTAG} ${.ALLSRC} ${DESTDIR}${LIBDIR}/${MODULE}.o
 
+.endif
+
 .include <bsd.lib.mk>
Index: x11/Xserver/hw/xfree86/drivers/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/drivers/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- x11/Xserver/hw/xfree86/drivers/Makefile	14 Mar 2004 17:01:10 -0000	1.7
+++ x11/Xserver/hw/xfree86/drivers/Makefile	10 Jul 2004 23:20:59 -0000
@@ -13,7 +13,7 @@
 .endif
 
 .if ${MACHINE} == "sgimips"
-SUBDIR+=	newport
+SUBDIR=	newport
 .endif
 
 .include <bsd.subdir.mk>