From d4f0809339359969e031353b079851d90cd89b3c Mon Sep 17 00:00:00 2001
Package: xf86-video-glide
Version: 1.0.0
From: Guillem Jover <guillem@hadrons.org>
Date: Fri, 9 Feb 2007 04:00:53 +0200
Status: applied
Subject: [PATCH] Modularize xf86-video-glide

---
 Makefile.am        |   22 +++++++++++++
 autogen.sh         |   12 +++++++
 configure.ac       |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/Makefile.am    |   60 ++++++++++++++++++++++++++++++++++++
 man/glide.man      |   19 ++++++-----
 src/Makefile.am    |   33 ++++++++++++++++++++
 src/glide_driver.c |   14 ++++----
 7 files changed, 230 insertions(+), 16 deletions(-)

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..7052905
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,22 @@
+#  Copyright 2005 Adam Jackson.
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  on the rights to use, copy, modify, merge, publish, distribute, sub
+#  license, and/or sell copies of the Software, and to permit persons to whom
+#  the Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice (including the next
+#  paragraph) shall be included in all copies or substantial portions of the
+#  Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+#  ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+#  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+#  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AUTOMAKE_OPTIONS = foreign
+SUBDIRS = src man
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..904cd67
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..59c8f09
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,86 @@
+#  Copyright 2005 Adam Jackson.
+#  Copyright 2007 Guillem Jover.
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  on the rights to use, copy, modify, merge, publish, distribute, sub
+#  license, and/or sell copies of the Software, and to permit persons to whom
+#  the Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice (including the next
+#  paragraph) shall be included in all copies or substantial portions of the
+#  Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+#  ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+#  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+#  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Process this file with autoconf to produce a configure script
+
+AC_PREREQ(2.57)
+AC_INIT([xf86-video-glide],
+        1.0.0,
+        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+        xf86-video-glide)
+
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_CONFIG_HEADER([config.h])
+AC_CONFIG_AUX_DIR(.)
+
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+AM_MAINTAINER_MODE
+
+# Checks for programs.
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_PROG_CC
+
+AH_TOP([#include "xorg-server.h"])
+
+AC_ARG_WITH(xorg-module-dir,
+            AC_HELP_STRING([--with-xorg-module-dir=DIR],
+                           [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+            [moduledir="$withval"],
+            [moduledir="$libdir/xorg/modules"])
+
+AC_ARG_WITH(glide-include-dir,
+            AC_HELP_STRING([--with-glide-include-dir=DIR],
+                           [Default Glide include directory [[default=$includedir/glide]]]),
+            [glideincludedir="$withval"],
+            [glideincludedir="$includedir/glide"])
+
+# Checks for extensions
+XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+# Checks for pkg-config packages
+PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
+sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+
+GLIDE_CFLAGS="-I$glideincludedir"
+AC_SUBST([GLIDE_CFLAGS])
+AC_SUBST([XORG_CFLAGS])
+AC_SUBST([moduledir])
+
+DRIVER_NAME=glide
+AC_SUBST([DRIVER_NAME])
+
+XORG_MANPAGE_SECTIONS
+XORG_RELEASE_VERSION
+
+AC_OUTPUT([
+	Makefile
+	src/Makefile
+	man/Makefile
+])
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644
index 0000000..f7e6783
--- /dev/null
+++ b/man/Makefile.am
@@ -0,0 +1,60 @@
+# $Id$
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# 
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation.
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name of the copyright holders shall
+# not be used in advertising or otherwise to promote the sale, use or
+# other dealings in this Software without prior written authorization
+# from the copyright holders.
+# 
+
+drivermandir = $(DRIVER_MAN_DIR)
+
+driverman_PRE = @DRIVER_NAME@.man
+
+driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
+
+EXTRA_DIST = @DRIVER_NAME@.man
+
+CLEANFILES = $(driverman_DATA)
+
+SED = sed
+
+# Strings to replace in man pages
+XORGRELSTRING = @PACKAGE_STRING@
+  XORGMANNAME = X Version 11
+
+MAN_SUBSTS = \
+	-e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
+	-e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
+	-e 's|__xservername__|Xorg|g' \
+	-e 's|__xconfigfile__|xorg.conf|g' \
+	-e 's|__projectroot__|$(prefix)|g' \
+	-e 's|__moduledir__|$(moduledir)|g' \
+	-e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \
+	-e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \
+	-e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \
+	-e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \
+	-e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g'
+
+SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+.man.$(DRIVER_MAN_SUFFIX):
+	sed $(MAN_SUBSTS) < $< > $@
diff --git a/man/glide.man b/man/glide.man
index bf3e78f..6c970e4 100644
--- a/man/glide.man
+++ b/man/glide.man
@@ -18,7 +18,7 @@ before it will work: You need Glide installed and you need to make a link for th
 file. Read the second paragraph in the description below to find out how.
 .SH DESCRIPTION
 .B glide 
-is an XFree86 driver for Glide capable video boards (such as 3Dfx
+is an __xservername__ driver for Glide capable video boards (such as 3Dfx
 Voodoo boards). This driver is mainly for Voodoo 1 and Voodoo 2 boards, later
 boards from 3Dfx have 2D built-in and you should preferably use a driver separate for
 those boards or the fbdev(__drivermansuffix__) driver.
@@ -34,13 +34,12 @@ data, we get very good speed anyway, especially since the whole shadow
 framebuffer is in cached RAM.
 .PP
 This driver requires that you have installed Glide. (Which can, at the
-time of this writing, be found at
-http://glide.xxedgexx.com/3DfxRPMS.html). Also, you need to tell
-XFree86 where the libglide2x.so file is placed by making a soft link
-in the /usr/X11R6/lib/modules directory that points to the libglide2x.so
+time of this writing, be found at http://glide.sf.net/). Also, you need
+to tell __xservername__ here the libglide2x.so file is placed by making
+a soft link in the __moduledir__ directory that points to the libglide2x.so
 file. For example (if your libglide2x.so file is in /usr/lib):
 .PP
-\&  # ln -s /usr/lib/libglide2x.so /usr/X11R6/lib/modules
+\&  # ln -s /usr/lib/libglide2x.so __moduledir__
 .PP
 If you have installed /dev/3dfx, the driver will be able to turn on
 the MTRR registers (through the glide library) if you have a CPU with
@@ -121,7 +120,7 @@ The
 .B glide
 driver supports any board that can be used with Glide (such as 3Dfx Voodoo boards)
 .SH CONFIGURATION DETAILS
-Please refer to XF86Config(__filemansuffix__) for general configuration
+Please refer to __xconfigfile__(__filemansuffix__) for general configuration
 details.  This section only covers configuration details specific to this
 driver.
 .PP
@@ -141,7 +140,7 @@ The value should be 0 for the first board, 1 for the second and so on.
 If it is not present, the first Voodoo board found will be selected.
 Put this option in the Device section.
 .SH "EXAMPLE"
-Here is an example of a part of an XF86Config file that uses a multihead
+Here is an example of a part of an __xconfigfile__ file that uses a multihead
 configuration with two monitors. The first monitor is driven by the
 fbdev video driver and the second monitor is driven by the glide
 driver.
@@ -292,7 +291,9 @@ overlap from one monitor to the other. Starting the X server with the
 Xinerama extension can be done for example like this:
 .PP
 $ xinit -- +xinerama
+.SH FILES
+glide_drv.o
 .SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
 .SH AUTHORS
 Author: Henrik Harmsen.
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..9542fbb
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,33 @@
+#  Copyright 2005 Adam Jackson.
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  on the rights to use, copy, modify, merge, publish, distribute, sub
+#  license, and/or sell copies of the Software, and to permit persons to whom
+#  the Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice (including the next
+#  paragraph) shall be included in all copies or substantial portions of the
+#  Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+#  ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+#  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+#  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# this is obnoxious:
+# -module lets us name the module exactly how we want
+# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
+# _ladir passes a dummy rpath to libtool so the thing will actually link
+# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+AM_CFLAGS = @XORG_CFLAGS@ @GLIDE_CFLAGS@ -DMODULEDIR=\""@moduledir@\""
+glide_drv_la_LTLIBRARIES = glide_drv.la
+glide_drv_la_LDFLAGS = -module -avoid-version
+glide_drv_ladir = @moduledir@/drivers
+
+glide_drv_la_SOURCES = \
+         glide_driver.c
+
diff --git a/src/glide_driver.c b/src/glide_driver.c
index 86652fa..e51e9a1 100644
--- a/src/glide_driver.c
+++ b/src/glide_driver.c
@@ -163,7 +163,7 @@ static void	GLIDEDisplayPowerManagementSet(ScrnInfoPtr pScrn,
 
 static int LoadGlide(void);
 
-#define VERSION 4000
+#define GLIDE_VERSION 4000
 #define GLIDE_NAME "GLIDE"
 #define GLIDE_DRIVER_NAME "glide"
 #define GLIDE_MAJOR_VERSION 1
@@ -179,7 +179,7 @@ static int LoadGlide(void);
  */
 
 _X_EXPORT DriverRec GLIDE = {
-  VERSION,
+  GLIDE_VERSION,
   GLIDE_DRIVER_NAME,
   GLIDEIdentify,
   GLIDEProbe,
@@ -268,13 +268,13 @@ glideSetup(pointer module, pointer opts, int *errmaj, int *errmin)
 "\n"
 "Could not load the shared library file for Glide: \"libglide2x.so\"! \n"
 "\n"
-"You need to have Glide installed to run the glide driver for XFree86.\n"
-"Also, you need to tell XFree86 where the libglide2x.so file is placed\n"
-"by making a soft link in the /usr/X11R6/lib/modules directory that points\n"
+"You need to have Glide installed to run the glide driver for X.Org.\n"
+"Also, you need to tell X.Org where the libglide2x.so file is placed\n"
+"by making a soft link in the " MODULEDIR " directory that points\n"
 "to the libglide2x.so file. For example (if your libglide2x.so file is in\n"
 "/usr/lib):\n"
 "\n"
-"  # ln -s /usr/lib/libglide2x.so /usr/X11R6/lib/modules\n"
+"  # ln -s /usr/lib/libglide2x.so " MODULEDIR "\n"
 "\n"
 "\n");
       if (errmaj)
@@ -412,7 +412,7 @@ GLIDEProbe(DriverPtr drv, int flags)
 	    /* XXX Need to see how this fits in with the new RAC */
 	    
 	    /* Fill in what we can of the ScrnInfoRec */
-	    pScrn->driverVersion = VERSION;
+	    pScrn->driverVersion = GLIDE_VERSION;
 	    pScrn->driverName    = GLIDE_DRIVER_NAME;
 	    pScrn->name          = GLIDE_NAME;
 	    pScrn->Probe	 = GLIDEProbe;
-- 
1.4.4.4

