Submitted By:            Randy McMurchy <randy_at_linuxfromscratch_dot_org>
Date:                    2011-01-18
Initial Package Version: 1.9.25
Upstream Status:         Unknown
Origin:                  Combination of different patches from all over the Internet
Description:             Patches build breakage, toolchain updates, and some enhancements
                         I am not sure why anyone would even use this old library, however


diff -Naur svgalib-1.9.25-orig/Makefile svgalib-1.9.25/Makefile
--- svgalib-1.9.25-orig/Makefile	2006-07-14 11:42:59.000000000 +0000
+++ svgalib-1.9.25/Makefile	2010-12-13 19:13:46.000000000 +0000
@@ -97,9 +97,9 @@
 	@for foo in $(notdir $(SHAREDLIBS)); do \
 		$(INSTALL_SHLIB) sharedlib/$$foo $(sharedlibdir)/$$foo; \
 		(cd $(sharedlibdir); \
-		 ln -sf $$foo `echo $$foo | sed 's/\.so\..*/.so/'` ); \
+		 ln -sf $$foo `echo $$foo | sed 's/\.so\..*/.so/'` ; \
+		 ln -sf $$foo `echo $$foo | sed 's/\.so\..*/.so.1/'` ); \
 	done
-	@./fixldsoconf
 	-ldconfig
 
 installstaticlib: static
@@ -180,15 +180,26 @@
 installmodule.alt:
 	(cd kernel/svgalib_helper ; $(MAKE) -f Makefile.alt modules_install )
 
-installdev:
-	(cd kernel/svgalib_helper ; $(MAKE) device )
-
 lib3dkit-install:
 	(cd threeDKit/; $(MAKE) install)
-	 
+
+udev-rules-install:
+	@echo "Installing Udev rules..."
+	@$(INSTALL_DIR) $(rulesdir)
+	@$(INSTALL_DATA) src/udev/56-svga.rules $(rulesdir)
+ 
+docs-install:
+	@echo "Installing documentation..."
+	@$(INSTALL_DIR) $(docdir)
+	@$(INSTALL_DATA) 0-README README doc/0-INSTALL doc/CHANGES doc/DESIGN \
+	doc/Driver-programming-HOWTO doc/README.joystick doc/README.keymap \
+	doc/README.multi-monitor doc/README.patching doc/README.vesa doc/TODO \
+	doc/add_driver doc/dual-head-howto $(docdir)
+	@$(INSTALL_DATA) lrmi-0.6m/README $(docdir)/README.lrmi
+ 
 install: installheaders $(INSTALLSHAREDLIB) installconfig \
-	$(INSTALLSTATICLIB) $(INSTALLUTILS) $(INSTALLMAN) $(INSTALLMODULE) $(INSTALLDEV) \
-	lib3dkit-install
+	$(INSTALLSTATICLIB) $(INSTALLUTILS) $(INSTALLMAN) $(INSTALLMODULE) \
+	lib3dkit-install udev-rules-install docs-install
 	@echo
 	@echo
 	@echo Now run "'make demoprogs'" to make the test and demo programs in
@@ -282,6 +293,8 @@
 	)
 
 demoprogs: $(PREDEMO) $(DEMODIRS)
+	@$(INSTALL_DIR) $(docdir)/demos/svgalib
+	@$(INSTALL_DIR) $(docdir)/demos/threeDKit
 	@for dir in $(DEMODIRS); do \
 		if [ -d $(SRCDIR)/$$dir ]; then \
 			(cd $$dir; \
diff -Naur svgalib-1.9.25-orig/Makefile.cfg svgalib-1.9.25/Makefile.cfg
--- svgalib-1.9.25-orig/Makefile.cfg	2006-07-14 11:38:58.000000000 +0000
+++ svgalib-1.9.25/Makefile.cfg	2010-12-13 19:14:05.000000000 +0000
@@ -44,7 +44,7 @@
 # Common prefix for installation directories.
 # NOTE: This directory must exist when you start the install.
 TOPDIR=
-prefix = $(TOPDIR)/usr/local
+prefix = $(TOPDIR)/usr
 exec_prefix = $(prefix)
 
 # Directory where the shared stubs and static library will be installed.
@@ -65,6 +65,12 @@
 # Directory where the man files will be installed.
 mandir = $(prefix)/share/man
 
+# Directory where the udev rules files will be installed.
+rulesdir = $(TOPDIR)/etc/udev/rules.d
+
+# Directory where the documentation will be installed.
+docdir = $(prefix)/share/doc/svgalib-$(VERSION)
+
 # Target binary format.
 TARGET_FORMAT = elf
 
@@ -320,10 +326,12 @@
 
 # Utilites used.
 AR	  = ar
-INSTALL_PROGRAM	= install -sm755
-INSTALL_SCRIPT	= install -m755
-INSTALL_SHLIB	= install -m755
-INSTALL_DATA	= install -m644
+INSTALL_PROGRAM	= install -sm0755
+INSTALL_SCRIPT	= install  -m0755
+INSTALL_SHLIB	= install  -m0755
+INSTALL_DATA	= install  -m0644
+INSTALL_DIR     = install  -m0755 -d
+
 
 ifneq ($(ARCH),i386)
 	NO_ASM = y
diff -Naur svgalib-1.9.25-orig/demos/Makefile svgalib-1.9.25/demos/Makefile
--- svgalib-1.9.25-orig/demos/Makefile	2004-11-16 07:59:52.000000000 +0000
+++ svgalib-1.9.25/demos/Makefile	2010-12-13 19:14:27.000000000 +0000
@@ -36,29 +36,38 @@
   LVGADEP = $(LIBS)
 endif
 
-all:	$(PROGS)
+all:	$(PROGS) graphics
 
 .PHONY: all clean cleanbin dep
 
 $(PROGS): $(LVGADEP)
 
 .c:
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $* $*.c $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $* $*.c $(LIBS) -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) $* $(docdir)/demos/svgalib
 
 rwpage: rwpage.pp
 	$(PC) -Rintel rwpage.pp
 
 testaccel: testaccel.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o testaccel testaccel.c $(LIBS) -lm
+	$(CC) $(CFLAGS) $(LDFLAGS) -o testaccel testaccel.c $(LIBS) -lm -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) testaccel $(docdir)/demos/svgalib
 
 accel: accel.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o accel accel.c $(LIBS) -lm
+	$(CC) $(CFLAGS) $(LDFLAGS) -o accel accel.c $(LIBS) -lm -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) accel $(docdir)/demos/svgalib
 
 linearspeed: linearspeed.c memset.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o linearspeed linearspeed.c memset.o $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o linearspeed linearspeed.c memset.o $(LIBS) -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) linearspeed $(docdir)/demos/svgalib
 
 buildcsr: mkcur.o
-	$(CC) -o buildcsr $(LDFLAGS) mkcur.o -lvgagl -lvga
+	$(CC) -o buildcsr $(LDFLAGS) mkcur.o -lvgagl -lvga -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) buildcsr $(docdir)/demos/svgalib
+
+graphics:
+	$(INSTALL_DATA) linuxlogo.bitmap eightbpp.xbm clut.xbm sixbpp.xbm \
+	wizard.xbm wizardmsk.xbm rwpage.pp $(docdir)/demos/svgalib
 
 clean:	cleanbin
 	rm -f .depend *.o *~ *.bak core
diff -Naur svgalib-1.9.25-orig/doc/Makefile svgalib-1.9.25/doc/Makefile
--- svgalib-1.9.25-orig/doc/Makefile	2005-07-02 16:21:57.000000000 +0000
+++ svgalib-1.9.25/doc/Makefile	2010-12-13 16:17:54.000000000 +0000
@@ -26,7 +26,7 @@
 SVGALIB=$(subst man,$(srcdir)/doc/man,$(SVGALIB1))
 VGAGL=$(subst man,$(srcdir)/doc/man,$(VGAGL1))
 THREED=$(subst man,$(srcdir)/doc/man,$(THREED1))
-COMPMANPAGES=$(shell cd $(srcdir)/doc; find man? -name "*.gz" -type f -print)
+COMPMANPAGES=$(shell cd $(srcdir)/doc; find man? -type f -print)
 
 .PHONY: clean ascii dvi ps install gunzip gzip
 
@@ -63,13 +63,12 @@
 	cat $(VGAGL) | grep -v '^\.so ' | troff -man -T$@ > vgagl.$@
 	cat $(THREED) | grep -v '^\.so ' | troff -man -T$@ > 3d.$@
 
-install: gzip
+install:
 	mkdir -p $(mandir)/man1 $(mandir)/man3 $(mandir)/man5 \
 		 $(mandir)/man6 $(mandir)/man7 $(mandir)/man8
 	for i in $(COMPMANPAGES); do\
 		$(INSTALL_DATA) $(srcdir)/doc/$$i $(mandir)/$$i; \
 	done
-	make gunzip
 ifdef MAKEWHATIS
 	@echo "Rebuilding the whatis database (this is slow!)"
 	@echo "You can comment this out in Makefile.cfg!"
diff -Naur svgalib-1.9.25-orig/kernel/svgalib_helper/Makefile svgalib-1.9.25/kernel/svgalib_helper/Makefile
--- svgalib-1.9.25-orig/kernel/svgalib_helper/Makefile	2006-05-20 12:31:04.000000000 +0000
+++ svgalib-1.9.25/kernel/svgalib_helper/Makefile	2010-12-13 16:19:18.000000000 +0000
@@ -25,7 +25,7 @@
 endif
 
 
-CLASS_SIMPLE := $(shell grep class_simple_create $(KDIR)/include/linux/device.h)
+CLASS_SIMPLE := $(shell grep -s class_simple_create $(KDIR)/include/linux/device.h)
 
 ifneq ($(CLASS_SIMPLE),)
   CLASS_CFLAGS = -DCLASS_SIMPLE=1
@@ -49,18 +49,9 @@
 svgalib_helper.o: $(svgalib_helper-objs)
 	$(LD) -r -o $@ $(svgalib_helper-objs)
 
-device:
-	rm -f /dev/svga /dev/svga?
-	mknod -m 666 /dev/svga c $(SVGALIB_HELPER_MAJOR) 0
-	mknod -m 666 /dev/svga1 c $(SVGALIB_HELPER_MAJOR) 1
-	mknod -m 666 /dev/svga2 c $(SVGALIB_HELPER_MAJOR) 2
-	mknod -m 666 /dev/svga3 c $(SVGALIB_HELPER_MAJOR) 3
-	mknod -m 666 /dev/svga4 c $(SVGALIB_HELPER_MAJOR) 4
-
-install: device modules_install
+install: modules_install
 
 modules_install: $(MODNAME)
-	mkdir -p /lib/modules/$(VER)/kernel/misc
-	install -m 0644 -c $(TARGET).ko /lib/modules/$(VER)/kernel/misc ||	install -m 0644 -c $(TARGET).o /lib/modules/$(VER)/kernel/misc
-	depmod -a $(VER)
+	mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
+	install -m 0644 -c $(TARGET).ko $(TOPDIR)/lib/modules/$(VER)/kernel/misc ||	install -m 0644 -c $(TARGET).o $(TOPDIR)/lib/modules/$(VER)/kernel/misc
 
diff -Naur svgalib-1.9.25-orig/kernel/svgalib_helper/Makefile.alt svgalib-1.9.25/kernel/svgalib_helper/Makefile.alt
--- svgalib-1.9.25-orig/kernel/svgalib_helper/Makefile.alt	2003-12-04 09:16:40.000000000 +0000
+++ svgalib-1.9.25/kernel/svgalib_helper/Makefile.alt	2010-12-13 16:17:54.000000000 +0000
@@ -37,7 +37,7 @@
 CFLAGS += -DSVGALIB_HELPER_MAJOR=$(SVGALIB_HELPER_MAJOR)
                                                                                                   
 ifeq (1,$(findstring 1,$(MODVER)))
-	CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
+	CFLAGS += -DMODVERSIONS -DCONFIG_MODVERSIONS=1
 endif
 
 TARGET = svgalib_helper
@@ -50,7 +50,8 @@
 	endif
 endif
 
-all: .depend $(OBJS)
+modules: $(OBJS)
+all: .depend modules
 
 $(TARGET).o: $(SRC:.c=.o)
 	$(LD) -r $^ -o $@
@@ -61,8 +62,8 @@
 install: device modules_install
 
 modules_install: $(OBJS)
-	mkdir -p /lib/modules/$(VER)/kernel/misc 
-	install -m 0644 -c $(OBJS) /lib/modules/$(VER)/kernel/misc
+	mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
+	install -m 0644 -c $(OBJS) $(TOPDIR)/lib/modules/$(VER)/kernel/misc
 
 device:
 	rm -f /dev/svgalib_helper* /dev/svga_helper* /dev/svga /dev/svga?
diff -Naur svgalib-1.9.25-orig/kernel/svgalib_helper/kernel26compat.h svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h
--- svgalib-1.9.25-orig/kernel/svgalib_helper/kernel26compat.h	2006-05-20 12:17:13.000000000 +0000
+++ svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h	2010-12-13 16:17:54.000000000 +0000
@@ -10,7 +10,7 @@
 # define PCI_GET_CLASS pci_find_class
 # define PCI_GET_DEVICE pci_find_device
 
-# if defined (PG_chainlock)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
 #  define my_io_remap_page_range(vma, start, ofs, len, prot) \
 		io_remap_page_range(vma,start,ofs,len,prot)
 # else
@@ -70,6 +70,7 @@
 
 /* These are also not present in 2.6 kernels ... */
 #if (!defined _LINUX_DEVFS_FS_KERNEL_H) || (defined KERNEL_2_6)
+#include <linux/fs.h>
 static inline int devfs_register_chrdev (unsigned int major, const char *name,
                                          struct file_operations *fops)
 {
@@ -77,7 +78,12 @@
 }
 static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
 {
-    return unregister_chrdev (major, name);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)    
+   return unregister_chrdev (major, name);
+#else
+    unregister_chrdev (major, name);
+    return 0;
+#endif
 }
 #endif
 
@@ -99,7 +105,8 @@
      class_device_create(svgalib_helper_class,                      	\
                              MKDEV(SVGALIB_HELPER_MAJOR, _minor),       \
                              &sh_pci_devs[_minor]->dev->dev, _name);
-#else /* 2.6.15 changed class_device_create */
+/* 2.6.15 changed class_device_create */
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
 #  define SLH_SYSFS_ADD_CONTROL                                         \
      class_device_create(svgalib_helper_class, NULL,                	\
                              MKDEV(SVGALIB_HELPER_MAJOR, 0),            \
@@ -109,7 +116,42 @@
      class_device_create(svgalib_helper_class, NULL,                	\
                              MKDEV(SVGALIB_HELPER_MAJOR, _minor),       \
                              &sh_pci_devs[_minor]->dev->dev, _name);
-#endif /* 2.6.15 */
+/* 2.6.26 changed class_device_create to device_create */
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+#  define SLH_SYSFS_ADD_CONTROL                                          \
+     device_create(svgalib_helper_class, NULL,                           \
+                             MKDEV(SVGALIB_HELPER_MAJOR, 0),             \
+                             "svga");
+
+#  define SLH_SYSFS_ADD_DEVICE(_name, _minor)                            \
+     device_create(svgalib_helper_class, &sh_pci_devs[_minor]->dev->dev, \
+                             MKDEV(SVGALIB_HELPER_MAJOR, _minor),        \
+                             _name);
+/* 2.6.27 changed device_create to device_create_drvdata */
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#  define SLH_SYSFS_ADD_CONTROL                                          \
+     device_create_drvdata(svgalib_helper_class, NULL,                   \
+                           MKDEV(SVGALIB_HELPER_MAJOR, 0),               \
+                           "%s%d", "svga", 0);
+
+#  define SLH_SYSFS_ADD_DEVICE(_name, _minor)                            \
+     device_create_drvdata(svgalib_helper_class,                         \
+                           &sh_pci_devs[_minor]->dev->dev,               \
+                           MKDEV(SVGALIB_HELPER_MAJOR, _minor),          \
+                           "%s%d", _name, _minor);
+/* 2.6.28 changed device_create_drvdata back to device_create */
+#else
+#  define SLH_SYSFS_ADD_CONTROL                                         \
+     device_create(svgalib_helper_class, NULL,                          \
+                   MKDEV(SVGALIB_HELPER_MAJOR, 0), NULL,                \
+                   "%s%d", "svga", 0);
+
+#  define SLH_SYSFS_ADD_DEVICE(_name, _minor)                           \
+     device_create(svgalib_helper_class,                                \
+                   &sh_pci_devs[_minor]->dev->dev,                      \
+                   MKDEV(SVGALIB_HELPER_MAJOR, _minor), NULL,           \
+                   "%s%d", _name, _minor);
+#endif
 
 #  define SLH_SYSFS_REMOVE_DEVICE(i)                                    \
      class_destroy(svgalib_helper_class);
@@ -161,3 +203,7 @@
 #ifndef PCI_VENDOR_ID_RENDITION 
 #define PCI_VENDOR_ID_RENDITION               0x1163
 #endif
+
+#ifndef IRQF_SHARED
+# define IRQF_SHARED SA_SHIRQ
+#endif
diff -Naur svgalib-1.9.25-orig/kernel/svgalib_helper/main.c svgalib-1.9.25/kernel/svgalib_helper/main.c
--- svgalib-1.9.25-orig/kernel/svgalib_helper/main.c	2006-01-12 18:17:53.000000000 +0000
+++ svgalib-1.9.25/kernel/svgalib_helper/main.c	2010-12-13 16:17:54.000000000 +0000
@@ -1,5 +1,3 @@
-#include <linux/config.h>
-
 #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
 # define MODVERSIONS
 #endif
@@ -17,15 +15,22 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
 #include <linux/devfs_fs_kernel.h>
+#endif
 #include <linux/mm.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 #include <linux/thread_info.h>
+#endif
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 
 #include <linux/sched.h>
 #include <linux/wait.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 #include <linux/syscalls.h>
+#endif
 
 #define __KERNEL_SYSCALLS__
 #include <linux/unistd.h>
@@ -50,7 +55,7 @@
 #include "displaystart.h"
 
 int debug=0;
-static int all_devices=0;
+int all_devices=0;
 int num_devices=0;
 
 static char *sdev_id="svgalib_helper";
@@ -98,7 +103,11 @@
 static volatile int vsync=0;
 static wait_queue_head_t vsync_wait;
 
-static irqreturn_t vsync_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t vsync_interrupt(int irq, void *dev_id
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+, struct pt_regs *regs
+#endif
+)
 {
     struct sh_pci_device *dev = (struct sh_pci_device *)dev_id;
 
@@ -153,9 +162,15 @@
 	get_user(pciv.address, &user_pciv->address); \
 	get_user(pciv.val, &user_pciv->val); 
 #define PUT_PCIV \
-	put_user(pciv.val, &user_pciv->val); 
+	put_user(pciv.val, &user_pciv->val);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) 
 static int svgalib_helper_ioctl( struct inode *inode, struct file *filp, 
                           unsigned int cmd, unsigned long arg) {
+#else
+static int svgalib_helper_ioctl(struct file *filp, 
+                          unsigned int cmd, unsigned long arg) {
+    struct inode *inode=filp->f_dentry->d_inode;
+#endif
 
     io_t iov, *user_iov=(io_t *)arg;
     pcic_t pciv, *user_pciv=(pcic_t *)arg;
@@ -355,7 +370,7 @@
                 vsync=1;
                 i=0;
                 while(irqs[i]!=-1)
-                    request_irq(irqs[i++], vsync_interrupt, SA_SHIRQ, "svgalib_helper", sdev_id);
+                    request_irq(irqs[i++], vsync_interrupt, IRQF_SHARED, "svgalib_helper", sdev_id);
                 vga_enable_vsync((void *)sdev_id);
 				wait_event_interruptible(vsync_wait, !vsync);
                 i=0;
@@ -443,7 +458,7 @@
 		int i=sh_pci_devs[minor]->dev->irq;
 		sh_pci_devs[minor]->opencount++;
 		if(sh_pci_devs[minor]->opencount==1 && i!=0 && i!=-1 && i!=255)
-			request_irq(i, vsync_interrupt, SA_SHIRQ, "svgalib_helper", sh_pci_devs[minor]);
+			request_irq(i, vsync_interrupt, IRQF_SHARED, "svgalib_helper", sh_pci_devs[minor]);
 	}
 
 #ifndef KERNEL_2_6
@@ -586,7 +601,11 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
    .owner	= THIS_MODULE,
 #endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
    .ioctl	= svgalib_helper_ioctl,
+#else
+   .unlocked_ioctl	= svgalib_helper_ioctl,
+#endif
    .mmap	= svgalib_helper_mmap,
    .open	= svgalib_helper_open,
    .release	= svgalib_helper_release,
@@ -763,10 +782,15 @@
 
 }
 
+#ifdef KERNEL_2_6
+module_param(debug, int, 0);
+module_param(all_devices, int, 0);
+#else
 MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "Debug output level.");
-
 MODULE_PARM(all_devices, "i");
+#endif
+
+MODULE_PARM_DESC(debug, "Debug output level.");
 MODULE_PARM_DESC(all_devices, "Give access to all PCI devices, regardless of class.");
 
 
diff -Naur svgalib-1.9.25-orig/lrmi-0.6m/lrmi.c svgalib-1.9.25/lrmi-0.6m/lrmi.c
--- svgalib-1.9.25-orig/lrmi-0.6m/lrmi.c	2005-04-14 12:41:08.000000000 +0000
+++ svgalib-1.9.25/lrmi-0.6m/lrmi.c	2010-12-13 16:17:54.000000000 +0000
@@ -170,6 +170,14 @@
 	}
 
 
+#ifndef TF_MASK
+#define TF_MASK X86_EFLAGS_TF
+#define IF_MASK X86_EFLAGS_IF
+#define IOPL_MASK X86_EFLAGS_IOPL
+#define VIF_MASK X86_EFLAGS_VIF
+#define VIP_MASK X86_EFLAGS_VIP
+#endif
+
 #define DEFAULT_VM86_FLAGS 	(IF_MASK | IOPL_MASK)
 #define DEFAULT_STACK_SIZE 	0x1000
 #define RETURN_TO_32_INT 	255
diff -Naur svgalib-1.9.25-orig/lrmi-0.9/lrmi.c svgalib-1.9.25/lrmi-0.9/lrmi.c
--- svgalib-1.9.25-orig/lrmi-0.9/lrmi.c	2005-09-01 06:43:52.000000000 +0000
+++ svgalib-1.9.25/lrmi-0.9/lrmi.c	2010-12-13 16:17:54.000000000 +0000
@@ -203,6 +203,13 @@
 
 
 #if defined(__linux__)
+#ifndef TF_MASK
+#define TF_MASK X86_EFLAGS_TF
+#define IF_MASK X86_EFLAGS_IF
+#define IOPL_MASK X86_EFLAGS_IOPL
+#define VIF_MASK X86_EFLAGS_VIF
+#define VIP_MASK X86_EFLAGS_VIP
+#endif
 #define DEFAULT_VM86_FLAGS 	(IF_MASK | IOPL_MASK)
 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 #define DEFAULT_VM86_FLAGS  (PSL_I | PSL_IOPL)
diff -Naur svgalib-1.9.25-orig/src/lrmi.6.c svgalib-1.9.25/src/lrmi.6.c
--- svgalib-1.9.25-orig/src/lrmi.6.c	2005-10-22 11:29:17.000000000 +0000
+++ svgalib-1.9.25/src/lrmi.6.c	2010-12-13 16:17:54.000000000 +0000
@@ -169,6 +169,13 @@
 		}
 	}
 
+#ifndef TF_MASK
+#define TF_MASK X86_EFLAGS_TF
+#define IF_MASK X86_EFLAGS_IF
+#define IOPL_MASK X86_EFLAGS_IOPL
+#define VIF_MASK X86_EFLAGS_VIF
+#define VIP_MASK X86_EFLAGS_VIP
+#endif
 
 #define DEFAULT_VM86_FLAGS 	(IF_MASK | IOPL_MASK)
 #define DEFAULT_STACK_SIZE 	0x1000
diff -Naur svgalib-1.9.25-orig/src/lrmi.9.c svgalib-1.9.25/src/lrmi.9.c
--- svgalib-1.9.25-orig/src/lrmi.9.c	2005-10-31 18:42:46.000000000 +0000
+++ svgalib-1.9.25/src/lrmi.9.c	2010-12-13 16:17:54.000000000 +0000
@@ -206,6 +206,13 @@
 
 
 #if defined(__linux__)
+#ifndef TF_MASK
+#define TF_MASK X86_EFLAGS_TF
+#define IF_MASK X86_EFLAGS_IF
+#define IOPL_MASK X86_EFLAGS_IOPL
+#define VIF_MASK X86_EFLAGS_VIF
+#define VIP_MASK X86_EFLAGS_VIP
+#endif
 #define DEFAULT_VM86_FLAGS 	(IF_MASK | IOPL_MASK)
 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 #define DEFAULT_VM86_FLAGS  (PSL_I | PSL_IOPL)
diff -Naur svgalib-1.9.25-orig/src/udev/56-svga.rules svgalib-1.9.25/src/udev/56-svga.rules
--- svgalib-1.9.25-orig/src/udev/56-svga.rules	1970-01-01 00:00:00.000000000 +0000
+++ svgalib-1.9.25/src/udev/56-svga.rules	2010-12-13 16:32:43.000000000 +0000
@@ -0,0 +1,6 @@
+# /etc/udev/rules.d/56-svga.rules
+#
+# When the svgalib_helper.ko module is loaded, it creates file in /dev
+# This rule sets the proper group and permissions
+#
+KERNEL=="svga*", MODE="0660", GROUP="video"
diff -Naur svgalib-1.9.25-orig/threeDKit/Makefile svgalib-1.9.25/threeDKit/Makefile
--- svgalib-1.9.25-orig/threeDKit/Makefile	2006-07-14 11:30:49.000000000 +0000
+++ svgalib-1.9.25/threeDKit/Makefile	2010-12-13 19:14:54.000000000 +0000
@@ -14,7 +14,7 @@
 # Compiler Section (overrides Makefile.cfg)
 #----------------------------------------------------------------------
 
-INCLUDES += -I$(srcdir)/src
+INCLUDES += -I$(srcdir)/src -I$(srcdir)/gl
 
 #----------------------------------------------------------------------
 # Rules Section
@@ -48,7 +48,7 @@
 
 else                                                               
 
-all:	lib3dkit.so.$(VERSION) plane wrapdemo
+all:	lib3dkit.so.$(VERSION) plane wrapdemo otherfiles
 
 # These rules are for ELF only.
 lib3dkit.so.$(VERSION): $(OBJECTS)
@@ -57,7 +57,7 @@
 
 $(sharedlibdir)/lib3dkit.so.$(VERSION): lib3dkit.so.$(VERSION)
 	$(INSTALL_SHLIB) $< $(sharedlibdir)/$<
-	(cd $(sharedlibdir); ln -sf lib3dkit.so.$(VERSION) `echo lib3dkit.so.$(VERSION) | sed 's/\.so\..*/.so/'` )
+	(cd $(sharedlibdir); ln -sf lib3dkit.so.$(VERSION) `echo lib3dkit.so.$(VERSION) | sed 's/\.so\..*/.so/'`; ln -sf lib3dkit.so.$(VERSION) `echo lib3dkit.so.$(VERSION) | sed 's/\.so\..*/.so.1/'` )
 	-ldconfig
 
 install: $(sharedlibdir)/lib3dkit.so.$(VERSION) installheaders
@@ -76,15 +76,20 @@
 	$(AR) rcs lib3dkit.a $(ALLOBJS)
 
 plane: planukit.o planinit.o $(OBJECTS) $(LVGADEP)
-	$(CC) $(LDFLAGS) -o plane planukit.o planinit.o $(OBJECTS) $(LIBS)
+	$(CC) $(LDFLAGS) -o plane planukit.o planinit.o $(OBJECTS) $(LIBS) -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) plane $(docdir)/demos/threeDKit
 	# chown root plane
 	# chmod u+s plane
 
 wrapdemo: wrapdemo.o $(OBJECTS) $(LVGADEP)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o wrapdemo wrapdemo.c $(OBJECTS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o wrapdemo wrapdemo.c $(OBJECTS) $(LIBS) -L$(srcdir)/sharedlib
+	$(INSTALL_PROGRAM) wrapdemo $(docdir)/demos/threeDKit
 	# chown root wrapdemo
 	# chmod u+s wrapdemo
 
+otherfiles:
+	$(INSTALL_DATA) susannaRUBENS.bmp 0-README $(docdir)/demos/threeDKit
+
 clean:
 	rm -f *.o core lib3dkit.a lib3dkit.so.* plane wrapdemo *.bak
 
diff -Naur svgalib-1.9.25-orig/utils/gtf/gtfcalc.c svgalib-1.9.25/utils/gtf/gtfcalc.c
--- svgalib-1.9.25-orig/utils/gtf/gtfcalc.c	2005-07-10 19:33:16.000000000 +0000
+++ svgalib-1.9.25/utils/gtf/gtfcalc.c	2010-12-13 16:17:54.000000000 +0000
@@ -64,7 +64,9 @@
 
 /*-------------------------- Implementation -------------------------------*/
 
-static double round(double v)
+static double svg_round(double v);
+
+double svg_round(double v)
 {
 	return floor(v + 0.5);
 }
@@ -84,9 +86,9 @@
 ****************************************************************************/
 {
 	c->margin = GC.margin;
-	c->cellGran = round(GC.cellGran);
-	c->minPorch = round(GC.minPorch);
-	c->vSyncRqd = round(GC.vSyncRqd);
+	c->cellGran = svg_round(GC.cellGran);
+	c->minPorch = svg_round(GC.minPorch);
+	c->vSyncRqd = svg_round(GC.vSyncRqd);
 	c->hSync = GC.hSync;
 	c->minVSyncBP = GC.minVSyncBP;
 	if (GC.k == 0)
@@ -140,13 +142,13 @@
 	vFreq = hFreq = dotClock = freq;
 
 	/* Round pixels to character cell granularity */
-	hPixels = round(hPixels / c.cellGran) * c.cellGran;
+	hPixels = svg_round(hPixels / c.cellGran) * c.cellGran;
 
 	/* For interlaced mode halve the vertical parameters, and double
 	 * the required field refresh rate.
 	 */
 	if (wantInterlace) {
-		vLines = round(vLines / 2);
+		vLines = svg_round(vLines / 2);
 		vFieldRate = vFreq * 2;
 		dotClock = dotClock * 2;
 		interlace = 0.5;
@@ -158,8 +160,8 @@
 
 	/* Determine the lines for margins */
 	if (wantMargins) {
-		topMarginLines = round(c.margin / 100 * vLines);
-		botMarginLines = round(c.margin / 100 * vLines);
+		topMarginLines = svg_round(c.margin / 100 * vLines);
+		botMarginLines = svg_round(c.margin / 100 * vLines);
 		}
 	else {
 		topMarginLines = 0;
@@ -173,11 +175,11 @@
 				(vLines + (2*topMarginLines) + c.minPorch + interlace) * 1000000;
 
 			/* Find the number of lines in vSync + back porch */
-			vSyncBP = round(c.minVSyncBP / hPeriodEst);
+			vSyncBP = svg_round(c.minVSyncBP / hPeriodEst);
 			}
 		else if (type == GTF_lockHF) {
 			/* Find the number of lines in vSync + back porch */
-			vSyncBP = round((c.minVSyncBP * hFreq) / 1000);
+			vSyncBP = svg_round((c.minVSyncBP * hFreq) / 1000);
 			}
 
 		/* Find the number of lines in the V back porch alone */
@@ -205,8 +207,8 @@
 
 	/* Find the number of pixels in the left and right margins */
 	if (wantMargins) {
-		leftMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran);
-		rightMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran);
+		leftMarginPixels = svg_round(hPixels * c.margin) / (100 * c.cellGran);
+		rightMarginPixels = svg_round(hPixels * c.margin) / (100 * c.cellGran);
 		}
 	else {
 		leftMarginPixels = 0;
@@ -235,17 +237,17 @@
 		}
 
 	/* Find the number of pixels in blanking time */
-	hBlankPixels = round((hTotalActivePixels * idealDutyCycle) /
+	hBlankPixels = svg_round((hTotalActivePixels * idealDutyCycle) /
 		((100 - idealDutyCycle) * 2 * c.cellGran)) * (2 * c.cellGran);
 
 	/* Find the total number of pixels */
 	hTotalPixels = hTotalActivePixels + hBlankPixels;
 
 	/* Find the horizontal back porch */
-	hBackPorch = round((hBlankPixels / 2) / c.cellGran) * c.cellGran;
+	hBackPorch = svg_round((hBlankPixels / 2) / c.cellGran) * c.cellGran;
 
 	/* Find the horizontal sync width */
-	hSyncWidth = round(((c.hSync/100) * hTotalPixels) / c.cellGran) * c.cellGran;
+	hSyncWidth = svg_round(((c.hSync/100) * hTotalPixels) / c.cellGran) * c.cellGran;
 
 	/* Find the horizontal sync + back porch */
 	hSyncBP = hBackPorch + hSyncWidth;
@@ -258,7 +260,7 @@
 		hPeriod = 1000 / hFreq;
 
 		/* Find the number of lines in vSync + back porch */
-		vSyncBP = round((c.minVSyncBP * hFreq) / 1000);
+		vSyncBP = svg_round((c.minVSyncBP * hFreq) / 1000);
 
 		/* Find the number of lines in the V back porch alone */
 		vBackPorch = vSyncBP - c.vSyncRqd;
